diff options
author | Larry Wall <lwall@netlabs.com> | 1993-10-07 23:00:00 +0000 |
---|---|---|
committer | Larry Wall <lwall@netlabs.com> | 1993-10-07 23:00:00 +0000 |
commit | 79072805bf63abe5b5978b5928ab00d360ea3e7f (patch) | |
tree | 96688fcd69f9c8d2110e93c350b4d0025eaf240d /t/op | |
parent | e334a159a5616cab575044bafaf68f75b7bb3a16 (diff) | |
download | perl-79072805bf63abe5b5978b5928ab00d360ea3e7f.tar.gz |
perl 5.0 alpha 2perl-5a2
[editor's note: from history.perl.org. The sparc executables
originally included in the distribution are not in this commit.]
Diffstat (limited to 't/op')
-rwxr-xr-x[-rw-r--r--] | t/op/append.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/array.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/auto.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/chop.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/cond.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/dbm.t | 16 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/delete.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/do.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/each.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/eval.t | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/exec.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/exp.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/flip.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/fork.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/glob.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/goto.t | 26 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/groups.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/index.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/int.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/join.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/list.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/local.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/magic.t | 24 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/mkdir.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/oct.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/ord.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/pack.t | 26 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/pat.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/push.t | 11 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/range.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/read.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/readdir.t | 0 | ||||
-rwxr-xr-x | t/op/ref.t | 179 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/regexp.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/repeat.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/s.t | 27 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/sleep.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/sort.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/split.t | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/sprintf.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/stat.t | 7 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/study.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/substr.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/time.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/undef.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/unshift.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/vec.t | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/op/write.t | 2 |
48 files changed, 333 insertions, 65 deletions
diff --git a/t/op/append.t b/t/op/append.t index 9140c16b83..d11514615a 100644..100755 --- a/t/op/append.t +++ b/t/op/append.t @@ -1,6 +1,6 @@ #!./perl -# $Header: append.t,v 4.0 91/03/20 01:51:23 lwall Locked $ +# $RCSfile: append.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:36 $ print "1..3\n"; diff --git a/t/op/array.t b/t/op/array.t index 18fe288356..089fb5528e 100644..100755 --- a/t/op/array.t +++ b/t/op/array.t @@ -1,6 +1,6 @@ #!./perl -# $Header: array.t,v 4.0 91/03/20 01:51:31 lwall Locked $ +# $RCSfile: array.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:37 $ print "1..36\n"; diff --git a/t/op/auto.t b/t/op/auto.t index e1122a5774..93a42f8472 100644..100755 --- a/t/op/auto.t +++ b/t/op/auto.t @@ -1,6 +1,6 @@ #!./perl -# $Header: auto.t,v 4.0 91/03/20 01:51:35 lwall Locked $ +# $RCSfile: auto.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:39 $ print "1..34\n"; diff --git a/t/op/chop.t b/t/op/chop.t index ba6d6262b3..d20b546465 100644..100755 --- a/t/op/chop.t +++ b/t/op/chop.t @@ -1,6 +1,6 @@ #!./perl -# $Header: chop.t,v 4.0 91/03/20 01:51:42 lwall Locked $ +# $RCSfile: chop.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:40 $ print "1..4\n"; diff --git a/t/op/cond.t b/t/op/cond.t index 31baf9d05f..427efb4887 100644..100755 --- a/t/op/cond.t +++ b/t/op/cond.t @@ -1,6 +1,6 @@ #!./perl -# $Header: cond.t,v 4.0 91/03/20 01:51:47 lwall Locked $ +# $RCSfile: cond.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:41 $ print "1..4\n"; diff --git a/t/op/dbm.t b/t/op/dbm.t index 647d3efb71..f09ca4febf 100644..100755 --- a/t/op/dbm.t +++ b/t/op/dbm.t @@ -1,6 +1,6 @@ #!./perl -# $RCSfile: dbm.t,v $$Revision: 4.0.1.1 $$Date: 92/06/08 15:43:02 $ +# $RCSfile: dbm.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:43 $ if (!-r '/usr/include/dbm.h' && !-r '/usr/include/ndbm.h' && !-r '/usr/include/rpcsvc/dbm.h') { @@ -11,10 +11,18 @@ if (!-r '/usr/include/dbm.h' && !-r '/usr/include/ndbm.h' print "1..12\n"; unlink <Op.dbmx.*>; +unlink Op.dbmx; # in case we're running gdbm + umask(0); print (dbmopen(h,'Op.dbmx',0640) ? "ok 1\n" : "not ok 1\n"); + +$Dfile = "Op.dbmx.pag"; +if (! -e $Dfile) { + $Dfile = "Op.dbmx"; + print "# Probably a gdbm database\n"; +} ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime, - $blksize,$blocks) = stat('Op.dbmx.pag'); + $blksize,$blocks) = stat($Dfile); print (($mode & 0777) == 0640 ? "ok 2\n" : "not ok 2\n"); while (($key,$value) = each(h)) { $i++; @@ -93,7 +101,7 @@ for ($i = 1; $i < 200; $i++) { $ok = 0 unless $h{$i} == $i; } print ($ok ? "ok 8\n" : "not ok 8\n"); ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime, - $blksize,$blocks) = stat('Op.dbmx.pag'); + $blksize,$blocks) = stat($Dfile); print ($size > 0 ? "ok 9\n" : "not ok 9\n"); @h{0..200} = 200..400; @@ -103,4 +111,4 @@ print join(':',200..400) eq join(':',@foo) ? "ok 10\n" : "not ok 10\n"; print ($h{'foo'} eq '' ? "ok 11\n" : "not ok 11\n"); print ($h{''} eq 'bar' ? "ok 12\n" : "not ok 12\n"); -unlink 'Op.dbmx.dir', 'Op.dbmx.pag'; +unlink 'Op.dbmx.dir', $Dfile; diff --git a/t/op/delete.t b/t/op/delete.t index b5920dd397..86ed9b47ba 100644..100755 --- a/t/op/delete.t +++ b/t/op/delete.t @@ -1,6 +1,6 @@ #!./perl -# $Header: delete.t,v 4.0 91/03/20 01:51:56 lwall Locked $ +# $RCSfile: delete.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:44 $ print "1..6\n"; diff --git a/t/op/do.t b/t/op/do.t index f75ca3010e..db4623720e 100644..100755 --- a/t/op/do.t +++ b/t/op/do.t @@ -1,6 +1,6 @@ #!./perl -# $Header: do.t,v 4.0 91/03/20 01:52:08 lwall Locked $ +# $RCSfile: do.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:45 $ sub foo1 { diff --git a/t/op/each.t b/t/op/each.t index d759fda549..7a58fc8dcc 100644..100755 --- a/t/op/each.t +++ b/t/op/each.t @@ -1,6 +1,6 @@ #!./perl -# $Header: each.t,v 4.0 91/03/20 01:52:14 lwall Locked $ +# $RCSfile: each.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:47 $ print "1..3\n"; diff --git a/t/op/eval.t b/t/op/eval.t index 7bca608137..6d0a67b533 100644..100755 --- a/t/op/eval.t +++ b/t/op/eval.t @@ -1,6 +1,6 @@ #!./perl -# $RCSfile: eval.t,v $$Revision: 4.0.1.1 $$Date: 91/11/05 18:43:19 $ +# $RCSfile: eval.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:48 $ print "1..16\n"; @@ -15,7 +15,7 @@ eval "\$foo\n = # this is a comment\n'ok 4\n';"; print $foo; print eval ' -$foo ='; # this tests for a call through yyerror() +$foo =;'; # this tests for a call through yyerror() if ($@ =~ /line 2/) {print "ok 5\n";} else {print "not ok 5\n";} print eval '$foo = /'; # this tests for a call through fatal() diff --git a/t/op/exec.t b/t/op/exec.t index f3012fd2f9..1103a1a464 100644..100755 --- a/t/op/exec.t +++ b/t/op/exec.t @@ -1,6 +1,6 @@ #!./perl -# $Header: exec.t,v 4.0 91/03/20 01:52:25 lwall Locked $ +# $RCSfile: exec.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:49 $ $| = 1; # flush stdout print "1..8\n"; diff --git a/t/op/exp.t b/t/op/exp.t index 776d2634da..5efc9ba950 100644..100755 --- a/t/op/exp.t +++ b/t/op/exp.t @@ -1,6 +1,6 @@ #!./perl -# $Header: exp.t,v 4.0 91/03/20 01:52:31 lwall Locked $ +# $RCSfile: exp.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:50 $ print "1..6\n"; diff --git a/t/op/flip.t b/t/op/flip.t index 35f100cdef..72425da3a2 100644..100755 --- a/t/op/flip.t +++ b/t/op/flip.t @@ -1,6 +1,6 @@ #!./perl -# $Header: flip.t,v 4.0 91/03/20 01:52:36 lwall Locked $ +# $RCSfile: flip.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:52 $ print "1..8\n"; diff --git a/t/op/fork.t b/t/op/fork.t index 55696fd98f..598310b63f 100644..100755 --- a/t/op/fork.t +++ b/t/op/fork.t @@ -1,6 +1,6 @@ #!./perl -# $Header: fork.t,v 4.0 91/03/20 01:52:43 lwall Locked $ +# $RCSfile: fork.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:53 $ $| = 1; print "1..2\n"; diff --git a/t/op/glob.t b/t/op/glob.t index 1250a72542..b4038442bd 100644..100755 --- a/t/op/glob.t +++ b/t/op/glob.t @@ -1,6 +1,6 @@ #!./perl -# $Header: glob.t,v 4.0 91/03/20 01:52:49 lwall Locked $ +# $RCSfile: glob.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:55 $ print "1..4\n"; diff --git a/t/op/goto.t b/t/op/goto.t index 29bf797a58..0b89921b94 100644..100755 --- a/t/op/goto.t +++ b/t/op/goto.t @@ -1,10 +1,10 @@ #!./perl -# $RCSfile: goto.t,v $$Revision: 4.0.1.1 $$Date: 92/06/08 15:43:25 $ +# $RCSfile: goto.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:56 $ -print "1..3\n"; +print "1..5\n"; -while (0) { +while ($?) { $foo = 1; label1: $foo = 2; @@ -31,3 +31,23 @@ if ($foo == 4) {print "ok 2\n";} else {print "not ok 2\n";} $x = `./perl -e 'goto foo;' 2>&1`; if ($x =~ /label/) {print "ok 3\n";} else {print "not ok 3\n";} + +sub foo { + goto bar; + print "not ok 4\n"; + return; +bar: + print "ok 4\n"; +} + +&foo; + +sub bar { + $x = 'exitcode'; + eval "goto $x"; # Do not take this as exemplary code!!! +} + +&bar; +exit; +exitcode: +print "ok 5\n"; diff --git a/t/op/groups.t b/t/op/groups.t index e1520cc3d6..4445953966 100644..100755 --- a/t/op/groups.t +++ b/t/op/groups.t @@ -26,7 +26,7 @@ for (split(' ', $()) { $gr1 = join(' ', sort @gr); -$gr2 = join(' ', grep(!$basegroup{$_}, sort split(' ',`/usr/ucb/groups`))); +$gr2 = join(' ', grep(!$basegroup{$_}++, sort split(' ',`/usr/ucb/groups`))); if ($gr1 eq $gr2) { print "ok 1\n"; diff --git a/t/op/index.t b/t/op/index.t index 7cc4fca5ca..0b08f0879d 100644..100755 --- a/t/op/index.t +++ b/t/op/index.t @@ -1,6 +1,6 @@ #!./perl -# $Header: index.t,v 4.0 91/03/20 01:53:05 lwall Locked $ +# $RCSfile: index.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:59 $ print "1..20\n"; diff --git a/t/op/int.t b/t/op/int.t index ff351aa0a3..eb060acd72 100644..100755 --- a/t/op/int.t +++ b/t/op/int.t @@ -1,6 +1,6 @@ #!./perl -# $Header: int.t,v 4.0 91/03/20 01:53:08 lwall Locked $ +# $RCSfile: int.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:00 $ print "1..4\n"; diff --git a/t/op/join.t b/t/op/join.t index b219af380d..eec4611e62 100644..100755 --- a/t/op/join.t +++ b/t/op/join.t @@ -1,6 +1,6 @@ #!./perl -# $Header: join.t,v 4.0 91/03/20 01:53:17 lwall Locked $ +# $RCSfile: join.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:01 $ print "1..3\n"; diff --git a/t/op/list.t b/t/op/list.t index 56fe09ca0a..a4230b681b 100644..100755 --- a/t/op/list.t +++ b/t/op/list.t @@ -1,6 +1,6 @@ #!./perl -# $Header: list.t,v 4.0 91/03/20 01:53:24 lwall Locked $ +# $RCSfile: list.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:02 $ print "1..27\n"; diff --git a/t/op/local.t b/t/op/local.t index 1f7608934f..5f007fd4f6 100644..100755 --- a/t/op/local.t +++ b/t/op/local.t @@ -1,6 +1,6 @@ #!./perl -# $Header: local.t,v 4.0 91/03/20 01:53:29 lwall Locked $ +# $RCSfile: local.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:04 $ print "1..20\n"; diff --git a/t/op/magic.t b/t/op/magic.t index f027d60d42..83420d2aab 100644..100755 --- a/t/op/magic.t +++ b/t/op/magic.t @@ -1,6 +1,6 @@ #!./perl -# $Header: magic.t,v 4.0 91/03/20 01:53:35 lwall Locked $ +# $RCSfile: magic.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:05 $ $| = 1; # command buffering @@ -17,14 +17,24 @@ if ($! == 2) {print "ok 2\n";} else {print "not ok 2\n";} # the next tests are embedded inside system simply because sh spits out # a newline onto stderr when a child process kills itself with SIGINT. -system './perl', -'-e', '$| = 1; # command buffering', +system './perl', '-e', <<'END'; -'-e', '$SIG{"INT"} = "ok3"; kill 2,$$;', -'-e', '$SIG{"INT"} = "IGNORE"; kill 2,$$; print "ok 4\n";', -'-e', '$SIG{"INT"} = "DEFAULT"; kill 2,$$; print "not ok\n";', + $| = 1; # command buffering -'-e', 'sub ok3 { print "ok 3\n" if pop(@_) eq "INT"; }'; + $SIG{"INT"} = "ok3"; kill "INT",$$; + $SIG{"INT"} = "IGNORE"; kill 2,$$; print "ok 4\n"; + $SIG{"INT"} = "DEFAULT"; kill 2,$$; print "not ok\n"; + + sub ok3 { + if (($x = pop(@_)) eq "INT") { + print "ok 3\n"; + } + else { + print "not ok 3 $a\n"; + } + } + +END @val1 = @ENV{keys(%ENV)}; # can we slice ENV? @val2 = values(%ENV); diff --git a/t/op/mkdir.t b/t/op/mkdir.t index 9186aa54e3..7db5ec91e4 100644..100755 --- a/t/op/mkdir.t +++ b/t/op/mkdir.t @@ -1,6 +1,6 @@ #!./perl -# $Header: mkdir.t,v 4.0 91/03/20 01:53:39 lwall Locked $ +# $RCSfile: mkdir.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:06 $ print "1..7\n"; diff --git a/t/op/oct.t b/t/op/oct.t index 1a9a92ec58..8ed0c9843a 100644..100755 --- a/t/op/oct.t +++ b/t/op/oct.t @@ -1,6 +1,6 @@ #!./perl -# $Header: oct.t,v 4.0 91/03/20 01:53:43 lwall Locked $ +# $RCSfile: oct.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:08 $ print "1..3\n"; diff --git a/t/op/ord.t b/t/op/ord.t index d95824f731..67b8e24686 100644..100755 --- a/t/op/ord.t +++ b/t/op/ord.t @@ -1,6 +1,6 @@ #!./perl -# $Header: ord.t,v 4.0 91/03/20 01:53:50 lwall Locked $ +# $RCSfile: ord.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:09 $ print "1..2\n"; diff --git a/t/op/pack.t b/t/op/pack.t index aa498c5846..859d48f70d 100644..100755 --- a/t/op/pack.t +++ b/t/op/pack.t @@ -1,8 +1,8 @@ #!./perl -# $Header: pack.t,v 4.0 91/03/20 01:53:57 lwall Locked $ +# $RCSfile: pack.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:11 $ -print "1..3\n"; +print "1..8\n"; $format = "c2x5CCxsdila6"; # Need the expression in here to force ary[5] to be numeric. This avoids @@ -18,3 +18,25 @@ $out2=join(':',@ary2); print ($out1 eq $out2 ? "ok 2\n" : "not ok 2\n"); print ($foo =~ /def/ ? "ok 3\n" : "not ok 3\n"); + +# How about counting bits? + +print +($x = unpack("%32B*", "\001\002\004\010\020\040\100\200\377")) == 16 + ? "ok 4\n" : "not ok 4 $x\n"; + +print +($x = unpack("%32b69", "\001\002\004\010\020\040\100\200\017")) == 12 + ? "ok 5\n" : "not ok 5 $x\n"; + +print +($x = unpack("%32B69", "\001\002\004\010\020\040\100\200\017")) == 9 + ? "ok 6\n" : "not ok 6 $x\n"; + +print +($x = unpack("%32B*", "Now is the time for all good blurfl")) == 129 + ? "ok 7\n" : "not ok 7 $x\n"; + +open(BIN, "./perl") || die "Can't open ../perl: $!\n"; +sysread BIN, $foo, 8192; +close BIN; + +$sum = unpack("%32b*", $foo); +$longway = unpack("b*", $foo); +print $sum == $longway =~ tr/1/1/ ? "ok 8\n" : "not ok 8\n"; diff --git a/t/op/pat.t b/t/op/pat.t index 8c3adc975d..a669526177 100644..100755 --- a/t/op/pat.t +++ b/t/op/pat.t @@ -1,6 +1,6 @@ #!./perl -# $RCSfile: pat.t,v $$Revision: 4.0.1.2 $$Date: 91/06/10 01:29:34 $ +# $RCSfile: pat.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:12 $ print "1..51\n"; diff --git a/t/op/push.t b/t/op/push.t index 721b63f2f7..68fab66af7 100644..100755 --- a/t/op/push.t +++ b/t/op/push.t @@ -1,6 +1,6 @@ #!./perl -# $Header: push.t,v 4.0 91/03/20 01:54:07 lwall Locked $ +# $RCSfile: push.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:13 $ @tests = split(/\n/, <<EOF); 0 3, 0 1 2, 3 4 5 6 7 @@ -28,11 +28,16 @@ if (join(':',@x) eq '1:2:3:1:2:3:4') {print "ok 2\n";} else {print "not ok 2\n"; $test = 3; foreach $line (@tests) { ($list,$get,$leave) = split(/,\t*/,$line); - @list = split(' ',$list); + ($pos, $len, @list) = split(' ',$list); @get = split(' ',$get); @leave = split(' ',$leave); @x = (0,1,2,3,4,5,6,7); - @got = splice(@x,@list); + if (defined $len) { + @got = splice(@x, $pos, $len, @list); + } + else { + @got = splice(@x, $pos); + } if (join(':',@got) eq join(':',@get) && join(':',@x) eq join(':',@leave)) { print "ok ",$test++,"\n"; diff --git a/t/op/range.t b/t/op/range.t index 9ab7892636..746da46800 100644..100755 --- a/t/op/range.t +++ b/t/op/range.t @@ -1,6 +1,6 @@ #!./perl -# $Header: range.t,v 4.0 91/03/20 01:54:11 lwall Locked $ +# $RCSfile: range.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:14 $ print "1..8\n"; diff --git a/t/op/read.t b/t/op/read.t index 019324ce33..8c571c035b 100644..100755 --- a/t/op/read.t +++ b/t/op/read.t @@ -1,6 +1,6 @@ #!./perl -# $Header: read.t,v 4.0 91/03/20 01:54:16 lwall Locked $ +# $RCSfile: read.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:17 $ print "1..4\n"; diff --git a/t/op/readdir.t b/t/op/readdir.t index 18006991cd..18006991cd 100644..100755 --- a/t/op/readdir.t +++ b/t/op/readdir.t diff --git a/t/op/ref.t b/t/op/ref.t new file mode 100755 index 0000000000..cace1e14bd --- /dev/null +++ b/t/op/ref.t @@ -0,0 +1,179 @@ +#!./perl + +print "1..37\n"; + +# Test glob operations. + +$bar = "ok 1\n"; +$foo = "ok 2\n"; +{ + local(*foo) = *bar; + print $foo; +} +print $foo; + +$baz = "ok 3\n"; +$foo = "ok 4\n"; +{ + local(*foo) = 'baz'; + print $foo; +} +print $foo; + +$foo = "ok 6\n"; +{ + local(*foo); + print $foo; + $foo = "ok 5\n"; + print $foo; +} +print $foo; + +# Test fake references. + +$baz = "ok 7\n"; +$bar = 'baz'; +$foo = 'bar'; +print $$$foo; + +# Test real references. + +$FOO = \$BAR; +$BAR = \$BAZ; +$BAZ = "ok 8\n"; +print $$$FOO; + +# Test references to real arrays. + +@ary = (9,10,11,12); +$ref[0] = \@a; +$ref[1] = \@b; +$ref[2] = \@c; +$ref[3] = \@d; +for $i (3,1,2,0) { + push(@{$ref[$i]}, "ok $ary[$i]\n"); +} +print @a; +print ${$ref[1]}[0]; +print @{$ref[2]}[0]; +print @{'d'}; + +# Test references to references. + +$refref = \\$x; +$x = "ok 13\n"; +print $$$refref; + +# Test nested anonymous lists. + +$ref = [[],2,[3,4,5,]]; +print scalar @$ref == 3 ? "ok 14\n" : "not ok 14\n"; +print $$ref[1] == 2 ? "ok 15\n" : "not ok 15\n"; +print ${$$ref[2]}[2] == 5 ? "ok 16\n" : "not ok 16\n"; +print scalar @{$$ref[0]} == 0 ? "ok 17\n" : "not ok 17\n"; + +print $ref->[1] == 2 ? "ok 18\n" : "not ok 18\n"; +print $ref->[2]->[0] == 3 ? "ok 19\n" : "not ok 18\n"; + +# Test references to hashes of references. + +$refref = \%whatever; +$refref->{"key"} = $ref; +print $refref->{"key"}->[2]->[0] == 3 ? "ok 20\n" : "not ok 20\n"; + +# Test to see if anonymous subarrays sprint into existence. + +$spring[5]->[0] = 123; +$spring[5]->[1] = 456; +push(@{$spring[5]}, 789); +print join(':',@{$spring[5]}) eq "123:456:789" ? "ok 21\n" : "not ok 21\n"; + +# Test to see if anonymous subhashes sprint into existence. + +@{$spring2{"foo"}} = (1,2,3); +$spring2{"foo"}->[3] = 4; +print join(':',@{$spring2{"foo"}}) eq "1:2:3:4" ? "ok 22\n" : "not ok 22\n"; + +# Test references to subroutines. + +sub mysub { print "ok 23\n" } +$subref = \&mysub; +&$subref; + +$subrefref = \\&mysub2; +&$$subrefref("ok 24\n"); +sub mysub2 { print shift } + +# Test the ref operator. + +print ref $subref eq CODE ? "ok 25\n" : "not ok 25\n"; +print ref $ref eq ARRAY ? "ok 26\n" : "not ok 26\n"; +print ref $refref eq HASH ? "ok 27\n" : "not ok 27\n"; + +# Test anonymous hash syntax. + +$anonhash = {}; +print ref $anonhash eq HASH ? "ok 28\n" : "not ok 28\n"; +$anonhash2 = {FOO => BAR, ABC => XYZ,}; +print join('', sort values %$anonhash2) eq BARXYZ ? "ok 29\n" : "not ok 29\n"; + +# Test bless operator. + +package MYHASH; + +$object = bless $main'anonhash2; +print ref $object eq MYHASH ? "ok 30\n" : "not ok 30\n"; +print $object->{ABC} eq XYZ ? "ok 31\n" : "not ok 31\n"; + +$object2 = bless {}; +print ref $object2 eq MYHASH ? "ok 32\n" : "not ok 32\n"; + +# Test ordinary call on object method. + +&mymethod($object,33); + +sub mymethod { + local($THIS, @ARGS) = @_; + die "Not a MYHASH" unless ref $THIS eq MYHASH; + print $THIS->{FOO} eq BAR ? "ok $ARGS[0]\n" : "not ok $ARGS[0]\n"; +} + +# Test automatic destructor call. + +$string = "not ok 34\n"; +$object = "foo"; +$string = "ok 34\n"; +$main'anonhash2 = "foo"; +$string = "not ok 34\n"; + +sub DESTROY { + print $string; + + # Test that the object has already been "cursed". + print ref shift eq HASH ? "ok 35\n" : "not ok 35\n"; +} + +# Now test inheritance of methods. + +package OBJ; + +@ISA = (BASEOBJ); + +$main'object = bless {FOO => foo, BAR => bar}; + +package main; + +# Test arrow-style method invocation. + +print $object->doit("BAR") eq bar ? "ok 36\n" : "not ok 36\n"; + +# Test indirect-object-style method invocation. + +$foo = doit $object "FOO"; +print $foo eq foo ? "ok 37\n" : "not ok 37\n"; + +sub BASEOBJ'doit { + local $ref = shift; + die "Not an OBJ" unless ref $ref eq OBJ; + $ref->{shift}; +} diff --git a/t/op/regexp.t b/t/op/regexp.t index e488a82a61..af8a66610d 100644..100755 --- a/t/op/regexp.t +++ b/t/op/regexp.t @@ -1,6 +1,6 @@ #!./perl -# $RCSfile: regexp.t,v $$Revision: 4.0.1.1 $$Date: 91/06/10 01:30:29 $ +# $RCSfile: regexp.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:20 $ open(TESTS,'op/re_tests') || open(TESTS,'t/op/re_tests') || die "Can't open re_tests"; diff --git a/t/op/repeat.t b/t/op/repeat.t index a494b99f96..54fa590836 100644..100755 --- a/t/op/repeat.t +++ b/t/op/repeat.t @@ -1,6 +1,6 @@ #!./perl -# $Header: repeat.t,v 4.0 91/03/20 01:54:26 lwall Locked $ +# $RCSfile: repeat.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:21 $ print "1..19\n"; diff --git a/t/op/s.t b/t/op/s.t index 323d374809..0f554b6ee6 100644..100755 --- a/t/op/s.t +++ b/t/op/s.t @@ -1,8 +1,8 @@ #!./perl -# $Header: s.t,v 4.0 91/03/20 01:54:30 lwall Locked $ +# $RCSfile: s.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:22 $ -print "1..51\n"; +print "1..56\n"; $x = 'foo'; $_ = "x"; @@ -21,7 +21,7 @@ print "#3\t:$_: eq :\$x foo:\n"; if ($_ eq '$x foo') {print "ok 3\n";} else {print "not ok 3\n";} $b = 'cd'; -($a = 'abcdef') =~ s'(b${b}e)'\n$1'; +($a = 'abcdef') =~ s<(b${b}e)>'\n$1'; print "#4\t:$1: eq :bcde:\n"; print "#4\t:$a: eq :a\\n\$1f:\n"; if ($1 eq 'bcde' && $a eq 'a\n$1f') {print "ok 4\n";} else {print "not ok 4\n";} @@ -177,3 +177,24 @@ $_ = "Now is the %#*! time for all good men..."; print (($x=(y/a-zA-Z //cd)) == 7 ? "ok 50\n" : "not ok 50\n"); print y/ / /s == 8 ? "ok 51\n" : "not ok 51\n"; +$_ = 'abcdefghijklmnopqrstuvwxyz0123456789'; +tr/a-z/A-Z/; + +print $_ eq 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' ? "ok 52\n" : "not ok 52\n"; + +# same as tr/A-Z/a-z/; +y[\101-\132][\141-\172]; + +print $_ eq 'abcdefghijklmnopqrstuvwxyz0123456789' ? "ok 53\n" : "not ok 53\n"; + +$_ = '+,-'; +tr/+--/a-c/; +print $_ eq 'abc' ? "ok 54\n" : "not ok 54\n"; + +$_ = '+,-'; +tr/+\--/a\/c/; +print $_ eq 'a,/' ? "ok 55\n" : "not ok 55\n"; + +$_ = '+,-'; +tr/-+,/ab\-/; +print $_ eq 'b-a' ? "ok 56\n" : "not ok 56\n"; diff --git a/t/op/sleep.t b/t/op/sleep.t index c26d397d2f..07cdb826d1 100644..100755 --- a/t/op/sleep.t +++ b/t/op/sleep.t @@ -1,6 +1,6 @@ #!./perl -# $Header: sleep.t,v 4.0 91/03/20 01:54:34 lwall Locked $ +# $RCSfile: sleep.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:23 $ print "1..1\n"; diff --git a/t/op/sort.t b/t/op/sort.t index 658a5bd1bc..bf7a31759c 100644..100755 --- a/t/op/sort.t +++ b/t/op/sort.t @@ -1,6 +1,6 @@ #!./perl -# $RCSfile: sort.t,v $$Revision: 4.0.1.2 $$Date: 91/11/11 16:43:47 $ +# $RCSfile: sort.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:24 $ print "1..10\n"; diff --git a/t/op/split.t b/t/op/split.t index 34327cbd42..d87998e098 100644..100755 --- a/t/op/split.t +++ b/t/op/split.t @@ -1,6 +1,6 @@ #!./perl -# $Header: split.t,v 4.0 91/03/20 01:54:42 lwall Locked $ +# $RCSfile: split.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:26 $ print "1..12\n"; @@ -48,7 +48,7 @@ print $_ eq '1:2:3:4:5:6:::' ? "ok 10\n" : "not ok 10 $_\n"; # Does assignment to a list imply split to one more field than that? $foo = `./perl -D1024 -e '(\$a,\$b) = split;' 2>&1`; -print $foo =~ /DEBUGGING/ || $foo =~ /num\(3\)/ ? "ok 11\n" : "not ok 11\n"; +print $foo =~ /DEBUGGING/ || $foo =~ /SV = IV\(3\)/ ? "ok 11\n" : "not ok 11\n"; # Can we say how many fields to split to when assigning to a list? ($a,$b) = split(' ','1 2 3 4 5 6', 2); diff --git a/t/op/sprintf.t b/t/op/sprintf.t index 6155612aeb..8e1ef6958f 100644..100755 --- a/t/op/sprintf.t +++ b/t/op/sprintf.t @@ -1,6 +1,6 @@ #!./perl -# $Header: sprintf.t,v 4.0 91/03/20 01:54:46 lwall Locked $ +# $RCSfile: sprintf.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:27 $ print "1..1\n"; diff --git a/t/op/stat.t b/t/op/stat.t index 78b97dc191..b361da2df9 100644..100755 --- a/t/op/stat.t +++ b/t/op/stat.t @@ -1,6 +1,6 @@ #!./perl -# $RCSfile: stat.t,v $$Revision: 4.0.1.3 $$Date: 91/11/11 16:44:49 $ +# $RCSfile: stat.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:28 $ print "1..56\n"; @@ -122,7 +122,10 @@ while (defined($_ = <*>)) { chdir $cwd || die "Can't cd back to $cwd"; # I suppose this is going to fail somewhere... -if ($uid > 0 && $uid < $cnt) {print "ok 35\n";} else {print "not ok 35\n";} +if ($uid > 0 && $uid < $cnt) + {print "ok 35\n";} +else + {print "not ok 35 ($uid $cnt)\n";} unless (open(tty,"/dev/tty")) { print STDERR "Can't open /dev/tty--run t/TEST outside of make.\n"; diff --git a/t/op/study.t b/t/op/study.t index 01e33fa613..ea3b366f0b 100644..100755 --- a/t/op/study.t +++ b/t/op/study.t @@ -1,6 +1,6 @@ #!./perl -# $Header: study.t,v 4.0 91/03/20 01:54:59 lwall Locked $ +# $RCSfile: study.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:30 $ print "1..24\n"; diff --git a/t/op/substr.t b/t/op/substr.t index 12ad531c49..25336365b9 100644..100755 --- a/t/op/substr.t +++ b/t/op/substr.t @@ -1,6 +1,6 @@ #!./perl -# $Header: substr.t,v 4.0 91/03/20 01:55:05 lwall Locked $ +# $RCSfile: substr.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:31 $ print "1..22\n"; diff --git a/t/op/time.t b/t/op/time.t index 28635219fe..347592dab4 100644..100755 --- a/t/op/time.t +++ b/t/op/time.t @@ -1,6 +1,6 @@ #!./perl -# $Header: time.t,v 4.0 91/03/20 01:55:09 lwall Locked $ +# $RCSfile: time.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:32 $ print "1..5\n"; diff --git a/t/op/undef.t b/t/op/undef.t index fc73cf85d5..8ab2ec421f 100644..100755 --- a/t/op/undef.t +++ b/t/op/undef.t @@ -1,6 +1,6 @@ #!./perl -# $Header: undef.t,v 4.0 91/03/20 01:55:16 lwall Locked $ +# $RCSfile: undef.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:34 $ print "1..21\n"; diff --git a/t/op/unshift.t b/t/op/unshift.t index fec68e183b..68d37756bd 100644..100755 --- a/t/op/unshift.t +++ b/t/op/unshift.t @@ -1,6 +1,6 @@ #!./perl -# $Header: unshift.t,v 4.0 91/03/20 01:55:21 lwall Locked $ +# $RCSfile: unshift.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:35 $ print "1..2\n"; diff --git a/t/op/vec.t b/t/op/vec.t index e8fe018ba8..97b6d60989 100644..100755 --- a/t/op/vec.t +++ b/t/op/vec.t @@ -1,6 +1,6 @@ #!./perl -# $Header: vec.t,v 4.0 91/03/20 01:55:28 lwall Locked $ +# $RCSfile: vec.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:36 $ print "1..13\n"; diff --git a/t/op/write.t b/t/op/write.t index e51a09088c..35aba42eaa 100644..100755 --- a/t/op/write.t +++ b/t/op/write.t @@ -1,6 +1,6 @@ #!./perl -# $Header: write.t,v 4.0 91/03/20 01:55:34 lwall Locked $ +# $RCSfile: write.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:38 $ print "1..3\n"; |