diff options
Diffstat (limited to 't/base')
-rw-r--r-- | t/base/cond.t | 19 | ||||
-rw-r--r-- | t/base/if.t | 11 | ||||
-rw-r--r-- | t/base/lex.t | 78 | ||||
-rw-r--r-- | t/base/pat.t | 11 | ||||
-rw-r--r-- | t/base/term.t | 42 |
5 files changed, 161 insertions, 0 deletions
diff --git a/t/base/cond.t b/t/base/cond.t new file mode 100644 index 0000000000..592580120f --- /dev/null +++ b/t/base/cond.t @@ -0,0 +1,19 @@ +#!./perl + +# $Header: cond.t,v 4.0 91/03/20 01:48:54 lwall Locked $ + +# make sure conditional operators work + +print "1..4\n"; + +$x = '0'; + +$x eq $x && (print "ok 1\n"); +$x ne $x && (print "not ok 1\n"); +$x eq $x || (print "not ok 2\n"); +$x ne $x || (print "ok 2\n"); + +$x == $x && (print "ok 3\n"); +$x != $x && (print "not ok 3\n"); +$x == $x || (print "not ok 4\n"); +$x != $x || (print "ok 4\n"); diff --git a/t/base/if.t b/t/base/if.t new file mode 100644 index 0000000000..6965ef5141 --- /dev/null +++ b/t/base/if.t @@ -0,0 +1,11 @@ +#!./perl + +# $Header: if.t,v 4.0 91/03/20 01:49:03 lwall Locked $ + +print "1..2\n"; + +# first test to see if we can run the tests. + +$x = 'test'; +if ($x eq $x) { print "ok 1\n"; } else { print "not ok 1\n";} +if ($x ne $x) { print "not ok 2\n"; } else { print "ok 2\n";} diff --git a/t/base/lex.t b/t/base/lex.t new file mode 100644 index 0000000000..0c94b875a3 --- /dev/null +++ b/t/base/lex.t @@ -0,0 +1,78 @@ +#!./perl + +# $Header: lex.t,v 4.0 91/03/20 01:49:08 lwall Locked $ + +print "1..18\n"; + +$ # this is the register <space> += 'x'; + +print "#1 :$ : eq :x:\n"; +if ($ eq 'x') {print "ok 1\n";} else {print "not ok 1\n";} + +$x = $#; # this is the register $# + +if ($x eq '') {print "ok 2\n";} else {print "not ok 2\n";} + +$x = $#x; + +if ($x eq '-1') {print "ok 3\n";} else {print "not ok 3\n";} + +$x = '\\'; # '; + +if (length($x) == 1) {print "ok 4\n";} else {print "not ok 4\n";} + +eval 'while (0) { + print "foo\n"; +} +/^/ && (print "ok 5\n"); +'; + +eval '$foo{1} / 1;'; +if (!$@) {print "ok 6\n";} else {print "not ok 6\n";} + +eval '$foo = 123+123.4+123e4+123.4E5+123.4e+5+.12;'; + +$foo = int($foo * 100 + .5); +if ($foo eq 2591024652) {print "ok 7\n";} else {print "not ok 7 :$foo:\n";} + +print <<'EOF'; +ok 8 +EOF + +$foo = 'ok 9'; +print <<EOF; +$foo +EOF + +eval <<\EOE, print $@; +print <<'EOF'; +ok 10 +EOF + +$foo = 'ok 11'; +print <<EOF; +$foo +EOF +EOE + +print <<`EOS` . <<\EOF; +echo ok 12 +EOS +ok 13 +EOF + +print qq/ok 14\n/; +print qq(ok 15\n); + +print qq +ok 16\n +; + +print q<ok 17 +>; + +print <<; # Yow! +ok 18 + +# previous line intentionally left blank. diff --git a/t/base/pat.t b/t/base/pat.t new file mode 100644 index 0000000000..8ad88dd331 --- /dev/null +++ b/t/base/pat.t @@ -0,0 +1,11 @@ +#!./perl + +# $Header: pat.t,v 4.0 91/03/20 01:49:12 lwall Locked $ + +print "1..2\n"; + +# first test to see if we can run the tests. + +$_ = 'test'; +if (/^test/) { print "ok 1\n"; } else { print "not ok 1\n";} +if (/^foo/) { print "not ok 2\n"; } else { print "ok 2\n";} diff --git a/t/base/term.t b/t/base/term.t new file mode 100644 index 0000000000..c322242710 --- /dev/null +++ b/t/base/term.t @@ -0,0 +1,42 @@ +#!./perl + +# $Header: term.t,v 4.0 91/03/20 01:49:17 lwall Locked $ + +print "1..6\n"; + +# check "" interpretation + +$x = "\n"; +if ($x lt ' ') {print "ok 1\n";} else {print "not ok 1\n";} + +# check `` processing + +$x = `echo hi there`; +if ($x eq "hi there\n") {print "ok 2\n";} else {print "not ok 2\n";} + +# check $#array + +$x[0] = 'foo'; +$x[1] = 'foo'; +$tmp = $#x; +print "#3\t:$tmp: == :1:\n"; +if ($#x == '1') {print "ok 3\n";} else {print "not ok 3\n";} + +# check numeric literal + +$x = 1; +if ($x == '1') {print "ok 4\n";} else {print "not ok 4\n";} + +# check <> pseudoliteral + +open(try, "/dev/null") || (die "Can't open /dev/null."); +if (<try> eq '') { + print "ok 5\n"; +} +else { + print "not ok 5\n"; + die "/dev/null IS NOT A CHARACTER SPECIAL FILE!!!!\n" unless -c '/dev/null'; +} + +open(try, "../Makefile") || (die "Can't open ../Makefile."); +if (<try> ne '') {print "ok 6\n";} else {print "not ok 6\n";} |