summaryrefslogtreecommitdiff
path: root/t/op
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>1999-09-10 20:44:22 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>1999-09-10 20:44:22 +0000
commit53e9df65959190f4cd34a02fe359bc5e6d2553f6 (patch)
tree0808e1620b6ecdcd9f64c6db1b8f70966efe542e /t/op
parenta0ed51b321531af4b47cce24205ab9656f043f0f (diff)
parent8a7fc0dc3015c8254ce4e866be71508e3379d45d (diff)
downloadperl-53e9df65959190f4cd34a02fe359bc5e6d2553f6.tar.gz
Get resolve -at mainline
p4raw-id: //depot/utfperl@4126
Diffstat (limited to 't/op')
-rw-r--r--t/op/64bit.t182
-rwxr-xr-xt/op/arith.t6
-rwxr-xr-xt/op/array.t7
-rwxr-xr-xt/op/assignwarn.t2
-rw-r--r--t/op/attrs.t176
-rwxr-xr-xt/op/auto.t6
-rwxr-xr-xt/op/avhv.t2
-rwxr-xr-xt/op/bop.t23
-rwxr-xr-xt/op/chars.t74
-rwxr-xr-xt/op/chop.t10
-rwxr-xr-xt/op/closure.t2
-rwxr-xr-xt/op/defins.t3
-rwxr-xr-xt/op/die.t2
-rwxr-xr-xt/op/die_exit.t15
-rwxr-xr-xt/op/each.t20
-rwxr-xr-xt/op/eval.t103
-rwxr-xr-xt/op/exec.t26
-rwxr-xr-xt/op/fh.t26
-rwxr-xr-xt/op/filetest.t71
-rwxr-xr-xt/op/fork.t4
-rwxr-xr-xt/op/goto.t44
-rwxr-xr-xt/op/goto_xs.t2
-rwxr-xr-xt/op/grent.t139
-rwxr-xr-xt/op/grep.t31
-rwxr-xr-xt/op/groups.t106
-rwxr-xr-xt/op/gv.t39
-rwxr-xr-xt/op/hashwarn.t2
-rwxr-xr-xt/op/join.t16
-rwxr-xr-xt/op/lex_assign.t305
-rw-r--r--t/op/lfs.t177
-rwxr-xr-xt/op/list.t12
-rwxr-xr-xt/op/local.t43
-rwxr-xr-xt/op/lop.t44
-rwxr-xr-xt/op/magic.t31
-rwxr-xr-xt/op/method.t43
-rwxr-xr-xt/op/misc.t108
-rwxr-xr-xt/op/mkdir.t12
-rwxr-xr-xt/op/nothread.t4
-rwxr-xr-xt/op/numconvert.t185
-rwxr-xr-xt/op/oct.t63
-rwxr-xr-xt/op/ord.t10
-rwxr-xr-xt/op/pack.t221
-rwxr-xr-xt/op/pat.t290
-rwxr-xr-xt/op/pwent.t137
-rwxr-xr-xt/op/quotemeta.t32
-rwxr-xr-xt/op/rand.t19
-rwxr-xr-xt/op/range.t20
-rw-r--r--t/op/re_tests278
-rwxr-xr-xt/op/readdir.t6
-rwxr-xr-xt/op/ref.t22
-rwxr-xr-xt/op/regexp.t24
-rwxr-xr-xt/op/repeat.t58
-rwxr-xr-xt/op/runlevel.t24
-rwxr-xr-xt/op/sort.t119
-rwxr-xr-xt/op/sprintf.t4
-rwxr-xr-xt/op/stat.t102
-rwxr-xr-xt/op/subst.t86
-rwxr-xr-xt/op/subst_amp.t104
-rwxr-xr-xt/op/subst_wamp.t11
-rwxr-xr-xt/op/sysio.t40
-rwxr-xr-xt/op/taint.t28
-rwxr-xr-xt/op/tie.t59
-rwxr-xr-xt/op/tiearray.t2
-rwxr-xr-xt/op/tiehandle.t20
-rwxr-xr-xt/op/time.t8
-rwxr-xr-xt/op/tr.t39
-rwxr-xr-xt/op/undef.t29
-rwxr-xr-xt/op/universal.t14
-rwxr-xr-xt/op/write.t25
69 files changed, 3743 insertions, 254 deletions
diff --git a/t/op/64bit.t b/t/op/64bit.t
new file mode 100644
index 0000000000..09419f8790
--- /dev/null
+++ b/t/op/64bit.t
@@ -0,0 +1,182 @@
+BEGIN {
+ eval { my $q = pack "q", 0 };
+ if ($@) {
+ print "1..0\n# no 64-bit types\n";
+ exit(0);
+ }
+ chdir 't' if -d 't';
+ unshift @INC, '../lib';
+}
+
+# This could use a lot of more tests.
+#
+# Nota bene: bit operations (&, |, ^, ~, <<, >>) are not 64-bit clean.
+# See the beginning of pp.c and the explanation next to IBW/UBW.
+
+# so that using > 0xfffffff constants and
+# 32+ bit vector sizes doesn't cause noise
+no warnings qw(overflow portable);
+
+print "1..34\n";
+
+my $q = 12345678901;
+my $r = 23456789012;
+my $f = 0xffffffff;
+my $x;
+my $y;
+
+$x = unpack "q", pack "q", $q;
+print "not " unless $x == $q && $x > $f;
+print "ok 1\n";
+
+
+$x = sprintf("%lld", 12345678901);
+print "not " unless $x eq $q && $x > $f;
+print "ok 2\n";
+
+
+$x = sprintf("%lld", $q);
+print "not " unless $x == $q && $x eq $q && $x > $f;
+print "ok 3\n";
+
+$x = sprintf("%Ld", $q);
+print "not " unless $x == $q && $x eq $q && $x > $f;
+print "ok 4\n";
+
+$x = sprintf("%qd", $q);
+print "not " unless $x == $q && $x eq $q && $x > $f;
+print "ok 5\n";
+
+
+$x = sprintf("%llx", $q);
+print "not " unless hex($x) == 0x2dfdc1c35 && hex($x) > $f;
+print "ok 6\n";
+
+$x = sprintf("%Lx", $q);
+print "not " unless hex($x) == 0x2dfdc1c35 && hex($x) > $f;
+print "ok 7\n";
+
+$x = sprintf("%qx", $q);
+print "not " unless hex($x) == 0x2dfdc1c35 && hex($x) > $f;
+print "ok 8\n";
+
+
+$x = sprintf("%llo", $q);
+print "not " unless oct("0$x") == 0133767016065 && oct($x) > $f;
+print "ok 9\n";
+
+$x = sprintf("%Lo", $q);
+print "not " unless oct("0$x") == 0133767016065 && oct($x) > $f;
+print "ok 10\n";
+
+$x = sprintf("%qo", $q);
+print "not " unless oct("0$x") == 0133767016065 && oct($x) > $f;
+print "ok 11\n";
+
+
+$x = sprintf("%llb", $q);
+print "not " unless oct("0b$x") == 0b1011011111110111000001110000110101 &&
+ oct("0b$x") > $f;
+print "ok 12\n";
+
+$x = sprintf("%Lb", $q);
+print "not " unless oct("0b$x") == 0b1011011111110111000001110000110101 &&
+ oct("0b$x") > $f;
+print "ok 13\n";
+
+$x = sprintf("%qb", $q);
+print "not " unless oct("0b$x") == 0b1011011111110111000001110000110101 &&
+ oct("0b$x") > $f;
+print "ok 14\n";
+
+
+$x = sprintf("%llu", $q);
+print "not " unless $x eq $q && $x > $f;
+print "ok 15\n";
+
+$x = sprintf("%Lu", $q);
+print "not " unless $x == $q && $x eq $q && $x > $f;
+print "ok 16\n";
+
+$x = sprintf("%qu", $q);
+print "not " unless $x == $q && $x eq $q && $x > $f;
+print "ok 17\n";
+
+
+$x = sprintf("%D", $q);
+print "not " unless $x == $q && $x eq $q && $x > $f;
+print "ok 18\n";
+
+$x = sprintf("%U", $q);
+print "not " unless $x == $q && $x eq $q && $x > $f;
+print "ok 19\n";
+
+$x = sprintf("%O", $q);
+print "not " unless oct($x) == $q && oct($x) > $f;
+print "ok 20\n";
+
+
+$x = $q + $r;
+print "not " unless $x == 35802467913 && $x > $f;
+print "ok 21\n";
+
+$x = $q - $r;
+print "not " unless $x == -11111110111 && -$x > $f;
+print "ok 22\n";
+
+$x = $q * 1234567;
+print "not " unless $x == 15241567763770867 && $x > $f;
+print "ok 23\n";
+
+$x /= 1234567;
+print "not " unless $x == $q && $x > $f;
+print "ok 24\n";
+
+$x = 98765432109 % 12345678901;
+print "not " unless $x == 901;
+print "ok 25\n";
+
+# The following six adapted from op/inc.
+
+$a = 9223372036854775807;
+$c = $a++;
+print "not " unless $a == 9223372036854775808;
+print "ok 26\n";
+
+$a = 9223372036854775807;
+$c = ++$a;
+print "not " unless $a == 9223372036854775808;
+print "ok 27\n";
+
+$a = 9223372036854775807;
+$c = $a + 1;
+print "not " unless $a == 9223372036854775808;
+print "ok 28\n";
+
+$a = -9223372036854775808;
+$c = $a--;
+print "not " unless $a == -9223372036854775809;
+print "ok 29\n";
+
+$a = -9223372036854775808;
+$c = --$a;
+print "not " unless $a == -9223372036854775809;
+print "ok 30\n";
+
+$a = -9223372036854775808;
+$c = $a - 1;
+print "not " unless $a == -9223372036854775809;
+print "ok 31\n";
+
+
+$x = '';
+print "not " unless (vec($x, 1, 64) = $q) == $q;
+print "ok 32\n";
+
+print "not " unless vec($x, 1, 64) == $q && vec($x, 1, 64) > $f;
+print "ok 33\n";
+
+print "not " unless vec($x, 0, 64) == 0 && vec($x, 2, 64) == 0;
+print "ok 34\n";
+
+# eof
diff --git a/t/op/arith.t b/t/op/arith.t
index 43af807b8b..f1bd827f9b 100755
--- a/t/op/arith.t
+++ b/t/op/arith.t
@@ -1,6 +1,6 @@
#!./perl
-print "1..4\n";
+print "1..8\n";
sub try ($$) {
print +($_[1] ? "ok" : "not ok"), " $_[0]\n";
@@ -10,3 +10,7 @@ try 1, 13 % 4 == 1;
try 2, -13 % 4 == 3;
try 3, 13 % -4 == -3;
try 4, -13 % -4 == -1;
+try 5, abs( 13e21 % 4e21 - 1e21) < 1e6;
+try 6, abs(-13e21 % 4e21 - 3e21) < 1e6;
+try 7, abs( 13e21 % -4e21 - -3e21) < 1e6;
+try 8, abs(-13e21 % -4e21 - -1e21) < 1e6;
diff --git a/t/op/array.t b/t/op/array.t
index 8dea44de3f..3409556396 100755
--- a/t/op/array.t
+++ b/t/op/array.t
@@ -1,6 +1,6 @@
#!./perl
-print "1..63\n";
+print "1..65\n";
#
# @foo, @bar, and @ary are also used from tie-stdarray after tie-ing them
@@ -206,3 +206,8 @@ t("@bar" eq "foo bar"); # 43
t("@bee" eq "foo bar burbl blah"); # 63
}
+# make sure reification behaves
+my $t = 63;
+sub reify { $_[1] = ++$t; print "@_\n"; }
+reify('ok');
+reify('ok');
diff --git a/t/op/assignwarn.t b/t/op/assignwarn.t
index 57e89c45e0..00f7abbf67 100755
--- a/t/op/assignwarn.t
+++ b/t/op/assignwarn.t
@@ -8,7 +8,7 @@
BEGIN {
chdir 't' if -d 't';
- @INC = '../lib';
+ unshift @INC, '../lib';
}
use strict;
diff --git a/t/op/attrs.t b/t/op/attrs.t
new file mode 100644
index 0000000000..e89c2cb816
--- /dev/null
+++ b/t/op/attrs.t
@@ -0,0 +1,176 @@
+#!./perl -w
+
+# Regression tests for attributes.pm and the C< : attrs> syntax.
+
+BEGIN {
+ chdir 't' if -d 't';
+ unshift @INC, '../lib';
+}
+
+sub NTESTS () ;
+
+my ($test, $ntests);
+BEGIN {$ntests=0}
+$test=0;
+my $failed = 0;
+
+print "1..".NTESTS."\n";
+
+$SIG{__WARN__} = sub { die @_ };
+
+sub mytest {
+ if (!$@ ne !$_[0] || $_[0] && $@ !~ $_[0]) {
+ if ($@) {
+ my $x = $@;
+ $x =~ s/\n.*\z//s;
+ print "# Got: $x\n"
+ }
+ else {
+ print "# Got unexpected success\n";
+ }
+ if ($_[0]) {
+ print "# Expected: $_[0]\n";
+ }
+ else {
+ print "# Expected success\n";
+ }
+ $failed = 1;
+ print "not ";
+ }
+ elsif (@_ == 3 && $_[1] ne $_[2]) {
+ print "# Got: $_[1]\n";
+ print "# Expected: $_[2]\n";
+ $failed = 1;
+ print "not ";
+ }
+ print "ok ",++$test,"\n";
+}
+
+eval 'sub t1 ($) : locked { $_[0]++ }';
+mytest;
+BEGIN {++$ntests}
+
+eval 'sub t2 : locked { $_[0]++ }';
+mytest;
+BEGIN {++$ntests}
+
+eval 'sub t3 ($) : locked ;';
+mytest;
+BEGIN {++$ntests}
+
+eval 'sub t4 : locked ;';
+mytest;
+BEGIN {++$ntests}
+
+my $anon1;
+eval '$anon1 = sub ($) : locked,,method { $_[0]++ }';
+mytest;
+BEGIN {++$ntests}
+
+my $anon2;
+eval '$anon2 = sub : locked , method { $_[0]++ }';
+mytest;
+BEGIN {++$ntests}
+
+my $anon3;
+eval '$anon3 = sub : method { $_[0]->[1] }';
+mytest;
+BEGIN {++$ntests}
+
+eval 'sub e1 ($) : plugh ;';
+mytest qr/^Invalid CODE attributes?: ["']?plugh["']? at/;
+BEGIN {++$ntests}
+
+eval 'sub e2 ($) : plugh(0,0) xyzzy ;';
+mytest qr/^Invalid CODE attributes: ["']?plugh\(0,0\)["']? /;
+BEGIN {++$ntests}
+
+eval 'sub e3 ($) : plugh(0,0 xyzzy ;';
+mytest qr/Unterminated attribute parameter in attribute list at/;
+BEGIN {++$ntests}
+
+eval 'sub e4 ($) : plugh + xyzzy ;';
+mytest qr/Invalid separator character '[+]' in attribute list at/;
+BEGIN {++$ntests}
+
+eval 'my main $x : = 0;';
+mytest;
+BEGIN {++$ntests}
+
+eval 'my $x : = 0;';
+mytest;
+BEGIN {++$ntests}
+
+eval 'my $x ;';
+mytest;
+BEGIN {++$ntests}
+
+eval 'my ($x) : = 0;';
+mytest;
+BEGIN {++$ntests}
+
+eval 'my ($x) ;';
+mytest;
+BEGIN {++$ntests}
+
+eval 'my ($x) : ;';
+mytest;
+BEGIN {++$ntests}
+
+eval 'my ($x,$y) : = 0;';
+mytest;
+BEGIN {++$ntests}
+
+eval 'my ($x,$y) ;';
+mytest;
+BEGIN {++$ntests}
+
+eval 'my ($x,$y) : ;';
+mytest;
+BEGIN {++$ntests}
+
+eval 'my ($x,$y) : plugh;';
+mytest qr/^Invalid SCALAR attribute: ["']?plugh["']? at/;
+BEGIN {++$ntests}
+
+sub A::MODIFY_SCALAR_ATTRIBUTES { return }
+eval 'my A $x : plugh;';
+mytest qr/^SCALAR package attribute may clash with future reserved word: ["']?plugh["']? at/;
+BEGIN {++$ntests}
+
+eval 'my A $x : plugh plover;';
+mytest qr/^SCALAR package attributes may clash with future reserved words: ["']?plugh["']? /;
+BEGIN {++$ntests}
+
+sub X::MODIFY_CODE_ATTRIBUTES { die "$_[0]" }
+sub X::foo { 1 }
+*Y::bar = \&X::foo;
+*Y::bar = \&X::foo; # second time for -w
+eval 'package Z; sub Y::bar : locked';
+mytest qr/^X at /;
+BEGIN {++$ntests}
+
+my @attrs = eval 'attributes::get \&Y::bar';
+mytest '', "@attrs", "locked";
+BEGIN {++$ntests}
+
+@attrs = eval 'attributes::get $anon1';
+mytest '', "@attrs", "locked method";
+BEGIN {++$ntests}
+
+sub Z::DESTROY { }
+sub Z::FETCH_CODE_ATTRIBUTES { return 'Z' }
+my $thunk = eval 'bless +sub : method locked { 1 }, "Z"';
+mytest '', ref($thunk), "Z";
+BEGIN {++$ntests}
+
+@attrs = eval 'attributes::get $thunk';
+mytest '', "@attrs", "locked method Z";
+BEGIN {++$ntests}
+
+
+# Other tests should be added above this line
+
+sub NTESTS () { $ntests }
+
+exit $failed;
diff --git a/t/op/auto.t b/t/op/auto.t
index 93a42f8472..2eb0097650 100755
--- a/t/op/auto.t
+++ b/t/op/auto.t
@@ -2,7 +2,7 @@
# $RCSfile: auto.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:39 $
-print "1..34\n";
+print "1..37\n";
$x = 10000;
if (0 + ++$x - 1 == 10000) { print "ok 1\n";} else {print "not ok 1\n";}
@@ -46,3 +46,7 @@ if (++($foo = '99') eq '100') {print "ok 31\n";} else {print "not ok 31\n";}
if (++($foo = 'a0') eq 'a1') {print "ok 32\n";} else {print "not ok 32\n";}
if (++($foo = 'Az') eq 'Ba') {print "ok 33\n";} else {print "not ok 33\n";}
if (++($foo = 'zz') eq 'aaa') {print "ok 34\n";} else {print "not ok 34\n";}
+if (++($foo = 'A99') eq 'B00') {print "ok 35\n";} else {print "not ok 35\n";}
+# EBCDIC guards: i and j, r and s, are not contiguous.
+if (++($foo = 'zi') eq 'zj') {print "ok 36\n";} else {print "not ok 36\n";}
+if (++($foo = 'zr') eq 'zs') {print "ok 37\n";} else {print "not ok 37\n";}
diff --git a/t/op/avhv.t b/t/op/avhv.t
index 55cc992e63..6837127d52 100755
--- a/t/op/avhv.t
+++ b/t/op/avhv.t
@@ -2,7 +2,7 @@
BEGIN {
chdir 't' if -d 't';
- @INC = '../lib';
+ unshift @INC, '../lib';
}
require Tie::Array;
diff --git a/t/op/bop.t b/t/op/bop.t
index 0c55029b93..0c5ef4874d 100755
--- a/t/op/bop.t
+++ b/t/op/bop.t
@@ -6,7 +6,7 @@
BEGIN {
chdir 't' if -d 't';
- @INC = '../lib';
+ unshift @INC, '../lib';
}
print "1..18\n";
@@ -42,14 +42,23 @@ print ((($cusp >> 1) == ($cusp / 2) &&
do { use integer; $cusp >> 1 } == -($cusp / 2))
? "ok 12\n" : "not ok 12\n");
+$Aaz = chr(ord("A") & ord("z"));
+$Aoz = chr(ord("A") | ord("z"));
+$Axz = chr(ord("A") ^ ord("z"));
+
# short strings
-print (("AAAAA" & "zzzzz") eq '@@@@@' ? "ok 13\n" : "not ok 13\n");
-print (("AAAAA" | "zzzzz") eq '{{{{{' ? "ok 14\n" : "not ok 14\n");
-print (("AAAAA" ^ "zzzzz") eq ';;;;;' ? "ok 15\n" : "not ok 15\n");
+print (("AAAAA" & "zzzzz") eq ($Aaz x 5) ? "ok 13\n" : "not ok 13\n");
+print (("AAAAA" | "zzzzz") eq ($Aoz x 5) ? "ok 14\n" : "not ok 14\n");
+print (("AAAAA" ^ "zzzzz") eq ($Axz x 5) ? "ok 15\n" : "not ok 15\n");
# long strings
$foo = "A" x 150;
$bar = "z" x 75;
-print (($foo & $bar) eq ('@'x75 ) ? "ok 16\n" : "not ok 16\n");
-print (($foo | $bar) eq ('{'x75 . 'A'x75) ? "ok 17\n" : "not ok 17\n");
-print (($foo ^ $bar) eq (';'x75 . 'A'x75) ? "ok 18\n" : "not ok 18\n");
+$zap = "A" x 75;
+# & truncates
+print (($foo & $bar) eq ($Aaz x 75 ) ? "ok 16\n" : "not ok 16\n");
+# | does not truncate
+print (($foo | $bar) eq ($Aoz x 75 . $zap) ? "ok 17\n" : "not ok 17\n");
+# ^ does not truncate
+print (($foo ^ $bar) eq ($Axz x 75 . $zap) ? "ok 18\n" : "not ok 18\n");
+
diff --git a/t/op/chars.t b/t/op/chars.t
new file mode 100755
index 0000000000..efdea027bb
--- /dev/null
+++ b/t/op/chars.t
@@ -0,0 +1,74 @@
+#!./perl
+
+print "1..33\n";
+
+# because of ebcdic.c these should be the same on asciiish
+# and ebcdic machines.
+# Peter Prymmer <pvhp@best.com>.
+
+my $c = "\c@";
+print +((ord($c) == 0) ? "" : "not "),"ok 1\n";
+$c = "\cA";
+print +((ord($c) == 1) ? "" : "not "),"ok 2\n";
+$c = "\cB";
+print +((ord($c) == 2) ? "" : "not "),"ok 3\n";
+$c = "\cC";
+print +((ord($c) == 3) ? "" : "not "),"ok 4\n";
+$c = "\cD";
+print +((ord($c) == 4) ? "" : "not "),"ok 5\n";
+$c = "\cE";
+print +((ord($c) == 5) ? "" : "not "),"ok 6\n";
+$c = "\cF";
+print +((ord($c) == 6) ? "" : "not "),"ok 7\n";
+$c = "\cG";
+print +((ord($c) == 7) ? "" : "not "),"ok 8\n";
+$c = "\cH";
+print +((ord($c) == 8) ? "" : "not "),"ok 9\n";
+$c = "\cI";
+print +((ord($c) == 9) ? "" : "not "),"ok 10\n";
+$c = "\cJ";
+print +((ord($c) == 10) ? "" : "not "),"ok 11\n";
+$c = "\cK";
+print +((ord($c) == 11) ? "" : "not "),"ok 12\n";
+$c = "\cL";
+print +((ord($c) == 12) ? "" : "not "),"ok 13\n";
+$c = "\cM";
+print +((ord($c) == 13) ? "" : "not "),"ok 14\n";
+$c = "\cN";
+print +((ord($c) == 14) ? "" : "not "),"ok 15\n";
+$c = "\cO";
+print +((ord($c) == 15) ? "" : "not "),"ok 16\n";
+$c = "\cP";
+print +((ord($c) == 16) ? "" : "not "),"ok 17\n";
+$c = "\cQ";
+print +((ord($c) == 17) ? "" : "not "),"ok 18\n";
+$c = "\cR";
+print +((ord($c) == 18) ? "" : "not "),"ok 19\n";
+$c = "\cS";
+print +((ord($c) == 19) ? "" : "not "),"ok 20\n";
+$c = "\cT";
+print +((ord($c) == 20) ? "" : "not "),"ok 21\n";
+$c = "\cU";
+print +((ord($c) == 21) ? "" : "not "),"ok 22\n";
+$c = "\cV";
+print +((ord($c) == 22) ? "" : "not "),"ok 23\n";
+$c = "\cW";
+print +((ord($c) == 23) ? "" : "not "),"ok 24\n";
+$c = "\cX";
+print +((ord($c) == 24) ? "" : "not "),"ok 25\n";
+$c = "\cY";
+print +((ord($c) == 25) ? "" : "not "),"ok 26\n";
+$c = "\cZ";
+print +((ord($c) == 26) ? "" : "not "),"ok 27\n";
+$c = "\c[";
+print +((ord($c) == 27) ? "" : "not "),"ok 28\n";
+$c = "\c\\";
+print +((ord($c) == 28) ? "" : "not "),"ok 29\n";
+$c = "\c]";
+print +((ord($c) == 29) ? "" : "not "),"ok 30\n";
+$c = "\c^";
+print +((ord($c) == 30) ? "" : "not "),"ok 31\n";
+$c = "\c_";
+print +((ord($c) == 31) ? "" : "not "),"ok 32\n";
+$c = "\c?";
+print +((ord($c) == 127) ? "" : "not "),"ok 33\n";
diff --git a/t/op/chop.t b/t/op/chop.t
index 77263ad3ad..6723ca3f1b 100755
--- a/t/op/chop.t
+++ b/t/op/chop.t
@@ -1,8 +1,6 @@
#!./perl
-# $RCSfile: chop.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:40 $
-
-print "1..28\n";
+print "1..30\n";
# optimized
@@ -85,3 +83,9 @@ $_ = "axx";
$/ = "yy";
print chomp() == 0 ? "ok 27\n" : "not ok 27\n";
print $_ eq "axx" ? "ok 28\n" : "not ok 28\n";
+
+# This case once mistakenly behaved like paragraph mode.
+$_ = "ab\n";
+$/ = \3;
+print chomp() == 0 ? "ok 29\n" : "not ok 29\n";
+print $_ eq "ab\n" ? "ok 30\n" : "not ok 30\n";
diff --git a/t/op/closure.t b/t/op/closure.t
index 95d44f51e3..2284be6df1 100755
--- a/t/op/closure.t
+++ b/t/op/closure.t
@@ -7,7 +7,7 @@
BEGIN {
chdir 't' if -d 't';
- @INC = '../lib';
+ unshift @INC, '../lib';
}
use Config;
diff --git a/t/op/defins.t b/t/op/defins.t
index 0ed61ce2fb..9e714a718b 100755
--- a/t/op/defins.t
+++ b/t/op/defins.t
@@ -6,7 +6,7 @@
BEGIN {
chdir 't' if -d 't';
- @INC = '../lib';
+ unshift @INC, '../lib';
$SIG{__WARN__} = sub { $warns++; warn $_[0] };
print "1..14\n";
}
@@ -61,6 +61,7 @@ while ($where{$seen} = <FILE>)
}
print "not " unless $seen;
print "ok 5\n";
+close FILE;
opendir(DIR,'.');
$seen = 0;
diff --git a/t/op/die.t b/t/op/die.t
index d473ed6b7f..cf4f8b0555 100755
--- a/t/op/die.t
+++ b/t/op/die.t
@@ -4,7 +4,7 @@ print "1..10\n";
$SIG{__DIE__} = sub { print ref($_[0]) ? ("ok ",$_[0]->[0]++,"\n") : @_ } ;
-$err = "ok 1\n";
+$err = "#[\000]\nok 1\n";
eval {
die $err;
};
diff --git a/t/op/die_exit.t b/t/op/die_exit.t
index b5760d6fa0..7808d9d7c5 100755
--- a/t/op/die_exit.t
+++ b/t/op/die_exit.t
@@ -7,7 +7,7 @@
BEGIN {
chdir 't' if -d 't';
- @INC = '../lib' if -e '../lib';
+ unshift @INC, '../lib' if -e '../lib';
}
my $perl = -e '../perl' ? '../perl' : -e './perl' ? './perl' : 'perl';
@@ -30,6 +30,8 @@ my %tests = (
14 => [ 255, 0],
15 => [ 255, 1],
16 => [ 255, 256],
+ # see if implicit close preserves $?
+ 17 => [ 0, 512, '{ local *F; open F, q[TEST]; close F; $!=0 } die;'],
);
my $max = keys %tests;
@@ -37,14 +39,15 @@ my $max = keys %tests;
print "1..$max\n";
foreach my $test (1 .. $max) {
- my($bang, $query) = @{$tests{$test}};
+ my($bang, $query, $code) = @{$tests{$test}};
+ $code ||= 'die;';
my $exit =
($^O eq 'MSWin32'
- ? system qq($perl -e "\$! = $bang; \$? = $query; die;" 2> nul)
- : system qq($perl -e '\$! = $bang; \$? = $query; die;' 2> /dev/null));
+ ? system qq($perl -e "\$! = $bang; \$? = $query; $code" 2> nul)
+ : system qq($perl -e '\$! = $bang; \$? = $query; $code' 2> /dev/null));
- printf "# 0x%04x 0x%04x 0x%04x\nnot ", $exit, $bang, $query
- unless $exit == (($bang || ($query >> 8) || 255) << 8);
+ printf "# 0x%04x 0x%04x 0x%04x\n", $exit, $bang, $query;
+ print "not " unless $exit == (($bang || ($query >> 8) || 255) << 8);
print "ok $test\n";
}
diff --git a/t/op/each.t b/t/op/each.t
index 420fdc09c3..879c0d0fd3 100755
--- a/t/op/each.t
+++ b/t/op/each.t
@@ -1,8 +1,6 @@
#!./perl
-# $RCSfile: each.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:47 $
-
-print "1..16\n";
+print "1..19\n";
$h{'abc'} = 'ABC';
$h{'def'} = 'DEF';
@@ -43,7 +41,8 @@ if ($#keys == 29 && $#values == 29) {print "ok 1\n";} else {print "not ok 1\n";}
$i = 0; # stop -w complaints
while (($key,$value) = each(%h)) {
- if ($key eq $keys[$i] && $value eq $values[$i] && $key eq lc($value)) {
+ if ($key eq $keys[$i] && $value eq $values[$i]
+ && (('a' lt 'A' && $key lt $value) || $key gt $value)) {
$key =~ y/a-z/A-Z/;
$i++ if $key eq $value;
}
@@ -119,3 +118,16 @@ while (($key, $value) = each(h)) {
}
}
if ($i == 5) { print "ok 16\n" } else { print "not ok\n" }
+
+{
+ package Obj;
+ sub DESTROY { print "ok 18\n"; }
+ {
+ my $h = { A => bless [], __PACKAGE__ };
+ while (my($k,$v) = each %$h) {
+ print "ok 17\n" if $k eq 'A' and ref($v) eq 'Obj';
+ }
+ }
+ print "ok 19\n";
+}
+
diff --git a/t/op/eval.t b/t/op/eval.t
index 9368281d5b..abcb3794b7 100755
--- a/t/op/eval.t
+++ b/t/op/eval.t
@@ -1,8 +1,6 @@
#!./perl
-# $RCSfile: eval.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:48 $
-
-print "1..23\n";
+print "1..37\n";
eval 'print "ok 1\n";';
@@ -79,3 +77,102 @@ eval {
};
&$x();
}
+
+my $b = 'wrong';
+my $X = sub {
+ my $b = "right";
+ print eval('"$b"') eq $b ? "ok 24\n" : "not ok 24\n";
+};
+&$X();
+
+
+# check navigation of multiple eval boundaries to find lexicals
+
+my $x = 25;
+eval <<'EOT'; die if $@;
+ print "# $x\n"; # clone into eval's pad
+ sub do_eval1 {
+ eval $_[0]; die if $@;
+ }
+EOT
+do_eval1('print "ok $x\n"');
+$x++;
+do_eval1('eval q[print "ok $x\n"]');
+$x++;
+do_eval1('sub { eval q[print "ok $x\n"] }->()');
+$x++;
+
+# calls from within eval'' should clone outer lexicals
+
+eval <<'EOT'; die if $@;
+ sub do_eval2 {
+ eval $_[0]; die if $@;
+ }
+do_eval2('print "ok $x\n"');
+$x++;
+do_eval2('eval q[print "ok $x\n"]');
+$x++;
+do_eval2('sub { eval q[print "ok $x\n"] }->()');
+$x++;
+EOT
+
+# calls outside eval'' should NOT clone lexicals from called context
+
+$main::x = 'ok';
+eval <<'EOT'; die if $@;
+ # $x unbound here
+ sub do_eval3 {
+ eval $_[0]; die if $@;
+ }
+EOT
+do_eval3('print "$x ' . $x . '\n"');
+$x++;
+do_eval3('eval q[print "$x ' . $x . '\n"]');
+$x++;
+do_eval3('sub { eval q[print "$x ' . $x . '\n"] }->()');
+$x++;
+
+# can recursive subroutine-call inside eval'' see its own lexicals?
+sub recurse {
+ my $l = shift;
+ if ($l < $x) {
+ ++$l;
+ eval 'print "# level $l\n"; recurse($l);';
+ die if $@;
+ }
+ else {
+ print "ok $l\n";
+ }
+}
+{
+ local $SIG{__WARN__} = sub { die "not ok $x\n" if $_[0] =~ /^Deep recurs/ };
+ recurse($x-5);
+}
+$x++;
+
+# do closures created within eval bind correctly?
+eval <<'EOT';
+ sub create_closure {
+ my $self = shift;
+ return sub {
+ print $self;
+ };
+ }
+EOT
+create_closure("ok $x\n")->();
+$x++;
+
+# does lexical search terminate correctly at subroutine boundary?
+$main::r = "ok $x\n";
+sub terminal { eval 'print $r' }
+{
+ my $r = "not ok $x\n";
+ eval 'terminal($r)';
+}
+$x++;
+
+# Have we cured panic which occurred with require/eval in die handler ?
+$SIG{__DIE__} = sub { eval {1}; die shift };
+eval { die "ok ".$x++,"\n" };
+print $@;
+
diff --git a/t/op/exec.t b/t/op/exec.t
index 506fc09fbd..5d014369ba 100755
--- a/t/op/exec.t
+++ b/t/op/exec.t
@@ -1,19 +1,24 @@
#!./perl
-# $RCSfile: exec.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:49 $
-
$| = 1; # flush stdout
+$ENV{LC_ALL} = 'C'; # Forge English error messages.
+$ENV{LANGUAGE} = 'C'; # Ditto in GNU.
+
if ($^O eq 'MSWin32') {
- print "# exec is unsupported on Win32\n";
# XXX the system tests could be written to use ./perl and so work on Win32
- print "1..0\n";
+ print "1..0 # Skip: shh, win32\n";
exit(0);
}
print "1..8\n";
-print "not ok 1\n" if system "echo ok \\1"; # shell interpreted
+if ($^O ne 'os2') {
+ print "not ok 1\n" if system "echo ok \\1"; # shell interpreted
+}
+else {
+ print "ok 1 # skipped: bug/feature of pdksh\n"; # shell interpreted
+}
print "not ok 2\n" if system "echo ok 2"; # split and directly called
print "not ok 3\n" if system "echo", "ok", "3"; # directly called
@@ -23,7 +28,16 @@ if (system "true") {print "not ok 4\n";} else {print "ok 4\n";}
if ((system "/bin/sh -c 'exit 1'") != 256) { print "not "; }
print "ok 5\n";
-if ((system "lskdfj") == 255 << 8) {print "ok 6\n";} else {print "not ok 6\n";}
+$rc = system "lskdfj";
+if ($rc == 255 << 8 or $rc == -1 and
+ (
+ $! == 2 or
+ $! =~ /\bno\b.*\bfile/i or
+ $! == 13 or
+ $! =~ /permission denied/i
+ )
+ )
+ {print "ok 6\n";} else {print "not ok 6\n";}
unless (exec "lskdjfalksdjfdjfkls") {print "ok 7\n";} else {print "not ok 7\n";}
diff --git a/t/op/fh.t b/t/op/fh.t
new file mode 100755
index 0000000000..86e405a992
--- /dev/null
+++ b/t/op/fh.t
@@ -0,0 +1,26 @@
+#!./perl
+
+print "1..5\n";
+
+my $test = 0;
+
+# symbolic filehandles should only result in glob entries with FH constructors
+
+$|=1;
+my $a = "SYM000";
+print "not " if defined(fileno($a)) or defined *{$a};
+++$test; print "ok $test\n";
+
+select select $a;
+print "not " unless defined *{$a};
+++$test; print "ok $test\n";
+
+$a++;
+print "not " if close $a or defined *{$a};
+++$test; print "ok $test\n";
+
+print "not " unless open($a, ">&STDOUT") and defined *{$a};
+++$test; print $a "ok $test\n";
+
+print "not " unless close $a;
+++$test; print $a "not "; print "ok $test\n";
diff --git a/t/op/filetest.t b/t/op/filetest.t
new file mode 100755
index 0000000000..e00d5fb7b0
--- /dev/null
+++ b/t/op/filetest.t
@@ -0,0 +1,71 @@
+#!./perl
+
+# There are few filetest operators that are portable enough to test.
+# See pod/perlport.pod for details.
+
+BEGIN {
+ chdir 't' if -d 't';
+ unshift @INC, '../lib' if -d '../lib';
+}
+
+use Config;
+print "1..10\n";
+
+print "not " unless -d 'op';
+print "ok 1\n";
+
+print "not " unless -f 'TEST';
+print "ok 2\n";
+
+print "not " if -f 'op';
+print "ok 3\n";
+
+print "not " if -d 'TEST';
+print "ok 4\n";
+
+print "not " unless -r 'TEST';
+print "ok 5\n";
+
+# make sure TEST is r-x
+eval { chmod 0555, 'TEST' };
+$bad_chmod = $@;
+
+$oldeuid = $>; # root can read and write anything
+eval '$> = 1'; # so switch uid (may not be implemented)
+
+print "# oldeuid = $oldeuid, euid = $>\n";
+
+if (!$Config{d_seteuid}) {
+ print "ok 6 #skipped, no seteuid\n";
+}
+elsif ($bad_chmod) {
+ print "#[$@]\nok 6 #skipped\n";
+}
+else {
+ print "not " if -w 'TEST';
+ print "ok 6\n";
+}
+
+# Scripts are not -x everywhere so cannot test that.
+
+eval '$> = $oldeuid'; # switch uid back (may not be implemented)
+
+# this would fail for the euid 1
+# (unless we have unpacked the source code as uid 1...)
+print "not " unless -r 'op';
+print "ok 7\n";
+
+# this would fail for the euid 1
+# (unless we have unpacked the source code as uid 1...)
+if ($Config{d_seteuid}) {
+ print "not " unless -w 'op';
+ print "ok 8\n";
+} else {
+ print "ok 8 #skipped, no seteuid\n";
+}
+
+print "not " unless -x 'op'; # Hohum. Are directories -x everywhere?
+print "ok 9\n";
+
+print "not " unless "@{[grep -r, qw(foo io noo op zoo)]}" eq "io op";
+print "ok 10\n";
diff --git a/t/op/fork.t b/t/op/fork.t
index 9790ff0f8c..20c87472b2 100755
--- a/t/op/fork.t
+++ b/t/op/fork.t
@@ -4,10 +4,10 @@
BEGIN {
chdir 't' if -d 't';
- @INC = '../lib';
+ unshift @INC, '../lib';
require Config; import Config;
unless ($Config{'d_fork'}) {
- print "1..0\n";
+ print "1..0 # Skip: no fork\n";
exit 0;
}
}
diff --git a/t/op/goto.t b/t/op/goto.t
index 1b34acda39..7a5de5fea5 100755
--- a/t/op/goto.t
+++ b/t/op/goto.t
@@ -1,10 +1,8 @@
#!./perl
-# $RCSfile: goto.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:56 $
-
# "This IS structured code. It's just randomly structured."
-print "1..9\n";
+print "1..16\n";
while ($?) {
$foo = 1;
@@ -56,7 +54,28 @@ sub bar {
exit;
FINALE:
-print "ok 9\n";
+print "ok 13\n";
+
+# does goto LABEL handle block contexts correctly?
+
+my $cond = 1;
+for (1) {
+ if ($cond == 1) {
+ $cond = 0;
+ goto OTHER;
+ }
+ elsif ($cond == 0) {
+ OTHER:
+ $cond = 2;
+ print "ok 14\n";
+ goto THIRD;
+ }
+ else {
+ THIRD:
+ print "ok 15\n";
+ }
+}
+print "ok 16\n";
exit;
bypass:
@@ -86,5 +105,22 @@ $wherever = NOWHERE;
eval { goto $wherever };
print $@ =~ /Can't find label NOWHERE/ ? "ok 8\n" : "not ok 8\n";
+# see if a modified @_ propagates
+{
+ package Foo;
+ sub DESTROY { my $s = shift; print "ok $s->[0]\n"; }
+ sub show { print "# @_\nnot ok $_[0][0]\n" if @_ != 5; }
+ sub start { push @_, 1, "foo", {}; goto &show; }
+ for (9..11) { start(bless([$_]), 'bar'); }
+}
+
+sub auto {
+ goto &loadit;
+}
+
+sub AUTOLOAD { print @_ }
+
+auto("ok 12\n");
+
$wherever = FINALE;
goto $wherever;
diff --git a/t/op/goto_xs.t b/t/op/goto_xs.t
index a35575eb26..8d9bca1cd6 100755
--- a/t/op/goto_xs.t
+++ b/t/op/goto_xs.t
@@ -10,7 +10,7 @@
# break correctly as well.
chdir 't' if -d 't';
-@INC = "../lib";
+unshift @INC, "../lib";
$ENV{PERL5LIB} = "../lib";
# turn warnings into fatal errors
diff --git a/t/op/grent.t b/t/op/grent.t
new file mode 100755
index 0000000000..761d8b9cf6
--- /dev/null
+++ b/t/op/grent.t
@@ -0,0 +1,139 @@
+#!./perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ unshift @INC, "../lib" if -d "../lib";
+ eval {my @n = getgrgid 0};
+ if ($@ && $@ =~ /(The \w+ function is unimplemented)/) {
+ print "1..0 # Skip: $1\n";
+ exit 0;
+ }
+ eval { require Config; import Config; };
+ my $reason;
+ if ($Config{'i_grp'} ne 'define') {
+ $reason = '$Config{i_grp} not defined';
+ }
+ elsif (not -f "/etc/group" ) { # Play safe.
+ $reason = 'no /etc/group file';
+ }
+
+ if (not defined $where) { # Try NIS.
+ foreach my $ypcat (qw(/usr/bin/ypcat /bin/ypcat /etc/ypcat)) {
+ if (-x $ypcat &&
+ open(GR, "$ypcat group 2>/dev/null |") &&
+ defined(<GR>)) {
+ $where = "NIS group";
+ undef $reason;
+ last;
+ }
+ }
+ }
+
+ if (not defined $where) { # Try NetInfo.
+ foreach my $nidump (qw(/usr/bin/nidump)) {
+ if (-x $nidump &&
+ open(GR, "$nidump group . 2>/dev/null |") &&
+ defined(<GR>)) {
+ $where = "NetInfo group";
+ undef $reason;
+ last;
+ }
+ }
+ }
+
+ if (not defined $where) { # Try local.
+ my $GR = "/etc/group";
+ if (-f $GR && open(GR, $GR) && defined(<GR>)) {
+ undef $reason;
+ $where = $GR;
+ }
+ }
+ if ($reason) {
+ print "1..0 # Skip: $reason\n";
+ exit 0;
+ }
+}
+
+# By now GR filehandle should be open and full of juicy group entries.
+
+print "1..1\n";
+
+# Go through at most this many groups.
+# (note that the first entry has been read away by now)
+my $max = 25;
+
+my $n = 0;
+my $tst = 1;
+my %perfect;
+my %seen;
+
+while (<GR>) {
+ chomp;
+ my @s = split /:/;
+ my ($name_s,$passwd_s,$gid_s,$members_s) = @s;
+ if (@s) {
+ push @{ $seen{$name_s} }, $.;
+ } else {
+ warn "# Your $where line $. is empty.\n";
+ next;
+ }
+ if ($n == $max) {
+ local $/;
+ my $junk = <GR>;
+ last;
+ }
+ # In principle we could whine if @s != 4 but do we know enough
+ # of group file formats everywhere?
+ if (@s == 4) {
+ $members_s =~ s/\s*,\s*/,/g;
+ $members_s =~ s/\s+$//;
+ $members_s =~ s/^\s+//;
+ @n = getgrgid($gid_s);
+ # 'nogroup' et al.
+ next unless @n;
+ my ($name,$passwd,$gid,$members) = @n;
+ # Protect against one-to-many and many-to-one mappings.
+ if ($name_s ne $name) {
+ @n = getgrnam($name_s);
+ ($name,$passwd,$gid,$members) = @n;
+ next if $name_s ne $name;
+ }
+ # NOTE: group names *CAN* contain whitespace.
+ $members =~ s/\s+/,/g;
+ # what about different orders of members?
+ $perfect{$name_s}++
+ if $name eq $name_s and
+# Do not compare passwords: think shadow passwords.
+# Not that group passwords are used much but better not assume anything.
+ $gid eq $gid_s and
+ $members eq $members_s;
+ }
+ $n++;
+}
+
+if (keys %perfect == 0) {
+ $max++;
+ print <<EOEX;
+#
+# The failure of op/grent test is not necessarily serious.
+# It may fail due to local group administration conventions.
+# If you are for example using both NIS and local groups,
+# test failure is possible. Any distributed group scheme
+# can cause such failures.
+#
+# What the grent test is doing is that it compares the $max first
+# entries of $where
+# with the results of getgrgid() and getgrnam() call. If it finds no
+# matches at all, it suspects something is wrong.
+#
+EOEX
+ print "not ";
+ $not = 1;
+} else {
+ $not = 0;
+}
+print "ok ", $tst++;
+print "\t# (not necessarily serious: run t/op/grent.t by itself)" if $not;
+print "\n";
+
+close(GR);
diff --git a/t/op/grep.t b/t/op/grep.t
new file mode 100755
index 0000000000..45d0e25a27
--- /dev/null
+++ b/t/op/grep.t
@@ -0,0 +1,31 @@
+#!./perl
+
+#
+# grep() and map() tests
+#
+
+print "1..3\n";
+
+$test = 1;
+
+sub ok {
+ my ($got,$expect) = @_;
+ print "# expected [$expect], got [$got]\nnot " if $got ne $expect;
+ print "ok $test\n";
+}
+
+{
+ my @lol = ([qw(a b c)], [], [qw(1 2 3)]);
+ my @mapped = map {scalar @$_} @lol;
+ ok "@mapped", "3 0 3";
+ $test++;
+
+ my @grepped = grep {scalar @$_} @lol;
+ ok "@grepped", "$lol[0] $lol[2]";
+ $test++;
+
+ @grepped = grep { $_ } @mapped;
+ ok "@grepped", "3 3";
+ $test++;
+}
+
diff --git a/t/op/groups.t b/t/op/groups.t
index 47aabe3d7b..f46af93bd3 100755
--- a/t/op/groups.t
+++ b/t/op/groups.t
@@ -1,13 +1,101 @@
#!./perl
-if (! -x ($groups = '/usr/ucb/groups') &&
- ! -x ($groups = '/usr/bin/groups') &&
- ! -x ($groups = '/bin/groups')
-) {
- print "1..0\n";
+$ENV{PATH} ="/bin:/usr/bin:/usr/xpg4/bin:/usr/ucb" .
+ exists $ENV{PATH} ? ":$ENV{PATH}" : "";
+$ENV{LC_ALL} = "C"; # so that external utilities speak English
+$ENV{LANGUAGE} = 'C'; # GNU locale extension
+
+sub quit {
+ print "1..0 # Skip: no `id` or `groups`\n";
exit 0;
}
+quit() if $^O eq 'MSWin32';
+
+# We have to find a command that prints all (effective
+# and real) group names (not ids). The known commands are:
+# groups
+# id -Gn
+# id -a
+# Beware 1: some systems do just 'id -G' even when 'id -Gn' is used.
+# Beware 2: id -Gn or id -a format might be id(name) or name(id).
+# Beware 3: the groups= might be anywhere in the id output.
+# Beware 4: groups can have spaces ('id -a' being the only defense against this)
+# Beware 5: id -a might not contain the groups= part.
+#
+# That is, we might meet the following:
+#
+# foo bar zot # accept
+# foo 22 42 bar zot # accept
+# 1 22 42 2 3 # reject
+# groups=(42),foo(1),bar(2),zot me(3) # parse
+# groups=22,42,1(foo),2(bar),3(zot me) # parse
+#
+# and the groups= might be after, before, or between uid=... and gid=...
+
+GROUPS: {
+ # prefer 'id' over 'groups' (is this ever wrong anywhere?)
+ # and 'id -a' over 'id -Gn' (the former is good about spaces in group names)
+ if (($groups = `id -a 2>/dev/null`) ne '') {
+ # $groups is of the form:
+ # uid=39957(gsar) gid=22(users) groups=33536,39181,22(users),0(root),1067(dev)
+ last GROUPS if $groups =~ /groups=/;
+ }
+ if (($groups = `id -Gn 2>/dev/null`) ne '') {
+ # $groups could be of the form:
+ # users 33536 39181 root dev
+ last GROUPS if $groups !~ /^(\d|\s)+$/;
+ }
+ if (($groups = `groups 2>/dev/null`) ne '') {
+ # may not reflect all groups in some places, so do a sanity check
+ if (-d '/afs') {
+ print <<EOM;
+# These test results *may* be bogus, as you appear to have AFS,
+# and I can't find a working 'id' in your PATH (which I have set
+# to '$ENV{PATH}').
+#
+# If these tests fail, report the particular incantation you use
+# on this platform to find *all* the groups that an arbitrary
+# luser may belong to, using the 'perlbug' program.
+EOM
+ }
+ last GROUPS;
+ }
+ # Okay, not today.
+ quit();
+}
+
+unless (eval { getgrgid(0); 1 }) {
+ print "1..0 # Skip: getgrgid() not implemented\n";
+ exit 0;
+}
+
+# Remember that group names can contain whitespace, '-', et cetera.
+# That is: do not \w, do not \S.
+if ($groups =~ /groups=(.+)( [ug]id=|$)/) {
+ my $gr = $1;
+ my @g0 = split /,/, $gr;
+ my @g1;
+ # prefer names over numbers
+ for (@g0) {
+ # 42(zot me)
+ if (/^(\d+)(?:\(([^)]+)\))?$/) {
+ push @g1, ($2 || $1);
+ }
+ # zot me(42)
+ elsif (/^([^(]*)\((\d+)\)$/) {
+ push @g1, ($1 || $2);
+ }
+ else {
+ print "# ignoring group entry [$_]\n";
+ }
+ }
+ print "# groups=$gr\n";
+ print "# g0 = @g0\n";
+ print "# g1 = @g1\n";
+ $groups = "@g1";
+}
+
print "1..2\n";
$pwgid = $( + 0;
@@ -27,9 +115,13 @@ for (split(' ', $()) {
}
}
-$gr1 = join(' ', sort @gr);
+if ($^O eq "uwin") { # Or anybody else who can have spaces in group names.
+ $gr1 = join(' ', grep(!$did{$_}++, sort split(' ', join(' ', @gr))));
+} else {
+ $gr1 = join(' ', sort @gr);
+}
-$gr2 = join(' ', grep(!$basegroup{$_}++, sort split(' ',`$groups`)));
+$gr2 = join(' ', grep(!$basegroup{$_}++, sort split(' ',$groups)));
if ($gr1 eq $gr2) {
print "ok 1\n";
diff --git a/t/op/gv.t b/t/op/gv.t
index c253e4bd9d..ee7978e046 100755
--- a/t/op/gv.t
+++ b/t/op/gv.t
@@ -4,7 +4,7 @@
# various typeglob tests
#
-print "1..23\n";
+print "1..30\n";
# type coersion on assignment
$foo = 'foo';
@@ -62,7 +62,7 @@ if (defined $baa) {
# fact that %X::Y:: is stored in %X:: isn't documented.
# (I hope.)
-{ package Foo::Bar }
+{ package Foo::Bar; $test=1; }
print exists $Foo::{'Bar::'} ? "ok 12\n" : "not ok 12\n";
print $Foo::{'Bar::'} eq '*Foo::Bar::' ? "ok 13\n" : "not ok 13\n";
@@ -95,4 +95,39 @@ print *{*x{GLOB}} eq "*main::STDOUT" ? "ok 21\n" : "not ok 21\n";
print {*x{IO}} "ok 22\n";
print {*x{FILEHANDLE}} "ok 23\n";
+# test if defined() doesn't create any new symbols
+{
+ my $test = 23;
+
+ my $a = "SYM000";
+ print "not " if defined *{$a};
+ ++$test; print "ok $test\n";
+
+ print "not " if defined @{$a} or defined *{$a};
+ ++$test; print "ok $test\n";
+
+ print "not " if defined %{$a} or defined *{$a};
+ ++$test; print "ok $test\n";
+
+ print "not " if defined ${$a} or defined *{$a};
+ ++$test; print "ok $test\n";
+
+ print "not " if defined &{$a} or defined *{$a};
+ ++$test; print "ok $test\n";
+
+ *{$a} = sub { print "ok $test\n" };
+ print "not " unless defined &{$a} and defined *{$a};
+ ++$test; &{$a};
+}
+
+# does pp_readline() handle glob-ness correctly?
+
+{
+ my $g = *foo;
+ $g = <DATA>;
+ print $g;
+}
+
+__END__
+ok 30
diff --git a/t/op/hashwarn.t b/t/op/hashwarn.t
index 6343a2a8d5..634e7e1f25 100755
--- a/t/op/hashwarn.t
+++ b/t/op/hashwarn.t
@@ -2,7 +2,7 @@
BEGIN {
chdir 't' if -d 't';
- @INC = '../lib';
+ unshift @INC, '../lib';
}
use strict;
diff --git a/t/op/join.t b/t/op/join.t
index eec4611e62..def5a9e9fa 100755
--- a/t/op/join.t
+++ b/t/op/join.t
@@ -1,8 +1,6 @@
#!./perl
-# $RCSfile: join.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:01 $
-
-print "1..3\n";
+print "1..6\n";
@x = (1, 2, 3);
if (join(':',@x) eq '1:2:3') {print "ok 1\n";} else {print "not ok 1\n";}
@@ -10,3 +8,15 @@ if (join(':',@x) eq '1:2:3') {print "ok 1\n";} else {print "not ok 1\n";}
if (join('',1,2,3) eq '123') {print "ok 2\n";} else {print "not ok 2\n";}
if (join(':',split(/ /,"1 2 3")) eq '1:2:3') {print "ok 3\n";} else {print "not ok 3\n";}
+
+my $f = 'a';
+$f = join ',', 'b', $f, 'e';
+if ($f eq 'b,a,e') {print "ok 4\n";} else {print "# '$f'\nnot ok 4\n";}
+
+$f = 'a';
+$f = join ',', $f, 'b', 'e';
+if ($f eq 'a,b,e') {print "ok 5\n";} else {print "not ok 5\n";}
+
+$f = 'a';
+$f = join $f, 'b', 'e', 'k';
+if ($f eq 'baeak') {print "ok 6\n";} else {print "# '$f'\nnot ok 6\n";}
diff --git a/t/op/lex_assign.t b/t/op/lex_assign.t
new file mode 100755
index 0000000000..b5c471a5a0
--- /dev/null
+++ b/t/op/lex_assign.t
@@ -0,0 +1,305 @@
+#!./perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ unshift @INC, '../lib';
+}
+
+umask 0;
+$xref = \ "";
+$runme = ($^O eq 'VMS' ? 'MCR ' : '') . $^X;
+@a = (1..5);
+%h = (1..6);
+$aref = \@a;
+$href = \%h;
+open OP, qq{$runme -le "print 'aaa Ok ok' for 1..100"|};
+$chopit = 'aaaaaa';
+@chopar = (113 .. 119);
+$posstr = '123456';
+$cstr = 'aBcD.eF';
+pos $posstr = 3;
+$nn = $n = 2;
+sub subb {"in s"}
+
+@INPUT = <DATA>;
+@simple_input = grep /^\s*\w+\s*\$\w+\s*[#\n]/, @INPUT;
+print "1..", (8 + @INPUT + @simple_input), "\n";
+$ord = 0;
+
+sub wrn {"@_"}
+
+# Check correct optimization of ucfirst etc
+$ord++;
+my $a = "AB";
+my $b = "\u\L$a";
+print "not " unless $b eq 'Ab';
+print "ok $ord\n";
+
+# Check correct destruction of objects:
+my $dc = 0;
+sub A::DESTROY {$dc += 1}
+$a=8;
+my $b;
+{ my $c = 6; $b = bless \$c, "A"}
+
+$ord++;
+print "not " unless $dc == 0;
+print "ok $ord\n";
+
+$b = $a+5;
+
+$ord++;
+print "not " unless $dc == 1;
+print "ok $ord\n";
+
+{ # Check calling STORE
+ my $sc = 0;
+ sub B::TIESCALAR {bless [11], 'B'}
+ sub B::FETCH { -(shift->[0]) }
+ sub B::STORE { $sc++; my $o = shift; $o->[0] = 17 + shift }
+
+ my $m;
+ tie $m, 'B';
+ $m = 100;
+
+ $ord++;
+ print "not " unless $sc == 1;
+ print "ok $ord\n";
+
+ my $t = 11;
+ $m = $t + 89;
+
+ $ord++;
+ print "not " unless $sc == 2;
+ print "ok $ord\n";
+
+ $ord++;
+ print "# $m\nnot " unless $m == -117;
+ print "ok $ord\n";
+
+ $m += $t;
+
+ $ord++;
+ print "not " unless $sc == 3;
+ print "ok $ord\n";
+
+ $ord++;
+ print "# $m\nnot " unless $m == 89;
+ print "ok $ord\n";
+
+}
+
+for (@INPUT) {
+ $ord++;
+ ($op, undef, $comment) = /^([^\#]+)(\#\s+(.*))?/;
+ $comment = $op unless defined $comment;
+ $op = "$op==$op" unless $op =~ /==/;
+ ($op, $expectop) = $op =~ /(.*)==(.*)/;
+
+ $skip = ($op =~ /^'\?\?\?'/ or $comment =~ /skip\(.*\Q$^O\E.*\)/i)
+ ? "skip" : "not";
+ $integer = ($comment =~ /^i_/) ? "use integer" : '' ;
+ (print "#skipping $comment:\nok $ord\n"), next if $skip eq 'skip';
+
+ eval <<EOE;
+ local \$SIG{__WARN__} = \\&wrn;
+ my \$a = 'fake';
+ $integer;
+ \$a = $op;
+ \$b = $expectop;
+ if (\$a ne \$b) {
+ print "# \$comment: got `\$a', expected `\$b'\n";
+ print "\$skip " if \$a ne \$b or \$skip eq 'skip';
+ }
+ print "ok \$ord\\n";
+EOE
+ if ($@) {
+ if ($@ =~ /is unimplemented/) {
+ print "# skipping $comment: unimplemented:\nok $ord\n";
+ } else {
+ warn $@;
+ print "not ok $ord\n";
+ }
+ }
+}
+
+for (@simple_input) {
+ $ord++;
+ ($op, undef, $comment) = /^([^\#]+)(\#\s+(.*))?/;
+ $comment = $op unless defined $comment;
+ ($operator, $variable) = /^\s*(\w+)\s*\$(\w+)/ or warn "misprocessed '$_'\n";
+ eval <<EOE;
+ local \$SIG{__WARN__} = \\&wrn;
+ my \$$variable = "Ac# Ca\\nxxx";
+ \$$variable = $operator \$$variable;
+ \$toself = \$$variable;
+ \$direct = $operator "Ac# Ca\\nxxx";
+ print "# \\\$$variable = $operator \\\$$variable\\nnot "
+ unless \$toself eq \$direct;
+ print "ok \$ord\\n";
+EOE
+ if ($@) {
+ if ($@ =~ /is unimplemented/) {
+ print "# skipping $comment: unimplemented:\nok $ord\n";
+ } elsif ($@ =~ /Can't (modify|take log of 0)/) {
+ print "# skipping $comment: syntax not good for selfassign:\nok $ord\n";
+ } else {
+ warn $@;
+ print "not ok $ord\n";
+ }
+ }
+}
+__END__
+ref $xref # ref
+ref $cstr # ref nonref
+`$runme -e "print qq[1\n]"` # backtick skip(MSWin32)
+`$undefed` # backtick undef skip(MSWin32)
+<*> # glob
+<OP> # readline
+'faked' # rcatline
+(@z = (1 .. 3)) # aassign
+chop $chopit # chop
+(chop (@x=@chopar)) # schop
+chomp $chopit # chomp
+(chop (@x=@chopar)) # schomp
+pos $posstr # pos
+pos $chopit # pos returns undef
+$nn++==2 # postinc
+$nn++==3 # i_postinc
+$nn--==4 # postdec
+$nn--==3 # i_postdec
+$n ** $n # pow
+$n * $n # multiply
+$n * $n # i_multiply
+$n / $n # divide
+$n / $n # i_divide
+$n % $n # modulo
+$n % $n # i_modulo
+$n x $n # repeat
+$n + $n # add
+$n + $n # i_add
+$n - $n # subtract
+$n - $n # i_subtract
+$n . $n # concat
+$n . $a=='2fake' # concat with self
+"3$a"=='3fake' # concat with self in stringify
+"$n" # stringify
+$n << $n # left_shift
+$n >> $n # right_shift
+$n <=> $n # ncmp
+$n <=> $n # i_ncmp
+$n cmp $n # scmp
+$n & $n # bit_and
+$n ^ $n # bit_xor
+$n | $n # bit_or
+-$n # negate
+-$n # i_negate
+~$n # complement
+atan2 $n,$n # atan2
+sin $n # sin
+cos $n # cos
+'???' # rand
+exp $n # exp
+log $n # log
+sqrt $n # sqrt
+int $n # int
+hex $n # hex
+oct $n # oct
+abs $n # abs
+length $posstr # length
+substr $posstr, 2, 2 # substr
+vec("abc",2,8) # vec
+index $posstr, 2 # index
+rindex $posstr, 2 # rindex
+sprintf "%i%i", $n, $n # sprintf
+ord $n # ord
+chr $n # chr
+crypt $n, $n # crypt
+ucfirst ($cstr . "a") # ucfirst padtmp
+ucfirst $cstr # ucfirst
+lcfirst $cstr # lcfirst
+uc $cstr # uc
+lc $cstr # lc
+quotemeta $cstr # quotemeta
+@$aref # rv2av
+@$undefed # rv2av undef
+each %h==1 # each
+values %h # values
+keys %h # keys
+%$href # rv2hv
+pack "C2", $n,$n # pack
+split /a/, "abad" # split
+join "a"; @a # join
+push @a,3==6 # push
+unshift @aaa # unshift
+reverse @a # reverse
+reverse $cstr # reverse - scal
+grep $_, 1,0,2,0,3 # grepwhile
+map "x$_", 1,0,2,0,3 # mapwhile
+subb() # entersub
+caller # caller
+warn "ignore this\n" # warn
+'faked' # die
+open BLAH, "<non-existent" # open
+fileno STDERR # fileno
+umask 0 # umask
+select STDOUT # sselect
+select "","","",0 # select
+getc OP # getc
+'???' # read
+'???' # sysread
+'???' # syswrite
+'???' # send
+'???' # recv
+'???' # tell
+'???' # fcntl
+'???' # ioctl
+'???' # flock
+'???' # accept
+'???' # shutdown
+'???' # ftsize
+'???' # ftmtime
+'???' # ftatime
+'???' # ftctime
+chdir 'non-existent' # chdir
+'???' # chown
+'???' # chroot
+unlink 'non-existent' # unlink
+chmod 'non-existent' # chmod
+utime 'non-existent' # utime
+rename 'non-existent', 'non-existent1' # rename
+link 'non-existent', 'non-existent1' # link
+'???' # symlink
+readlink 'non-existent', 'non-existent1' # readlink
+'???' # mkdir
+'???' # rmdir
+'???' # telldir
+'???' # fork
+'???' # wait
+'???' # waitpid
+system "$runme -e 0" # system skip(VMS)
+'???' # exec
+'???' # kill
+getppid # getppid
+getpgrp # getpgrp
+'???' # setpgrp
+getpriority $$, $$ # getpriority
+'???' # setpriority
+time # time
+localtime $^T # localtime
+gmtime $^T # gmtime
+sleep 1 # sleep
+'???' # alarm
+'???' # shmget
+'???' # shmctl
+'???' # shmread
+'???' # shmwrite
+'???' # msgget
+'???' # msgctl
+'???' # msgsnd
+'???' # msgrcv
+'???' # semget
+'???' # semctl
+'???' # semop
+'???' # getlogin
+'???' # syscall
diff --git a/t/op/lfs.t b/t/op/lfs.t
new file mode 100644
index 0000000000..ae6aac6079
--- /dev/null
+++ b/t/op/lfs.t
@@ -0,0 +1,177 @@
+# NOTE: this file tests how large files (>2GB) work with perlio (stdio/sfio).
+# sysopen(), sysseek(), syswrite(), sysread() are tested in t/lib/syslfs.t.
+# If you modify/add tests here, remember to update also t/lib/syslfs.t.
+
+BEGIN {
+ # Don't bother if there are no quads.
+ eval { my $q = pack "q", 0 };
+ if ($@) {
+ print "1..0\n# no 64-bit types\n";
+ exit(0);
+ }
+ chdir 't' if -d 't';
+ unshift @INC, '../lib';
+ # Don't bother if there are no quad offsets.
+ require Config; import Config;
+ if ($Config{lseeksize} < 8) {
+ print "1..0\n# no 64-bit file offsets\n";
+ exit(0);
+ }
+}
+
+sub bye {
+ close(BIG);
+ unlink "big";
+ exit(0);
+}
+
+sub explain {
+ print <<EOM;
+#
+# If the lfs (large file support: large meaning larger than two gigabytes)
+# tests are skipped or fail, it may mean either that your process is not
+# allowed to write large files or that the file system you are running
+# the tests on doesn't support large files, or both. You may also need
+# to reconfigure your kernel. (This is all very system-dependent.)
+#
+# Perl may still be able to support large files, once you have
+# such a process and such a (file) system.
+#
+EOM
+}
+
+# Known have-nots.
+if ($^O eq 'win32' || $^O eq 'vms') {
+ print "1..0\n# no sparse files\n";
+ bye();
+}
+
+# Then try to deduce whether we have sparse files.
+
+# Let's not depend on Fcntl or any other extension.
+
+my ($SEEK_SET, $SEEK_CUR, $SEEK_END) = (0, 1, 2);
+
+# We'll start off by creating a one megabyte file which has
+# only three "true" bytes. If we have sparseness, we should
+# consume less blocks than one megabyte (assuming nobody has
+# one megabyte blocks...)
+
+open(BIG, ">big") or do { warn "open failed: $!\n"; bye };
+binmode BIG;
+seek(BIG, 1_000_000, $SEEK_SET);
+print BIG "big";
+close(BIG);
+
+my @s;
+
+@s = stat("big");
+
+print "# @s\n";
+
+my $BLOCKSIZE = 512; # is this really correct everywhere?
+
+unless (@s == 13 &&
+ $s[7] == 1_000_003 &&
+ defined $s[12] &&
+ $BLOCKSIZE * $s[12] < 1_000_003) {
+ print "1..0\n# no sparse files?\n";
+ bye();
+}
+
+# By now we better be sure that we do have sparse files:
+# if we are not, the following will hog 5 gigabytes of disk. Ooops.
+
+open(BIG, ">big") or do { warn "open failed: $!\n"; bye };
+binmode BIG;
+seek(BIG, 5_000_000_000, $SEEK_SET);
+# Either the print or (more likely, thanks to buffering) the close will
+# fail if there are are filesize limitations (process or fs).
+my $print = print BIG "big";
+my $close = close BIG if $print;
+unless ($print && $close) {
+ $ENV{LC_ALL} = "C";
+ if ($! =~/File too large/) {
+ print "1..0\n# writing past 2GB failed\n";
+ explain();
+ }
+ bye();
+}
+
+@s = stat("big");
+
+print "# @s\n";
+
+sub fail () {
+ print "not ";
+ $fail++;
+}
+
+print "1..17\n";
+
+my $fail = 0;
+
+fail unless $s[7] == 5_000_000_003; # exercizes pp_stat
+print "ok 1\n";
+
+fail unless -s "big" == 5_000_000_003; # exercizes pp_ftsize
+print "ok 2\n";
+
+fail unless -e "big";
+print "ok 3\n";
+
+fail unless -f "big";
+print "ok 4\n";
+
+open(BIG, "big") or do { warn "open failed: $!\n"; bye };
+binmode BIG;
+
+fail unless seek(BIG, 4_500_000_000, $SEEK_SET);
+print "ok 5\n";
+
+fail unless tell(BIG) == 4_500_000_000;
+print "ok 6\n";
+
+fail unless seek(BIG, 1, $SEEK_CUR);
+print "ok 7\n";
+
+fail unless tell(BIG) == 4_500_000_001;
+print "ok 8\n";
+
+fail unless seek(BIG, -1, $SEEK_CUR);
+print "ok 9\n";
+
+fail unless tell(BIG) == 4_500_000_000;
+print "ok 10\n";
+
+fail unless seek(BIG, -3, $SEEK_END);
+print "ok 11\n";
+
+fail unless tell(BIG) == 5_000_000_000;
+print "ok 12\n";
+
+my $big;
+
+fail unless read(BIG, $big, 3) == 3;
+print "ok 13\n";
+
+fail unless $big eq "big";
+print "ok 14\n";
+
+# 705_032_704 = (I32)5_000_000_000
+fail unless seek(BIG, 705_032_704, $SEEK_SET);
+print "ok 15\n";
+
+my $zero;
+
+fail unless read(BIG, $zero, 3) == 3;
+print "ok 16\n";
+
+fail unless $zero eq "\0\0\0";
+print "ok 17\n";
+
+explain if $fail;
+
+bye(); # does the necessary cleanup
+
+# eof
diff --git a/t/op/list.t b/t/op/list.t
index a4230b681b..4d7a2d5444 100755
--- a/t/op/list.t
+++ b/t/op/list.t
@@ -1,8 +1,6 @@
#!./perl
-# $RCSfile: list.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:02 $
-
-print "1..27\n";
+print "1..28\n";
@foo = (1, 2, 3, 4);
if ($foo[0] == 1 && $foo[3] == 4) {print "ok 1\n";} else {print "not ok 1\n";}
@@ -81,3 +79,11 @@ for ($x = 0; $x < 3; $x++) {
print $a,$b,$c;
}
+# slices
+{
+ my @a = (0, undef, undef, 3);
+ my @b = @a[1,2];
+ my @c = (0, undef, undef, 3)[1, 2];
+ print "not " unless @b == @c and @c == 2;
+ print "ok 28\n";
+}
diff --git a/t/op/local.t b/t/op/local.t
index 2f674d103b..b478e01993 100755
--- a/t/op/local.t
+++ b/t/op/local.t
@@ -1,8 +1,6 @@
#!./perl
-# $RCSfile: local.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:04 $
-
-print "1..58\n";
+print "1..69\n";
# XXX known to leak scalars
$ENV{PERL_DESTRUCT_LEVEL} = 0 unless $ENV{PERL_DESTRUCT_LEVEL} > 3;
@@ -198,3 +196,42 @@ print +($ENV{_X_} eq 'a') ? "" : "not ", "ok 56\n";
print +($ENV{_Y_} eq 'b') ? "" : "not ", "ok 57\n";
print +($ENV{_Z_} eq 'c') ? "" : "not ", "ok 58\n";
+# does implicit localization in foreach skip magic?
+
+$_ = "ok 59,ok 60,";
+my $iter = 0;
+while (/(o.+?),/gc) {
+ print "$1\n";
+ foreach (1..1) { $iter++ }
+ if ($iter > 2) { print "not ok 60\n"; last; }
+}
+
+{
+ package UnderScore;
+ sub TIESCALAR { bless \my $self, shift }
+ sub FETCH { die "read \$_ forbidden" }
+ sub STORE { die "write \$_ forbidden" }
+ tie $_, __PACKAGE__;
+ my $t = 61;
+ my @tests = (
+ "Nesting" => sub { print '#'; for (1..3) { print }
+ print "\n" }, 1,
+ "Reading" => sub { print }, 0,
+ "Matching" => sub { $x = /badness/ }, 0,
+ "Concat" => sub { $_ .= "a" }, 0,
+ "Chop" => sub { chop }, 0,
+ "Filetest" => sub { -x }, 0,
+ "Assignment" => sub { $_ = "Bad" }, 0,
+ # XXX whether next one should fail is debatable
+ "Local \$_" => sub { local $_ = 'ok?'; print }, 0,
+ "for local" => sub { for("#ok?\n"){ print } }, 1,
+ );
+ while ( ($name, $code, $ok) = splice(@tests, 0, 3) ) {
+ print "# Testing $name\n";
+ eval { &$code };
+ print(($ok xor $@) ? "ok $t\n" : "not ok $t\n");
+ ++$t;
+ }
+ untie $_;
+}
+
diff --git a/t/op/lop.t b/t/op/lop.t
new file mode 100755
index 0000000000..f15201ff09
--- /dev/null
+++ b/t/op/lop.t
@@ -0,0 +1,44 @@
+#!./perl
+
+#
+# test the logical operators '&&', '||', '!', 'and', 'or', 'not'
+#
+
+BEGIN {
+ chdir 't' if -d 't';
+ unshift @INC, '../lib';
+}
+
+print "1..7\n";
+
+my $test = 0;
+for my $i (undef, 0 .. 2, "", "0 but true") {
+ my $true = 1;
+ my $false = 0;
+ for my $j (undef, 0 .. 2, "", "0 but true") {
+ $true &&= !(
+ ((!$i || !$j) != !($i && $j))
+ or (!($i || $j) != (!$i && !$j))
+ or (!!($i || $j) != !(!$i && !$j))
+ or (!(!$i || !$j) != !!($i && $j))
+ );
+ $false ||= (
+ ((!$i || !$j) == !!($i && $j))
+ and (!!($i || $j) == (!$i && !$j))
+ and ((!$i || $j) == ($i && !$j))
+ and (($i || !$j) != (!$i && $j))
+ );
+ }
+ if (not $true) {
+ print "not ";
+ } elsif ($false) {
+ print "not ";
+ }
+ print "ok ", ++$test, "\n";
+}
+
+# $test == 6
+my $i = 0;
+(($i ||= 1) &&= 3) += 4;
+print "not " unless $i == 7;
+print "ok ", ++$test, "\n";
diff --git a/t/op/magic.t b/t/op/magic.t
index 61e4522913..31765e2c50 100755
--- a/t/op/magic.t
+++ b/t/op/magic.t
@@ -4,7 +4,7 @@ BEGIN {
$^W = 1;
$| = 1;
chdir 't' if -d 't';
- @INC = '../lib';
+ unshift @INC, '../lib';
$SIG{__WARN__} = sub { die "Dying on warning: ", @_ };
}
@@ -22,6 +22,7 @@ sub ok {
$Is_MSWin32 = $^O eq 'MSWin32';
$Is_VMS = $^O eq 'VMS';
$Is_Dos = $^O eq 'dos';
+$Is_Cygwin = $^O =~ /cygwin/;
$PERL = ($Is_MSWin32 ? '.\perl' : './perl');
print "1..35\n";
@@ -111,6 +112,11 @@ ok 18, $$ > 0, $$;
if ($^O eq 'qnx') {
chomp($wd = `/usr/bin/fullpath -t`);
}
+ elsif($Is_Cygwin) {
+ # Cygwin turns the symlink into the real file
+ chomp($wd = `pwd`);
+ $wd =~ s#/t$##;
+ }
else {
$wd = '.';
}
@@ -120,8 +126,9 @@ ok 18, $$ > 0, $$;
$script = "$wd/show-shebang";
if ($Is_MSWin32) {
chomp($wd = `cd`);
- $perl = "$wd\\perl.exe";
- $script = "$wd\\show-shebang.bat";
+ $wd =~ s|\\|/|g;
+ $perl = "$wd/perl.exe";
+ $script = "$wd/show-shebang.bat";
$headmaybe = <<EOH ;
\@rem ='
\@echo off
@@ -135,7 +142,13 @@ __END__
:endofperl
EOT
}
- $s1 = $s2 = "\$^X is $perl, \$0 is $script\n";
+ if ($^O eq 'os390' or $^O eq 'posix-bc' or $^O eq 'vmesa') { # no shebang
+ $headmaybe = <<EOH ;
+ eval 'exec ./perl -S \$0 \${1+"\$\@"}'
+ if 0;
+EOH
+ }
+ $s1 = "\$^X is $perl, \$0 is $script\n";
ok 19, open(SCRIPT, ">$script"), $!;
ok 20, print(SCRIPT $headmaybe . <<EOB . <<'EOF' . $tailmaybe), $!;
#!$wd/perl
@@ -145,12 +158,14 @@ EOF
ok 21, close(SCRIPT), $!;
ok 22, chmod(0755, $script), $!;
$_ = `$script`;
- s/.exe//i if $Is_Dos;
+ s/\.exe//i if $Is_Dos or $Is_Cygwin;
s{\bminiperl\b}{perl}; # so that test doesn't fail with miniperl
s{is perl}{is $perl}; # for systems where $^X is only a basename
- ok 23, ($Is_MSWin32 ? uc($_) eq uc($s2) : $_ eq $s2), ":$_:!=:$s2:";
+ s{\\}{/}g;
+ ok 23, ($Is_MSWin32 ? uc($_) eq uc($s1) : $_ eq $s1), ":$_:!=:$s1:";
$_ = `$perl $script`;
- s/.exe//i if $Is_Dos;
+ s/\.exe//i if $Is_Dos;
+ s{\\}{/}g;
ok 24, ($Is_MSWin32 ? uc($_) eq uc($s1) : $_ eq $s1), ":$_:!=:$s1: after `$perl $script`";
ok 25, unlink($script), $!;
}
@@ -179,7 +194,7 @@ else {
}
{
- local $SIG{'__WARN__'} = sub { print "not " };
+ local $SIG{'__WARN__'} = sub { print "# @_\nnot " };
$! = undef;
print "ok 31\n";
}
diff --git a/t/op/method.t b/t/op/method.t
index f1b1888ef6..1c6f3c5d9d 100755
--- a/t/op/method.t
+++ b/t/op/method.t
@@ -4,7 +4,7 @@
# test method calls and autoloading.
#
-print "1..26\n";
+print "1..49\n";
@A::ISA = 'B';
@B::ISA = 'C';
@@ -19,6 +19,35 @@ sub test {
print "ok ", ++$cnt, "\n"
}
+# First, some basic checks of method-calling syntax:
+$obj = bless [], "Pack";
+sub Pack::method { shift; join(",", "method", @_) }
+$mname = "method";
+
+test(Pack->method("a","b","c"), "method,a,b,c");
+test(Pack->$mname("a","b","c"), "method,a,b,c");
+test(method Pack ("a","b","c"), "method,a,b,c");
+test((method Pack "a","b","c"), "method,a,b,c");
+
+test(Pack->method(), "method");
+test(Pack->$mname(), "method");
+test(method Pack (), "method");
+test(Pack->method, "method");
+test(Pack->$mname, "method");
+test(method Pack, "method");
+
+test($obj->method("a","b","c"), "method,a,b,c");
+test($obj->$mname("a","b","c"), "method,a,b,c");
+test((method $obj ("a","b","c")), "method,a,b,c");
+test((method $obj "a","b","c"), "method,a,b,c");
+
+test($obj->method(), "method");
+test($obj->$mname(), "method");
+test((method $obj ()), "method");
+test($obj->method, "method");
+test($obj->$mname, "method");
+test(method $obj, "method");
+
test( A->d, "C::d"); # Update hash table;
*B::d = \&D::d; # Import now.
@@ -126,3 +155,15 @@ test(A->eee(), "new B: In A::eee, 4"); # Which sticks
# this test added due to bug discovery
test(defined(@{"unknown_package::ISA"}) ? "defined" : "undefined", "undefined");
+
+# test that failed subroutine calls don't affect method calls
+{
+ package A1;
+ sub foo { "foo" }
+ package A2;
+ @ISA = 'A1';
+ package main;
+ test(A2->foo(), "foo");
+ test(do { eval 'A2::foo()'; $@ ? 1 : 0}, 1);
+ test(A2->foo(), "foo");
+}
diff --git a/t/op/misc.t b/t/op/misc.t
index 449d87cea1..926c7f38d0 100755
--- a/t/op/misc.t
+++ b/t/op/misc.t
@@ -4,7 +4,7 @@
# separate executable and can't simply use eval.
chdir 't' if -d 't';
-@INC = "../lib";
+unshift @INC, "../lib";
$ENV{PERL5LIB} = "../lib";
$|=1;
@@ -25,19 +25,25 @@ for (@prgs){
$switch = $1;
}
my($prog,$expected) = split(/\nEXPECT\n/, $_);
+ open TEST, ">$tmpfile" or die "Cannot open $tmpfile: $!";
+ print TEST $prog, "\n";
+ close TEST or die "Cannot close $tmpfile: $!";
+
if ($^O eq 'MSWin32') {
- open TEST, "| .\\perl -I../lib $switch >$tmpfile 2>&1";
+ $results = `.\\perl -I../lib $switch $tmpfile 2>&1`;
}
else {
- open TEST, "| sh -c './perl $switch' >$tmpfile 2>&1";
+ $results = `./perl $switch $tmpfile 2>&1`;
}
- print TEST $prog, "\n";
- close TEST;
$status = $?;
- $results = `$CAT $tmpfile`;
$results =~ s/\n+$//;
+ $results =~ s/at\s+misctmp\d+\s+line/at - line/g;
+ $results =~ s/of\s+misctmp\d+\s+aborted/of - aborted/g;
+# bison says 'parse error' instead of 'syntax error',
+# various yaccs may or may not capitalize 'syntax'.
+ $results =~ s/^(syntax|parse) error/syntax error/mig;
$expected =~ s/\n+$//;
- if ( $results ne $expected){
+ if ( $results ne $expected ) {
print STDERR "PROG: $switch\n$prog\n";
print STDERR "EXPECTED:\n$expected\n";
print STDERR "GOT:\n$results\n";
@@ -74,7 +80,7 @@ $x=0x0eabcd; print $x->ref;
EXPECT
Can't call method "ref" without a package or object reference at - line 1.
########
-chop ($str .= <STDIN>);
+chop ($str .= <DATA>);
########
close ($banana);
########
@@ -86,7 +92,7 @@ eval {sub bar {print "In bar";}}
########
system './perl -ne "print if eof" /dev/null'
########
-chop($file = <>);
+chop($file = <DATA>);
########
package N;
sub new {my ($obj,$n)=@_; bless \$n}
@@ -343,7 +349,7 @@ Sequence (?{...}) not terminated or not {}-balanced at - line 1, within pattern
########
/(?{"{"}})/ # Check it outside of eval too
EXPECT
-Unmatched right bracket at (re_eval 1) line 1, at end of line
+Unmatched right curly bracket at (re_eval 1) line 1, at end of line
syntax error at (re_eval 1) line 1, near ""{"}"
Compilation failed in regexp at - line 1.
########
@@ -417,3 +423,85 @@ EXPECT
destroyed
destroyed
########
+BEGIN {
+ $| = 1;
+ $SIG{__WARN__} = sub {
+ eval { print $_[0] };
+ die "bar\n";
+ };
+ warn "foo\n";
+}
+EXPECT
+foo
+bar
+BEGIN failed--compilation aborted at - line 8.
+########
+package X;
+@ISA='Y';
+sub new {
+ my $class = shift;
+ my $self = { };
+ bless $self, $class;
+ my $init = shift;
+ $self->foo($init);
+ print "new", $init;
+ return $self;
+}
+sub DESTROY {
+ my $self = shift;
+ print "DESTROY", $self->foo;
+}
+package Y;
+sub attribute {
+ my $self = shift;
+ my $var = shift;
+ if (@_ == 0) {
+ return $self->{$var};
+ } elsif (@_ == 1) {
+ $self->{$var} = shift;
+ }
+}
+sub AUTOLOAD {
+ $AUTOLOAD =~ /::([^:]+)$/;
+ my $method = $1;
+ splice @_, 1, 0, $method;
+ goto &attribute;
+}
+package main;
+my $x = X->new(1);
+for (2..3) {
+ my $y = X->new($_);
+ print $y->foo;
+}
+print $x->foo;
+EXPECT
+new1new22DESTROY2new33DESTROY31DESTROY1
+########
+re();
+sub re {
+ my $re = join '', eval 'qr/(?p{ $obj->method })/';
+ $re;
+}
+EXPECT
+########
+use strict;
+my $foo = "ZZZ\n";
+END { print $foo }
+EXPECT
+ZZZ
+########
+eval '
+use strict;
+my $foo = "ZZZ\n";
+END { print $foo }
+';
+EXPECT
+ZZZ
+########
+-w
+if (@ARGV) { print "" }
+else {
+ if ($x == 0) { print "" } else { print $x }
+}
+EXPECT
+Use of uninitialized value at - line 4.
diff --git a/t/op/mkdir.t b/t/op/mkdir.t
index 5ba0a0f18d..4bd1b21c80 100755
--- a/t/op/mkdir.t
+++ b/t/op/mkdir.t
@@ -4,10 +4,18 @@
print "1..7\n";
-$^O eq 'MSWin32' ? `del /s /q blurfl 2>&1` : `rm -rf blurfl`;
+if ($^O eq 'VMS') { # May as well test the library too
+ unshift @INC, '../lib';
+ require File::Path;
+ File::Path::rmtree('blurfl');
+}
+else {
+ $^O eq 'MSWin32' ? `del /s /q blurfl 2>&1` : `rm -rf blurfl`;
+}
# tests 3 and 7 rather naughtily expect English error messages
$ENV{'LC_ALL'} = 'C';
+$ENV{LANGUAGE} = 'C'; # GNU locale extension
print (mkdir('blurfl',0777) ? "ok 1\n" : "not ok 1\n");
print (mkdir('blurfl',0777) ? "not ok 2\n" : "ok 2\n");
@@ -15,4 +23,4 @@ print ($! =~ /exist|denied/ ? "ok 3\n" : "# $!\nnot ok 3\n");
print (-d 'blurfl' ? "ok 4\n" : "not ok 4\n");
print (rmdir('blurfl') ? "ok 5\n" : "not ok 5\n");
print (rmdir('blurfl') ? "not ok 6\n" : "ok 6\n");
-print ($! =~ /such|exist/ ? "ok 7\n" : "not ok 7\n");
+print ($! =~ /such|exist|not found/i ? "ok 7\n" : "not ok 7\n");
diff --git a/t/op/nothread.t b/t/op/nothread.t
index a0d444d90b..a434956cb0 100755
--- a/t/op/nothread.t
+++ b/t/op/nothread.t
@@ -6,12 +6,12 @@
BEGIN
{
chdir 't' if -d 't';
- @INC = "../lib";
+ unshift @INC, "../lib";
require Config;
import Config;
if ($Config{'usethreads'})
{
- print "1..0\n";
+ print "1..0 # Skip: this perl is threaded\n";
exit 0;
}
}
diff --git a/t/op/numconvert.t b/t/op/numconvert.t
new file mode 100755
index 0000000000..f71fd6c141
--- /dev/null
+++ b/t/op/numconvert.t
@@ -0,0 +1,185 @@
+#!./perl
+
+#
+# test the conversion operators
+#
+# Notations:
+#
+# "N p i N vs N N": Apply op-N, then op-p, then op-i, then reporter-N
+# Compare with application of op-N, then reporter-N
+# Right below are descriptions of different ops and reporters.
+
+# We do not use these subroutines any more, sub overhead makes a "switch"
+# solution better:
+
+# obviously, 0, 1 and 2, 3 are destructive. (XXXX 64-bit? 4 destructive too)
+
+# *0 = sub {--$_[0]}; # -
+# *1 = sub {++$_[0]}; # +
+
+# # Converters
+# *2 = sub { $_[0] = $max_uv & $_[0]}; # U
+# *3 = sub { use integer; $_[0] += $zero}; # I
+# *4 = sub { $_[0] += $zero}; # N
+# *5 = sub { $_[0] = "$_[0]" }; # P
+
+# # Side effects
+# *6 = sub { $max_uv & $_[0]}; # u
+# *7 = sub { use integer; $_[0] + $zero}; # i
+# *8 = sub { $_[0] + $zero}; # n
+# *9 = sub { $_[0] . "" }; # p
+
+# # Reporters
+# sub a2 { sprintf "%u", $_[0] } # U
+# sub a3 { sprintf "%d", $_[0] } # I
+# sub a4 { sprintf "%g", $_[0] } # N
+# sub a5 { "$_[0]" } # P
+
+BEGIN {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+}
+
+use strict 'vars';
+
+my $max_chain = $ENV{PERL_TEST_NUMCONVERTS} || 2;
+
+# Bulk out if unsigned type is hopelessly wrong:
+my $max_uv1 = ~0;
+my $max_uv2 = sprintf "%u", $max_uv1 ** 6; # 6 is an arbitrary number here
+my $big_iv = do {use integer; $max_uv1 * 16}; # 16 is an arbitrary number here
+
+if ($max_uv1 ne $max_uv2 or $big_iv > $max_uv1) {
+ print "1..0\n# Unsigned arithmetic is not sane\n";
+ exit 0;
+}
+
+my $st_t = 4*4; # We try 4 initializers and 4 reporters
+
+my $num = 0;
+$num += 10**$_ - 4**$_ for 1.. $max_chain;
+$num *= $st_t;
+print "1..$num\n"; # In fact 15 times more subsubtests...
+
+my $max_uv = ~0;
+my $max_iv = int($max_uv/2);
+my $zero = 0;
+
+my $l_uv = length $max_uv;
+my $l_iv = length $max_iv;
+
+# Hope: the first digits are good
+my $larger_than_uv = substr 97 x 100, 0, $l_uv;
+my $smaller_than_iv = substr 12 x 100, 0, $l_iv;
+my $yet_smaller_than_iv = substr 97 x 100, 0, ($l_iv - 1);
+
+my @list = (1, $yet_smaller_than_iv, $smaller_than_iv, $max_iv, $max_iv + 1,
+ $max_uv, $max_uv + 1);
+unshift @list, (reverse map -$_, @list), 0; # 15 elts
+@list = map "$_", @list; # Normalize
+
+# print "@list\n";
+
+
+my @opnames = split //, "-+UINPuinp";
+
+# @list = map { 2->($_), 3->($_), 4->($_), 5->($_), } @list; # Prepare input
+
+#print "@list\n";
+#print "'@ops'\n";
+
+my $test = 1;
+my $nok;
+for my $num_chain (1..$max_chain) {
+ my @ops = map [split //], grep /[4-9]/,
+ map { sprintf "%0${num_chain}d", $_ } 0 .. 10**$num_chain - 1;
+
+ #@ops = ([]) unless $num_chain;
+ #@ops = ([6, 4]);
+
+ # print "'@ops'\n";
+ for my $op (@ops) {
+ for my $first (2..5) {
+ for my $last (2..5) {
+ $nok = 0;
+ my @otherops = grep $_ <= 3, @$op;
+ my @curops = ($op,\@otherops);
+
+ for my $num (@list) {
+ my $inpt;
+ my @ans;
+
+ for my $short (0, 1) {
+ # undef $inpt; # Forget all we had - some bugs were masked
+
+ $inpt = $num; # Try to not contaminate $num...
+ $inpt = "$inpt";
+ if ($first == 2) {
+ $inpt = $max_uv & $inpt; # U 2
+ } elsif ($first == 3) {
+ use integer; $inpt += $zero; # I 3
+ } elsif ($first == 4) {
+ $inpt += $zero; # N 4
+ } else {
+ $inpt = "$inpt"; # P 5
+ }
+
+ # Saves 20% of time - not with this logic:
+ #my $tmp = $inpt;
+ #my $tmp1 = $num;
+ #next if $num_chain > 1
+ # and "$tmp" ne "$tmp1"; # Already the coercion gives problems...
+
+ for my $curop (@{$curops[$short]}) {
+ if ($curop < 5) {
+ if ($curop < 3) {
+ if ($curop == 0) {
+ --$inpt; # - 0
+ } elsif ($curop == 1) {
+ ++$inpt; # + 1
+ } else {
+ $inpt = $max_uv & $inpt; # U 2
+ }
+ } elsif ($curop == 3) {
+ use integer; $inpt += $zero;
+ } else {
+ $inpt += $zero; # N 4
+ }
+ } elsif ($curop < 8) {
+ if ($curop == 5) {
+ $inpt = "$inpt"; # P 5
+ } elsif ($curop == 6) {
+ $max_uv & $inpt; # u 6
+ } else {
+ use integer; $inpt + $zero;
+ }
+ } elsif ($curop == 8) {
+ $inpt + $zero; # n 8
+ } else {
+ $inpt . ""; # p 9
+ }
+ }
+
+ if ($last == 2) {
+ $inpt = sprintf "%u", $inpt; # U 2
+ } elsif ($last == 3) {
+ $inpt = sprintf "%d", $inpt; # I 3
+ } elsif ($last == 4) {
+ $inpt = sprintf "%g", $inpt; # N 4
+ } else {
+ $inpt = "$inpt"; # P 5
+ }
+ push @ans, $inpt;
+ }
+ $nok++,
+ print "# '$ans[0]' ne '$ans[1]',\t$num\t=> @opnames[$first,@{$curops[0]},$last] vs @opnames[$first,@{$curops[1]},$last]\n"
+ if $ans[0] ne $ans[1];
+ }
+ print "not " if $nok;
+ print "ok $test\n";
+ #print $txt if $nok;
+ $test++;
+ }
+ }
+ }
+}
diff --git a/t/op/oct.t b/t/op/oct.t
index 24b5c4309d..27ac5aa042 100755
--- a/t/op/oct.t
+++ b/t/op/oct.t
@@ -1,14 +1,53 @@
#!./perl
-# $RCSfile: oct.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:08 $
-
-print "1..8\n";
-
-print +(oct('01234') == 01234) ? "ok" : "not ok", " 1\n";
-print +(oct('0x1234') == 0x1234) ? "ok" : "not ok", " 2\n";
-print +(hex('01234') == 0x1234) ? "ok" : "not ok", " 3\n";
-print +(oct('20000000000') == 020000000000) ? "ok" : "not ok", " 4\n";
-print +(oct('x80000000') == 0x80000000) ? "ok" : "not ok", " 5\n";
-print +(hex('80000000') == 0x80000000) ? "ok" : "not ok", " 6\n";
-print +(oct('1234') == 668) ? "ok" : "not ok", " 7\n";
-print +(hex('1234') == 4660) ? "ok" : "not ok", " 8\n";
+print "1..36\n";
+
+print +(oct('0b10101') == 0b10101) ? "ok" : "not ok", " 1\n";
+print +(oct('0b10101') == 025) ? "ok" : "not ok", " 2\n";
+print +(oct('0b10101') == 21) ? "ok" : "not ok", " 3\n";
+print +(oct('0b10101') == 0x15) ? "ok" : "not ok", " 4\n";
+
+print +(oct('b10101') == 0b10101) ? "ok" : "not ok", " 5\n";
+print +(oct('b10101') == 025) ? "ok" : "not ok", " 6\n";
+print +(oct('b10101') == 21) ? "ok" : "not ok", " 7\n";
+print +(oct('b10101') == 0x15) ? "ok" : "not ok", " 8\n";
+
+print +(oct('01234') == 0b1010011100) ? "ok" : "not ok", " 9\n";
+print +(oct('01234') == 01234) ? "ok" : "not ok", " 10\n";
+print +(oct('01234') == 668) ? "ok" : "not ok", " 11\n";
+print +(oct('01234') == 0x29c) ? "ok" : "not ok", " 12\n";
+
+print +(oct('0x1234') == 0b1001000110100) ? "ok" : "not ok", " 13\n";
+print +(oct('0x1234') == 011064) ? "ok" : "not ok", " 14\n";
+print +(oct('0x1234') == 4660) ? "ok" : "not ok", " 15\n";
+print +(oct('0x1234') == 0x1234) ? "ok" : "not ok", " 16\n";
+
+print +(oct('x1234') == 0b1001000110100) ? "ok" : "not ok", " 17\n";
+print +(oct('x1234') == 011064) ? "ok" : "not ok", " 18\n";
+print +(oct('x1234') == 4660) ? "ok" : "not ok", " 19\n";
+print +(oct('x1234') == 0x1234) ? "ok" : "not ok", " 20\n";
+
+print +(hex('01234') == 0b1001000110100) ? "ok" : "not ok", " 21\n";
+print +(hex('01234') == 011064) ? "ok" : "not ok", " 22\n";
+print +(hex('01234') == 4660) ? "ok" : "not ok", " 23\n";
+print +(hex('01234') == 0x1234) ? "ok" : "not ok", " 24\n";
+
+print +(hex('0x1234') == 0b1001000110100) ? "ok" : "not ok", " 25\n";
+print +(hex('0x1234') == 011064) ? "ok" : "not ok", " 26\n";
+print +(hex('0x1234') == 4660) ? "ok" : "not ok", " 27\n";
+print +(hex('0x1234') == 0x1234) ? "ok" : "not ok", " 28\n";
+
+print +(hex('x1234') == 0b1001000110100) ? "ok" : "not ok", " 29\n";
+print +(hex('x1234') == 011064) ? "ok" : "not ok", " 30\n";
+print +(hex('x1234') == 4660) ? "ok" : "not ok", " 31\n";
+print +(hex('x1234') == 0x1234) ? "ok" : "not ok", " 32\n";
+
+print +(oct('0b11111111111111111111111111111111') == 4294967295) ?
+ "ok" : "not ok", " 33\n";
+print +(oct('037777777777') == 4294967295) ?
+ "ok" : "not ok", " 34\n";
+print +(oct('0xffffffff') == 4294967295) ?
+ "ok" : "not ok", " 35\n";
+
+print +(hex('0xffffffff') == 4294967295) ?
+ "ok" : "not ok", " 36\n";
diff --git a/t/op/ord.t b/t/op/ord.t
index 37128382d8..bc6d924554 100755
--- a/t/op/ord.t
+++ b/t/op/ord.t
@@ -1,16 +1,16 @@
#!./perl
-# $RCSfile: ord.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:09 $
-
print "1..3\n";
# compile time evaluation
-if (ord('A') == 65) {print "ok 1\n";} else {print "not ok 1\n";}
+# 65 ASCII
+# 193 EBCDIC
+if (ord('A') == 65 || ord('A') == 193) {print "ok 1\n";} else {print "not ok 1\n";}
# run time evaluation
$x = 'ABC';
-if (ord($x) == 65) {print "ok 2\n";} else {print "not ok 2\n";}
+if (ord($x) == 65 || ord($x) == 193) {print "ok 2\n";} else {print "not ok 2\n";}
-if (chr 65 == A) {print "ok 3\n";} else {print "not ok 3\n";}
+if (chr 65 == 'A' || chr 193 == 'A') {print "ok 3\n";} else {print "not ok 3\n";}
diff --git a/t/op/pack.t b/t/op/pack.t
index b8aece6b6b..082b954756 100755
--- a/t/op/pack.t
+++ b/t/op/pack.t
@@ -1,8 +1,12 @@
#!./perl
-# $RCSfile: pack.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:11 $
+BEGIN {
+ chdir 't' if -d 't';
+ unshift @INC, '../lib' if -d '../lib';
+ require Config; import Config;
+}
-print "1..56\n";
+print "1..148\n";
$format = "c2 x5 C C x s d i l a6";
# Need the expression in here to force ary[5] to be numeric. This avoids
@@ -30,7 +34,10 @@ print +($x = unpack("%32b69", "\001\002\004\010\020\040\100\200\017")) == 12
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
+my $sum = 129; # ASCII
+$sum = 103 if ($Config{ebcdic} eq 'define');
+
+print +($x = unpack("%32B*", "Now is the time for all good blurfl")) == $sum
? "ok 7\n" : "not ok 7 $x\n";
open(BIN, "./perl") || open(BIN, "./perl.exe")
@@ -154,3 +161,211 @@ foreach my $t (@templates) {
unless @t == 2 and (($t[0] == 12 and $t[1] == 34) or ($t =~ /[nv]/i));
print "ok ", $test++, "\n";
}
+
+# 57..60: uuencode/decode
+
+# Note that first uuencoding known 'text' data and then checking the
+# binary values of the uuencoded version would not be portable between
+# character sets. Uuencoding is meant for encoding binary data, not
+# text data.
+
+$in = pack 'C*', 0 .. 255;
+
+# just to be anal, we do some random tr/`/ /
+$uu = <<'EOUU';
+M` $"`P0%!@<("0H+# T.#Q`1$A,4%187&!D:&QP='A\@(2(C)"4F)R@I*BLL
+M+2XO,#$R,S0U-C<X.3H[/#T^/T!!0D-$149'2$E*2TQ-3D]045)35%565UA9
+M6EM<75Y?8&%B8V1E9F=H:6IK;&UN;W!Q<G-T=79W>'EZ>WQ]?G^`@8*#A(6&
+MAXB)BHN,C8Z/D)&2DY25EI>8F9J;G)V>GZ"AHJ.DI::GJ*FJJZRMKJ^PL;*S
+MM+6VM[BYNKN\O;Z_P,'"P\3%QL?(R<K+S,W.S]#1TM/4U=;7V-G:V]S=WM_@
+?X>+CY.7FY^CIZNOL[>[O\/'R\_3U]O?X^?K[_/W^_P `
+EOUU
+
+$_ = $uu;
+tr/ /`/;
+print "not " unless pack('u', $in) eq $_;
+print "ok ", $test++, "\n";
+
+print "not " unless unpack('u', $uu) eq $in;
+print "ok ", $test++, "\n";
+
+$in = "\x1f\x8b\x08\x08\x58\xdc\xc4\x35\x02\x03\x4a\x41\x50\x55\x00\xf3\x2a\x2d\x2e\x51\x48\xcc\xcb\x2f\xc9\x48\x2d\x52\x08\x48\x2d\xca\x51\x28\x2d\x4d\xce\x4f\x49\x2d\xe2\x02\x00\x64\x66\x60\x5c\x1a\x00\x00\x00";
+$uu = <<'EOUU';
+M'XL("%C<Q#4"`TI!4%4`\RHM+E%(S,LOR4@M4@A(+<I1*"U-SD])+>("`&1F
+&8%P:````
+EOUU
+
+print "not " unless unpack('u', $uu) eq $in;
+print "ok ", $test++, "\n";
+
+# 60 identical to 59 except that backquotes have been changed to spaces
+
+$uu = <<'EOUU';
+M'XL("%C<Q#4" TI!4%4 \RHM+E%(S,LOR4@M4@A(+<I1*"U-SD])+>(" &1F
+&8%P:
+EOUU
+
+print "not " unless unpack('u', $uu) eq $in;
+print "ok ", $test++, "\n";
+
+# 61..72: test the ascii template types (A, a, Z)
+
+print "not " unless pack('A*', "foo\0bar\0 ") eq "foo\0bar\0 ";
+print "ok ", $test++, "\n";
+
+print "not " unless pack('A11', "foo\0bar\0 ") eq "foo\0bar\0 ";
+print "ok ", $test++, "\n";
+
+print "not " unless unpack('A*', "foo\0bar \0") eq "foo\0bar";
+print "ok ", $test++, "\n";
+
+print "not " unless unpack('A8', "foo\0bar \0") eq "foo\0bar";
+print "ok ", $test++, "\n";
+
+print "not " unless pack('a*', "foo\0bar\0 ") eq "foo\0bar\0 ";
+print "ok ", $test++, "\n";
+
+print "not " unless pack('a11', "foo\0bar\0 ") eq "foo\0bar\0 \0\0";
+print "ok ", $test++, "\n";
+
+print "not " unless unpack('a*', "foo\0bar \0") eq "foo\0bar \0";
+print "ok ", $test++, "\n";
+
+print "not " unless unpack('a8', "foo\0bar \0") eq "foo\0bar ";
+print "ok ", $test++, "\n";
+
+print "not " unless pack('Z*', "foo\0bar\0 ") eq "foo\0bar\0 ";
+print "ok ", $test++, "\n";
+
+print "not " unless pack('Z11', "foo\0bar\0 ") eq "foo\0bar\0 \0\0";
+print "ok ", $test++, "\n";
+
+print "not " unless unpack('Z*', "foo\0bar \0") eq "foo";
+print "ok ", $test++, "\n";
+
+print "not " unless unpack('Z8', "foo\0bar \0") eq "foo";
+print "ok ", $test++, "\n";
+
+# 73..78: packing native shorts/ints/longs
+
+print "not " unless length(pack("s!", 0)) == $Config{shortsize};
+print "ok ", $test++, "\n";
+
+print "not " unless length(pack("i!", 0)) == $Config{intsize};
+print "ok ", $test++, "\n";
+
+print "not " unless length(pack("l!", 0)) == $Config{longsize};
+print "ok ", $test++, "\n";
+
+print "not " unless length(pack("s!", 0)) <= length(pack("i!", 0));
+print "ok ", $test++, "\n";
+
+print "not " unless length(pack("i!", 0)) <= length(pack("l!", 0));
+print "ok ", $test++, "\n";
+
+print "not " unless length(pack("i!", 0)) == length(pack("i", 0));
+print "ok ", $test++, "\n";
+
+# 79..138: pack <-> unpack bijectionism
+
+# 79.. 83 c
+foreach my $c (-128, -1, 0, 1, 127) {
+ print "not " unless unpack("c", pack("c", $c)) == $c;
+ print "ok ", $test++, "\n";
+}
+
+# 84.. 88: C
+foreach my $C (0, 1, 127, 128, 255) {
+ print "not " unless unpack("C", pack("C", $C)) == $C;
+ print "ok ", $test++, "\n";
+}
+
+# 89.. 93: s
+foreach my $s (-32768, -1, 0, 1, 32767) {
+ print "not " unless unpack("s", pack("s", $s)) == $s;
+ print "ok ", $test++, "\n";
+}
+
+# 94.. 98: S
+foreach my $S (0, 1, 32767, 32768, 65535) {
+ print "not " unless unpack("S", pack("S", $S)) == $S;
+ print "ok ", $test++, "\n";
+}
+
+# 99..103: i
+foreach my $i (-2147483648, -1, 0, 1, 2147483647) {
+ print "not " unless unpack("i", pack("i", $i)) == $i;
+ print "ok ", $test++, "\n";
+}
+
+# 104..108: I
+foreach my $I (0, 1, 2147483647, 2147483648, 4294967295) {
+ print "not " unless unpack("I", pack("I", $I)) == $I;
+ print "ok ", $test++, "\n";
+}
+
+# 109..113: l
+foreach my $l (-2147483648, -1, 0, 1, 2147483647) {
+ print "not " unless unpack("l", pack("l", $l)) == $l;
+ print "ok ", $test++, "\n";
+}
+
+# 114..118: L
+foreach my $L (0, 1, 2147483647, 2147483648, 4294967295) {
+ print "not " unless unpack("L", pack("L", $L)) == $L;
+ print "ok ", $test++, "\n";
+}
+
+# 119..123: n
+foreach my $n (0, 1, 32767, 32768, 65535) {
+ print "not " unless unpack("n", pack("n", $n)) == $n;
+ print "ok ", $test++, "\n";
+}
+
+# 124..128: v
+foreach my $v (0, 1, 32767, 32768, 65535) {
+ print "not " unless unpack("v", pack("v", $v)) == $v;
+ print "ok ", $test++, "\n";
+}
+
+# 129..133: N
+foreach my $N (0, 1, 2147483647, 2147483648, 4294967295) {
+ print "not " unless unpack("N", pack("N", $N)) == $N;
+ print "ok ", $test++, "\n";
+}
+
+# 134..138: V
+foreach my $V (0, 1, 2147483647, 2147483648, 4294967295) {
+ print "not " unless unpack("V", pack("V", $V)) == $V;
+ print "ok ", $test++, "\n";
+}
+
+# 139..142: pack nvNV byteorders
+
+print "not " unless pack("n", 0xdead) eq "\xde\xad";
+print "ok ", $test++, "\n";
+
+print "not " unless pack("v", 0xdead) eq "\xad\xde";
+print "ok ", $test++, "\n";
+
+print "not " unless pack("N", 0xdeadbeef) eq "\xde\xad\xbe\xef";
+print "ok ", $test++, "\n";
+
+print "not " unless pack("V", 0xdeadbeef) eq "\xef\xbe\xad\xde";
+print "ok ", $test++, "\n";
+
+# 143..148: #
+
+my $z;
+eval { ($x) = unpack '#a*','hello' };
+print 'not ' unless $@; print "ok $test\n"; $test++;
+eval { ($z,$x,$y) = unpack 'a3#A C#a* C#Z', "003ok \003yes\004z\000abc" };
+print $@ eq '' && $z eq 'ok' ? "ok $test\n" : "not ok $test\n"; $test++;
+print $@ eq '' && $x eq 'yes' ? "ok $test\n" : "not ok $test\n"; $test++;
+print $@ eq '' && $y eq 'z' ? "ok $test\n" : "not ok $test\n"; $test++;
+
+eval { ($x) = pack '#a*','hello' };
+print 'not ' unless $@; print "ok $test\n"; $test++;
+$z = pack 'n#a* w#A*','string','etc';
+print 'not ' unless $z eq "\000\006string\003etc"; print "ok $test\n"; $test++;
+
diff --git a/t/op/pat.t b/t/op/pat.t
index 7d4278f38a..6312c75cea 100755
--- a/t/op/pat.t
+++ b/t/op/pat.t
@@ -4,11 +4,11 @@
# the format supported by op/regexp.t. If you want to add a test
# that does fit that format, add it to op/re_tests, not here.
-print "1..141\n";
+print "1..188\n";
BEGIN {
chdir 't' if -d 't';
- @INC = "../lib" if -d "../lib";
+ unshift @INC, "../lib" if -d "../lib";
}
eval 'use Config'; # Defaults assumed if this fails
@@ -282,14 +282,7 @@ eval qq("${context}y" =~ /(?<=$context)y/);
print "not " if $@ !~ m%^\Q/(?<=\Ex+/: lookbehind longer than 255 not%;
print "ok 71\n";
-# This one will fail when POSIX character classes do get implemented
-{
- my $w;
- local $^W = 1;
- local $SIG{__WARN__} = sub{$w = shift};
- eval q('a' =~ /[[:alpha:]]/);
- print "not " if $w !~ /^\QCharacter class syntax [: :] is reserved/;
-}
+# removed test
print "ok 72\n";
# Long Monsters
@@ -363,6 +356,7 @@ sub matchit {
/xg;
}
+@ans = ();
push @ans, $res while $res = matchit;
print "# ans='@ans'\n# expect='$expect'\nnot " if "@ans" ne "1 1 1";
@@ -375,6 +369,26 @@ print "# ans='@ans'\n# expect='$expect'\nnot " if "@ans" ne $expect;
print "ok $test\n";
$test++;
+my $matched;
+$matched = qr/\((?:(?>[^()]+)|(?p{$matched}))*\)/;
+
+@ans = @ans1 = ();
+push(@ans, $res), push(@ans1, $&) while $res = m/$matched/g;
+
+print "# ans='@ans'\n# expect='$expect'\nnot " if "@ans" ne "1 1 1";
+print "ok $test\n";
+$test++;
+
+print "# ans1='@ans1'\n# expect='$expect'\nnot " if "@ans1" ne $expect;
+print "ok $test\n";
+$test++;
+
+@ans = m/$matched/g;
+
+print "# ans='@ans'\n# expect='$expect'\nnot " if "@ans" ne $expect;
+print "ok $test\n";
+$test++;
+
@ans = ('a/b' =~ m%(.*/)?(.*)%); # Stack may be bad
print "not " if "@ans" ne 'a/ b';
print "ok $test\n";
@@ -595,3 +609,259 @@ print "not " if @_;
print "ok $test\n";
$test++;
+/a(?=.$)/;
+print "not " if $#+ != 0 or $#- != 0;
+print "ok $test\n";
+$test++;
+
+print "not " if $+[0] != 2 or $-[0] != 1;
+print "ok $test\n";
+$test++;
+
+print "not "
+ if defined $+[1] or defined $-[1] or defined $+[2] or defined $-[2];
+print "ok $test\n";
+$test++;
+
+/a(a)(a)/;
+print "not " if $#+ != 2 or $#- != 2;
+print "ok $test\n";
+$test++;
+
+print "not " if $+[0] != 3 or $-[0] != 0;
+print "ok $test\n";
+$test++;
+
+print "not " if $+[1] != 2 or $-[1] != 1;
+print "ok $test\n";
+$test++;
+
+print "not " if $+[2] != 3 or $-[2] != 2;
+print "ok $test\n";
+$test++;
+
+print "not "
+ if defined $+[3] or defined $-[3] or defined $+[4] or defined $-[4];
+print "ok $test\n";
+$test++;
+
+/.(a)(b)?(a)/;
+print "not " if $#+ != 3 or $#- != 3;
+print "ok $test\n";
+$test++;
+
+print "not " if $+[0] != 3 or $-[0] != 0;
+print "ok $test\n";
+$test++;
+
+print "not " if $+[1] != 2 or $-[1] != 1;
+print "ok $test\n";
+$test++;
+
+print "not " if $+[3] != 3 or $-[3] != 2;
+print "ok $test\n";
+$test++;
+
+print "not "
+ if defined $+[2] or defined $-[2] or defined $+[4] or defined $-[4];
+print "ok $test\n";
+$test++;
+
+/.(a)/;
+print "not " if $#+ != 1 or $#- != 1;
+print "ok $test\n";
+$test++;
+
+print "not " if $+[0] != 2 or $-[0] != 0;
+print "ok $test\n";
+$test++;
+
+print "not " if $+[1] != 2 or $-[1] != 1;
+print "ok $test\n";
+$test++;
+
+print "not "
+ if defined $+[2] or defined $-[2] or defined $+[3] or defined $-[3];
+print "ok $test\n";
+$test++;
+
+/.(a)(ba*)?/;
+print "#$#-..$#+\nnot " if $#+ != 2 or $#- != 1;
+print "ok $test\n";
+$test++;
+
+$_ = 'aaa';
+pos = 1;
+@a = /\Ga/g;
+print "not " unless "@a" eq "a a";
+print "ok $test\n";
+$test++;
+
+$str = 'abcde';
+pos $str = 2;
+
+print "not " if $str =~ /^\G/;
+print "ok $test\n";
+$test++;
+
+print "not " if $str =~ /^.\G/;
+print "ok $test\n";
+$test++;
+
+print "not " unless $str =~ /^..\G/;
+print "ok $test\n";
+$test++;
+
+print "not " if $str =~ /^...\G/;
+print "ok $test\n";
+$test++;
+
+print "not " unless $str =~ /.\G./ and $& eq 'bc';
+print "ok $test\n";
+$test++;
+
+print "not " unless $str =~ /\G../ and $& eq 'cd';
+print "ok $test\n";
+$test++;
+
+undef $foo; undef $bar;
+print "#'$str','$foo','$bar'\nnot "
+ unless $str =~ /b(?{$foo = $_; $bar = pos})c/
+ and $foo eq 'abcde' and $bar eq 2;
+print "ok $test\n";
+$test++;
+
+undef $foo; undef $bar;
+pos $str = undef;
+print "#'$str','$foo','$bar'\nnot "
+ unless $str =~ /b(?{$foo = $_; $bar = pos})c/g
+ and $foo eq 'abcde' and $bar eq 2 and pos $str eq 3;
+print "ok $test\n";
+$test++;
+
+$_ = $str;
+
+undef $foo; undef $bar;
+print "#'$str','$foo','$bar'\nnot "
+ unless /b(?{$foo = $_; $bar = pos})c/
+ and $foo eq 'abcde' and $bar eq 2;
+print "ok $test\n";
+$test++;
+
+undef $foo; undef $bar;
+print "#'$str','$foo','$bar'\nnot "
+ unless /b(?{$foo = $_; $bar = pos})c/g
+ and $foo eq 'abcde' and $bar eq 2 and pos eq 3;
+print "ok $test\n";
+$test++;
+
+undef $foo; undef $bar;
+pos = undef;
+1 while /b(?{$foo = $_; $bar = pos})c/g;
+print "#'$str','$foo','$bar'\nnot "
+ unless $foo eq 'abcde' and $bar eq 2 and not defined pos;
+print "ok $test\n";
+$test++;
+
+undef $foo; undef $bar;
+$_ = 'abcde|abcde';
+print "#'$str','$foo','$bar','$_'\nnot "
+ unless s/b(?{$foo = $_; $bar = pos})c/x/g and $foo eq 'abcde|abcde'
+ and $bar eq 8 and $_ eq 'axde|axde';
+print "ok $test\n";
+$test++;
+
+@res = ();
+# List context:
+$_ = 'abcde|abcde';
+@dummy = /([ace]).(?{push @res, $1,$2})([ce])(?{push @res, $1,$2})/g;
+@res = map {defined $_ ? "'$_'" : 'undef'} @res;
+$res = "@res";
+print "#'@res' '$_'\nnot "
+ unless "@res" eq "'a' undef 'a' 'c' 'e' undef 'a' undef 'a' 'c'";
+print "ok $test\n";
+$test++;
+
+@res = ();
+@dummy = /([ace]).(?{push @res, $`,$&,$'})([ce])(?{push @res, $`,$&,$'})/g;
+@res = map {defined $_ ? "'$_'" : 'undef'} @res;
+$res = "@res";
+print "#'@res' '$_'\nnot "
+ unless "@res" eq
+ "'' 'ab' 'cde|abcde' " .
+ "'' 'abc' 'de|abcde' " .
+ "'abcd' 'e|' 'abcde' " .
+ "'abcde|' 'ab' 'cde' " .
+ "'abcde|' 'abc' 'de'" ;
+print "ok $test\n";
+$test++;
+
+#Some more \G anchor checks
+$foo='aabbccddeeffgg';
+
+pos($foo)=1;
+
+$foo=~/.\G(..)/g;
+print "not " unless($1 eq 'ab');
+print "ok $test\n";
+$test++;
+
+pos($foo) += 1;
+$foo=~/.\G(..)/g;
+print "not " unless($1 eq 'cc');
+print "ok $test\n";
+$test++;
+
+pos($foo) += 1;
+$foo=~/.\G(..)/g;
+print "not " unless($1 eq 'de');
+print "ok $test\n";
+$test++;
+
+print "not " unless $foo =~ /\Gef/g;
+print "ok $test\n";
+$test++;
+
+undef pos $foo;
+
+$foo=~/\G(..)/g;
+print "not " unless($1 eq 'aa');
+print "ok $test\n";
+$test++;
+
+$foo=~/\G(..)/g;
+print "not " unless($1 eq 'bb');
+print "ok $test\n";
+$test++;
+
+pos($foo)=5;
+$foo=~/\G(..)/g;
+print "not " unless($1 eq 'cd');
+print "ok $test\n";
+$test++;
+
+$_='123x123';
+@res = /(\d*|x)/g;
+print "not " unless('123||x|123|' eq join '|', @res);
+print "ok $test\n";
+$test++;
+
+# see if matching against temporaries (created via pp_helem()) is safe
+{ foo => "ok $test\n".$^X }->{foo} =~ /^(.*)\n/g;
+print "$1\n";
+$test++;
+
+# See if $i work inside (?{}) in the presense of saved substrings and
+# changing $_
+@a = qw(foo bar);
+@b = ();
+s/(\w)(?{push @b, $1})/,$1,/g for @a;
+
+print "# \@b='@b', expect 'f o o b a r'\nnot " unless("@b" eq "f o o b a r");
+print "ok $test\n";
+$test++;
+
+print "not " unless("@a" eq ",f,,o,,o, ,b,,a,,r,");
+print "ok $test\n";
+$test++;
+
diff --git a/t/op/pwent.t b/t/op/pwent.t
new file mode 100755
index 0000000000..ca14a99eec
--- /dev/null
+++ b/t/op/pwent.t
@@ -0,0 +1,137 @@
+#!./perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ unshift @INC, "../lib" if -d "../lib";
+ eval {my @n = getpwuid 0};
+ if ($@ && $@ =~ /(The \w+ function is unimplemented)/) {
+ print "1..0 # Skip: $1\n";
+ exit 0;
+ }
+ eval { require Config; import Config; };
+ my $reason;
+ if ($Config{'i_pwd'} ne 'define') {
+ $reason = '$Config{i_pwd} undefined';
+ }
+ elsif (not -f "/etc/passwd" ) { # Play safe.
+ $reason = 'no /etc/passwd file';
+ }
+
+ if (not defined $where) { # Try NIS.
+ foreach my $ypcat (qw(/usr/bin/ypcat /bin/ypcat /etc/ypcat)) {
+ if (-x $ypcat &&
+ open(PW, "$ypcat passwd 2>/dev/null |") &&
+ defined(<PW>)) {
+ $where = "NIS passwd";
+ undef $reason;
+ last;
+ }
+ }
+ }
+
+ if (not defined $where) { # Try NetInfo.
+ foreach my $nidump (qw(/usr/bin/nidump)) {
+ if (-x $nidump &&
+ open(PW, "$nidump passwd . 2>/dev/null |") &&
+ defined(<PW>)) {
+ $where = "NetInfo passwd";
+ undef $reason;
+ last;
+ }
+ }
+ }
+
+ if (not defined $where) { # Try local.
+ my $PW = "/etc/passwd";
+ if (-f $PW && open(PW, $PW) && defined(<PW>)) {
+ $where = $PW;
+ undef $reason;
+ }
+ }
+
+ if ($reason) { # Give up.
+ print "1..0 # Skip: $reason\n";
+ exit 0;
+ }
+}
+
+# By now PW filehandle should be open and full of juicy password entries.
+
+print "1..1\n";
+
+# Go through at most this many users.
+# (note that the first entry has been read away by now)
+my $max = 25;
+
+my $n = 0;
+my $tst = 1;
+my %perfect;
+my %seen;
+
+while (<PW>) {
+ chomp;
+ my @s = split /:/;
+ my ($name_s, $passwd_s, $uid_s, $gid_s, $gcos_s, $home_s, $shell_s) = @s;
+ next if /^\+/; # ignore NIS includes
+ if (@s) {
+ push @{ $seen{$name_s} }, $.;
+ } else {
+ warn "# Your $where line $. is empty.\n";
+ next;
+ }
+ if ($n == $max) {
+ local $/;
+ my $junk = <PW>;
+ last;
+ }
+ # In principle we could whine if @s != 7 but do we know enough
+ # of passwd file formats everywhere?
+ if (@s == 7) {
+ @n = getpwuid($uid_s);
+ # 'nobody' et al.
+ next unless @n;
+ my ($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$home,$shell) = @n;
+ # Protect against one-to-many and many-to-one mappings.
+ if ($name_s ne $name) {
+ @n = getpwnam($name_s);
+ ($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$home,$shell) = @n;
+ next if $name_s ne $name;
+ }
+ $perfect{$name_s}++
+ if $name eq $name_s and
+ $uid eq $uid_s and
+# Do not compare passwords: think shadow passwords.
+ $gid eq $gid_s and
+ $gcos eq $gcos_s and
+ $home eq $home_s and
+ $shell eq $shell_s;
+ }
+ $n++;
+}
+
+if (keys %perfect == 0) {
+ $max++;
+ print <<EOEX;
+#
+# The failure of op/pwent test is not necessarily serious.
+# It may fail due to local password administration conventions.
+# If you are for example using both NIS and local passwords,
+# test failure is possible. Any distributed password scheme
+# can cause such failures.
+#
+# What the pwent test is doing is that it compares the $max first
+# entries of $where
+# with the results of getpwuid() and getpwnam() call. If it finds no
+# matches at all, it suspects something is wrong.
+#
+EOEX
+ print "not ";
+ $not = 1;
+} else {
+ $not = 0;
+}
+print "ok ", $tst++;
+print "\t# (not necessarily serious: run t/op/pwent.t by itself)" if $not;
+print "\n";
+
+close(PW);
diff --git a/t/op/quotemeta.t b/t/op/quotemeta.t
index 20dd312b31..60e5b7be05 100755
--- a/t/op/quotemeta.t
+++ b/t/op/quotemeta.t
@@ -1,14 +1,32 @@
#!./perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ unshift @INC, '../lib' if -d '../lib';
+ require Config; import Config;
+}
+
print "1..15\n";
-$_=join "", map chr($_), 32..127;
+if ($Config{ebcdic} eq 'define') {
+ $_=join "", map chr($_), 129..233;
+
+ # 105 characters - 52 letters = 53 backslashes
+ # 105 characters + 53 backslashes = 158 characters
+ $_=quotemeta $_;
+ if ( length == 158 ){print "ok 1\n"} else {print "not ok 1\n"}
+ # 104 non-backslash characters
+ if (tr/\\//cd == 104){print "ok 2\n"} else {print "not ok 2\n"}
+} else { # some ASCII descendant, then.
+ $_=join "", map chr($_), 32..127;
-# 96 characters - 52 letters - 10 digits - 1 underscore = 33 backslashes
-# 96 characters + 33 backslashes = 129 characters
-$_=quotemeta $_;
-if ( length == 129 ){print "ok 1\n"} else {print "not ok 1\n"}
-# 95 non-backslash characters
-if (tr/\\//cd == 95){print "ok 2\n"} else {print "not ok 2\n"}
+ # 96 characters - 52 letters - 10 digits - 1 underscore = 33 backslashes
+ # 96 characters + 33 backslashes = 129 characters
+ $_=quotemeta $_;
+ if ( length == 129 ){print "ok 1\n"} else {print "not ok 1\n"}
+ # 95 non-backslash characters
+ if (tr/\\//cd == 95){print "ok 2\n"} else {print "not ok 2\n"}
+}
if (length quotemeta "" == 0){print "ok 3\n"} else {print "not ok 3\n"}
diff --git a/t/op/rand.t b/t/op/rand.t
index c779f9dad9..97019bb099 100755
--- a/t/op/rand.t
+++ b/t/op/rand.t
@@ -17,7 +17,7 @@
BEGIN {
chdir "t" if -d "t";
- @INC = "../lib" if -d "../lib";
+ unshift @INC, "../lib" if -d "../lib";
}
use strict;
@@ -52,6 +52,17 @@ sub bits ($) {
$max = $min = rand(1);
for (1..$reps) {
my $n = rand(1);
+ if ($n < 0.0 or $n >= 1.0) {
+ print <<EOM;
+# WHOA THERE! \$Config{drand01} is set to '$Config{drand01}',
+# but that apparently produces values < 0.0 or >= 1.0.
+# Make sure \$Config{drand01} is a valid expression in the
+# C-language, and produces values in the range [0.0,1.0).
+#
+# I give up.
+EOM
+ exit;
+ }
$sum += $n;
$bits += bits($n * 256); # Don't be greedy; 8 is enough
# It's too many if randbits is less than 8!
@@ -74,8 +85,8 @@ sub bits ($) {
# reason that the diagnostic message might get the
# wrong value is that Config.pm is incorrect.)
#
- if ($max <= 0 or $max >= (1 << $randbits)) { # Just in case...
- print "not ok 1\n";
+ if ($max <= 0 or $max >= (2 ** $randbits)) {# Just in case...
+ print "# max=[$max] min=[$min]\nnot ok 1\n";
print "# This perl was compiled with randbits=$randbits\n";
print "# which is _way_ off. Or maybe your system rand is broken,\n";
print "# or your C compiler can't multiply, or maybe Martians\n";
@@ -91,7 +102,7 @@ sub bits ($) {
$off = int($off) + ($off > 0); # Next more positive int
if ($off) {
$shouldbe = $Config{randbits} + $off;
- print "not ok 1\n";
+ print "# max=[$max] min=[$min]\nnot ok 1\n";
print "# This perl was compiled with randbits=$randbits on $^O.\n";
print "# Consider using randbits=$shouldbe instead.\n";
# And skip the remaining tests; they would be pointless now.
diff --git a/t/op/range.t b/t/op/range.t
index 7999b869cb..1698db4a55 100755
--- a/t/op/range.t
+++ b/t/op/range.t
@@ -1,6 +1,6 @@
#!./perl
-print "1..10\n";
+print "1..13\n";
print join(':',1..5) eq '1:2:3:4:5' ? "ok 1\n" : "not ok 1\n";
@@ -46,3 +46,21 @@ foreach ('09'..'08') {
print "not " unless join(",", @y) eq join(",", @x);
print "ok 10\n";
+# check bounds
+@a = 0x7ffffffe..0x7fffffff;
+print "not " unless "@a" eq "2147483646 2147483647";
+print "ok 11\n";
+
+@a = -0x7fffffff..-0x7ffffffe;
+print "not " unless "@a" eq "-2147483647 -2147483646";
+print "ok 12\n";
+
+# check magic
+{
+ my $bad = 0;
+ local $SIG{'__WARN__'} = sub { $bad = 1 };
+ my $x = 'a-e';
+ $x =~ s/(\w)-(\w)/join ':', $1 .. $2/e;
+ $bad = 1 unless $x eq 'a:b:c:d:e';
+ print $bad ? "not ok 13\n" : "ok 13\n";
+}
diff --git a/t/op/re_tests b/t/op/re_tests
index 7ac20c3852..b35e964dc1 100644
--- a/t/op/re_tests
+++ b/t/op/re_tests
@@ -151,8 +151,8 @@ a[bcd]+dcdcde adcdcde n - -
(bc+d$|ef*g.|h?i(j|k)) reffgz y $&-$1-$2 effgz-effgz-
((((((((((a)))))))))) a y $10 a
((((((((((a))))))))))\10 aa y $& aa
-((((((((((a))))))))))\41 aa n - -
-((((((((((a))))))))))\41 a! y $& a!
+((((((((((a))))))))))${bang} aa n - -
+((((((((((a))))))))))${bang} a! y $& a!
(((((((((a))))))))) a y $& a
multiple words of text uh-uh n - -
multiple words multiple words, yeah y $& multiple words
@@ -291,8 +291,8 @@ a[-]?c ac y $& ac
'(bc+d$|ef*g.|h?i(j|k))'i REFFGZ y $&-$1-$2 EFFGZ-EFFGZ-
'((((((((((a))))))))))'i A y $10 A
'((((((((((a))))))))))\10'i AA y $& AA
-'((((((((((a))))))))))\41'i AA n - -
-'((((((((((a))))))))))\41'i A! y $& A!
+'((((((((((a))))))))))${bang}'i AA n - -
+'((((((((((a))))))))))${bang}'i A! y $& A!
'(((((((((a)))))))))'i A y $& A
'(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))'i A y $1 A
'(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))'i C y $1 C
@@ -335,6 +335,9 @@ a(?:b|(c|e){1,2}?|d)+?(.) ace y $1$2 ce
^(a(?(1)\1)){4}$ aaaaaaaaaa y $1 aaaa
^(a(?(1)\1)){4}$ aaaaaaaaa n - -
^(a(?(1)\1)){4}$ aaaaaaaaaaa n - -
+((a{4})+) aaaaaaaaa y $1 aaaaaaaa
+(((aa){2})+) aaaaaaaaaa y $1 aaaaaaaa
+(((a{2}){2})+) aaaaaaaaaa y $1 aaaaaaaa
(?:(f)(o)(o)|(b)(a)(r))* foobar y $1:$2:$3:$4:$5:$6 f:o:o:b:a:r
(?<=a)b ab y $& b
(?<=a)b cb n - -
@@ -399,7 +402,7 @@ a(?{{})b - c - /a(?{{})b/: Sequence (?{...}) not terminated or not {}-balanced
a(?{}})b - c - /a(?{}})b/: Sequence (?{...}) not terminated or not {}-balanced
a(?{"{"})b - c - /a(?{"{"})b/: Sequence (?{...}) not terminated or not {}-balanced
a(?{"\{"})b cabd y $& ab
-a(?{"{"}})b - c - Unmatched right bracket
+a(?{"{"}})b - c - Unmatched right curly bracket
a(?{$bl="\{"}).b caxbd y $bl {
x(~~)*(?:(?:F)?)? x~~ y - -
^a(?#xxx){3}c aaac y $& aaac
@@ -471,15 +474,268 @@ $(?<=^(a)) a y $1 a
([[=]+) a=[b]= y $1 =[
([[.]+) a.[b]. y $1 .[
[a[:xyz: - c - /[a[:xyz:/: unmatched [] in regexp
-[a[:xyz:] - c - /[a[:xyz:]/: unmatched [] in regexp
-([a[:xyz:]b]+) pbaq y $1 ba
+[a[:xyz:] - c - Character class [:xyz:] unknown
+[a[:]b[:c] abc y $& abc
+([a[:xyz:]b]+) pbaq c - Character class [:xyz:] unknown
+[a[:]b[:c] abc y $& abc
+([[:alpha:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 ABcd
+([[:alnum:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 ABcd01Xy
+([[:ascii:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 ABcd01Xy__-- ${nulnul}
+([[:cntrl:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 ${nulnul}
+([[:digit:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 01
+([[:graph:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 ABcd01Xy__--
+([[:lower:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 cd
+([[:print:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 ABcd01Xy__--
+([[:punct:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 __--
+([[:space:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1
+([[:word:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 ABcd01Xy__
+([[:upper:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 AB
+([[:xdigit:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 ABcd01
+([[:^alpha:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 01
+([[:^alnum:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 __-- ${nulnul}${ffff}
+([[:^ascii:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 ${ffff}
+([[:^cntrl:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 ABcd01Xy__--
+([[:^digit:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 ABcd
+([[:^lower:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 AB
+([[:^print:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 ${nulnul}${ffff}
+([[:^punct:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 ABcd01Xy
+([[:^space:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 ABcd01Xy__--
+([[:^word:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 -- ${nulnul}${ffff}
+([[:^upper:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 cd01
+([[:^xdigit:]]+) ABcd01Xy__-- ${nulnul}${ffff} y $1 Xy__-- ${nulnul}${ffff}
+[[:foo:]] - c - Character class [:foo:] unknown
+[[:^foo:]] - c - Character class [:^foo:] unknown
((?>a+)b) aaab y $1 aaab
(?>(a+))b aaab y $1 aaa
((?>[^()]+)|\([^()]*\))+ ((abc(ade)ufh()()x y $& abc(ade)ufh()()x
(?<=x+)y - c - /(?<=x+)y/: variable length lookbehind not implemented
a{37,17} - c - /a{37,17}/: Can't do {n,m} with n > m
+\Z a\nb\n y $-[0] 3
+\z a\nb\n y $-[0] 4
+$ a\nb\n y $-[0] 3
+\Z b\na\n y $-[0] 3
+\z b\na\n y $-[0] 4
+$ b\na\n y $-[0] 3
+\Z b\na y $-[0] 3
+\z b\na y $-[0] 3
+$ b\na y $-[0] 3
+'\Z'm a\nb\n y $-[0] 3
+'\z'm a\nb\n y $-[0] 4
+'$'m a\nb\n y $-[0] 1
+'\Z'm b\na\n y $-[0] 3
+'\z'm b\na\n y $-[0] 4
+'$'m b\na\n y $-[0] 1
+'\Z'm b\na y $-[0] 3
+'\z'm b\na y $-[0] 3
+'$'m b\na y $-[0] 1
a\Z a\nb\n n - -
-b\Z a\nb\n y - -
-b\z a\nb\n n - -
-b\Z a\nb y - -
-b\z a\nb y - -
+a\z a\nb\n n - -
+a$ a\nb\n n - -
+a\Z b\na\n y $-[0] 2
+a\z b\na\n n - -
+a$ b\na\n y $-[0] 2
+a\Z b\na y $-[0] 2
+a\z b\na y $-[0] 2
+a$ b\na y $-[0] 2
+'a\Z'm a\nb\n bn - -
+'a\z'm a\nb\n n - -
+'a$'m a\nb\n y $-[0] 0
+'a\Z'm b\na\n y $-[0] 2
+'a\z'm b\na\n n - -
+'a$'m b\na\n y $-[0] 2
+'a\Z'm b\na y $-[0] 2
+'a\z'm b\na y $-[0] 2
+'a$'m b\na y $-[0] 2
+aa\Z aa\nb\n n - -
+aa\z aa\nb\n n - -
+aa$ aa\nb\n n - -
+aa\Z b\naa\n y $-[0] 2
+aa\z b\naa\n n - -
+aa$ b\naa\n y $-[0] 2
+aa\Z b\naa y $-[0] 2
+aa\z b\naa y $-[0] 2
+aa$ b\naa y $-[0] 2
+'aa\Z'm aa\nb\n bn - -
+'aa\z'm aa\nb\n n - -
+'aa$'m aa\nb\n y $-[0] 0
+'aa\Z'm b\naa\n y $-[0] 2
+'aa\z'm b\naa\n n - -
+'aa$'m b\naa\n y $-[0] 2
+'aa\Z'm b\naa y $-[0] 2
+'aa\z'm b\naa y $-[0] 2
+'aa$'m b\naa y $-[0] 2
+aa\Z ac\nb\n n - -
+aa\z ac\nb\n n - -
+aa$ ac\nb\n n - -
+aa\Z b\nac\n n - -
+aa\z b\nac\n n - -
+aa$ b\nac\n n - -
+aa\Z b\nac n - -
+aa\z b\nac n - -
+aa$ b\nac n - -
+'aa\Z'm ac\nb\n n - -
+'aa\z'm ac\nb\n n - -
+'aa$'m ac\nb\n n - -
+'aa\Z'm b\nac\n n - -
+'aa\z'm b\nac\n n - -
+'aa$'m b\nac\n n - -
+'aa\Z'm b\nac n - -
+'aa\z'm b\nac n - -
+'aa$'m b\nac n - -
+aa\Z ca\nb\n n - -
+aa\z ca\nb\n n - -
+aa$ ca\nb\n n - -
+aa\Z b\nca\n n - -
+aa\z b\nca\n n - -
+aa$ b\nca\n n - -
+aa\Z b\nca n - -
+aa\z b\nca n - -
+aa$ b\nca n - -
+'aa\Z'm ca\nb\n n - -
+'aa\z'm ca\nb\n n - -
+'aa$'m ca\nb\n n - -
+'aa\Z'm b\nca\n n - -
+'aa\z'm b\nca\n n - -
+'aa$'m b\nca\n n - -
+'aa\Z'm b\nca n - -
+'aa\z'm b\nca n - -
+'aa$'m b\nca n - -
+ab\Z ab\nb\n n - -
+ab\z ab\nb\n n - -
+ab$ ab\nb\n n - -
+ab\Z b\nab\n y $-[0] 2
+ab\z b\nab\n n - -
+ab$ b\nab\n y $-[0] 2
+ab\Z b\nab y $-[0] 2
+ab\z b\nab y $-[0] 2
+ab$ b\nab y $-[0] 2
+'ab\Z'm ab\nb\n bn - -
+'ab\z'm ab\nb\n n - -
+'ab$'m ab\nb\n y $-[0] 0
+'ab\Z'm b\nab\n y $-[0] 2
+'ab\z'm b\nab\n n - -
+'ab$'m b\nab\n y $-[0] 2
+'ab\Z'm b\nab y $-[0] 2
+'ab\z'm b\nab y $-[0] 2
+'ab$'m b\nab y $-[0] 2
+ab\Z ac\nb\n n - -
+ab\z ac\nb\n n - -
+ab$ ac\nb\n n - -
+ab\Z b\nac\n n - -
+ab\z b\nac\n n - -
+ab$ b\nac\n n - -
+ab\Z b\nac n - -
+ab\z b\nac n - -
+ab$ b\nac n - -
+'ab\Z'm ac\nb\n n - -
+'ab\z'm ac\nb\n n - -
+'ab$'m ac\nb\n n - -
+'ab\Z'm b\nac\n n - -
+'ab\z'm b\nac\n n - -
+'ab$'m b\nac\n n - -
+'ab\Z'm b\nac n - -
+'ab\z'm b\nac n - -
+'ab$'m b\nac n - -
+ab\Z ca\nb\n n - -
+ab\z ca\nb\n n - -
+ab$ ca\nb\n n - -
+ab\Z b\nca\n n - -
+ab\z b\nca\n n - -
+ab$ b\nca\n n - -
+ab\Z b\nca n - -
+ab\z b\nca n - -
+ab$ b\nca n - -
+'ab\Z'm ca\nb\n n - -
+'ab\z'm ca\nb\n n - -
+'ab$'m ca\nb\n n - -
+'ab\Z'm b\nca\n n - -
+'ab\z'm b\nca\n n - -
+'ab$'m b\nca\n n - -
+'ab\Z'm b\nca n - -
+'ab\z'm b\nca n - -
+'ab$'m b\nca n - -
+abb\Z abb\nb\n n - -
+abb\z abb\nb\n n - -
+abb$ abb\nb\n n - -
+abb\Z b\nabb\n y $-[0] 2
+abb\z b\nabb\n n - -
+abb$ b\nabb\n y $-[0] 2
+abb\Z b\nabb y $-[0] 2
+abb\z b\nabb y $-[0] 2
+abb$ b\nabb y $-[0] 2
+'abb\Z'm abb\nb\n bn - -
+'abb\z'm abb\nb\n n - -
+'abb$'m abb\nb\n y $-[0] 0
+'abb\Z'm b\nabb\n y $-[0] 2
+'abb\z'm b\nabb\n n - -
+'abb$'m b\nabb\n y $-[0] 2
+'abb\Z'm b\nabb y $-[0] 2
+'abb\z'm b\nabb y $-[0] 2
+'abb$'m b\nabb y $-[0] 2
+abb\Z ac\nb\n n - -
+abb\z ac\nb\n n - -
+abb$ ac\nb\n n - -
+abb\Z b\nac\n n - -
+abb\z b\nac\n n - -
+abb$ b\nac\n n - -
+abb\Z b\nac n - -
+abb\z b\nac n - -
+abb$ b\nac n - -
+'abb\Z'm ac\nb\n n - -
+'abb\z'm ac\nb\n n - -
+'abb$'m ac\nb\n n - -
+'abb\Z'm b\nac\n n - -
+'abb\z'm b\nac\n n - -
+'abb$'m b\nac\n n - -
+'abb\Z'm b\nac n - -
+'abb\z'm b\nac n - -
+'abb$'m b\nac n - -
+abb\Z ca\nb\n n - -
+abb\z ca\nb\n n - -
+abb$ ca\nb\n n - -
+abb\Z b\nca\n n - -
+abb\z b\nca\n n - -
+abb$ b\nca\n n - -
+abb\Z b\nca n - -
+abb\z b\nca n - -
+abb$ b\nca n - -
+'abb\Z'm ca\nb\n n - -
+'abb\z'm ca\nb\n n - -
+'abb$'m ca\nb\n n - -
+'abb\Z'm b\nca\n n - -
+'abb\z'm b\nca\n n - -
+'abb$'m b\nca\n n - -
+'abb\Z'm b\nca n - -
+'abb\z'm b\nca n - -
+'abb$'m b\nca n - -
+(^|x)(c) ca y $2 c
+a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz x n - -
+a(?{$a=2;$b=3;($b)=$a})b yabz y $b 2
+round\(((?>[^()]+))\) _I(round(xs * sz),1) y $1 xs * sz
+'((?x:.) )' x y $1- x -
+'((?-x:.) )'x x y $1- x-
+foo.bart foo.bart y - -
+'^d[x][x][x]'m abcd\ndxxx y - -
+.X(.+)+X bbbbXcXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa y - -
+.X(.+)+XX bbbbXcXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa y - -
+.XX(.+)+X bbbbXXcXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa y - -
+.X(.+)+X bbbbXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa n - -
+.X(.+)+XX bbbbXXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa n - -
+.XX(.+)+X bbbbXXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa n - -
+.X(.+)+[X] bbbbXcXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa y - -
+.X(.+)+[X][X] bbbbXcXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa y - -
+.XX(.+)+[X] bbbbXXcXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa y - -
+.X(.+)+[X] bbbbXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa n - -
+.X(.+)+[X][X] bbbbXXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa n - -
+.XX(.+)+[X] bbbbXXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa n - -
+.[X](.+)+[X] bbbbXcXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa y - -
+.[X](.+)+[X][X] bbbbXcXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa y - -
+.[X][X](.+)+[X] bbbbXXcXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa y - -
+.[X](.+)+[X] bbbbXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa n - -
+.[X](.+)+[X][X] bbbbXXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa n - -
+.[X][X](.+)+[X] bbbbXXXaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa n - -
+tt+$ xxxtt y - -
+[a-\w] - c - /[a-\w]/: invalid [] range in regexp
+[\w-z] - c - /[\w-z]/: invalid [] range in regexp
+[0-[:digit:]] - c - /[0-[:digit:]]/: invalid [] range in regexp
+[[:digit:]-9] - c - /[[:digit:]-9]/: invalid [] range in regexp
diff --git a/t/op/readdir.t b/t/op/readdir.t
index ca19ebc7db..aea976823a 100755
--- a/t/op/readdir.t
+++ b/t/op/readdir.t
@@ -5,6 +5,12 @@ if ($@) { print "1..0\n"; exit; }
print "1..3\n";
+for $i (1..2000) {
+ local *OP;
+ opendir(OP, "op") or die "can't opendir: $!";
+ # should auto-closedir() here
+}
+
if (opendir(OP, "op")) { print "ok 1\n"; } else { print "not ok 1\n"; }
@D = grep(/^[^\.].*\.t$/i, readdir(OP));
closedir(OP);
diff --git a/t/op/ref.t b/t/op/ref.t
index 1d70f9fd4c..a2baab8e3b 100755
--- a/t/op/ref.t
+++ b/t/op/ref.t
@@ -1,6 +1,6 @@
#!./perl
-print "1..55\n";
+print "1..56\n";
# Test glob operations.
@@ -241,11 +241,11 @@ print $$_,"\n";
package A;
sub new { bless {}, shift }
DESTROY { print "# destroying 'A'\nok 51\n" }
- package B;
+ package _B;
sub new { bless {}, shift }
- DESTROY { print "# destroying 'B'\nok 50\n"; bless shift, 'A' }
+ DESTROY { print "# destroying '_B'\nok 50\n"; bless shift, 'A' }
package main;
- my $b = B->new;
+ my $b = _B->new;
}
# test if $_[0] is properly protected in DESTROY()
@@ -271,14 +271,22 @@ print $$_,"\n";
print "# good, didn't recurse\n";
}
+# test if refgen behaves with autoviv magic
+
+{
+ my @a;
+ $a[1] = "ok 53\n";
+ print ${\$_} for @a;
+}
+
# test global destruction
package FINALE;
{
- $ref3 = bless ["ok 55\n"]; # package destruction
- my $ref2 = bless ["ok 54\n"]; # lexical destruction
- local $ref1 = bless ["ok 53\n"]; # dynamic destruction
+ $ref3 = bless ["ok 56\n"]; # package destruction
+ my $ref2 = bless ["ok 55\n"]; # lexical destruction
+ local $ref1 = bless ["ok 54\n"]; # dynamic destruction
1; # flush any temp values on stack
}
diff --git a/t/op/regexp.t b/t/op/regexp.t
index 0ec069b19a..4ffe1362c6 100755
--- a/t/op/regexp.t
+++ b/t/op/regexp.t
@@ -16,6 +16,8 @@ $ENV{PERL_DESTRUCT_LEVEL} = 0 unless $ENV{PERL_DESTRUCT_LEVEL} > 3;
# y expect a match
# n expect no match
# c expect an error
+# B test exposes a known bug in Perl, should be skipped
+# b test exposes a known bug in Perl, should be skipped if noamp
#
# Columns 4 and 5 are used only if column 3 contains C<y> or C<c>.
#
@@ -24,18 +26,16 @@ $ENV{PERL_DESTRUCT_LEVEL} = 0 unless $ENV{PERL_DESTRUCT_LEVEL} > 3;
# Column 5 contains the expected result of double-quote
# interpolating that string after the match, or start of error message.
#
-# \n in the tests are interpolated.
+# \n in the tests are interpolated, as are variables of the form ${\w+}.
#
# If you want to add a regular expression test that can't be expressed
# in this format, don't add it here: put it in op/pat.t instead.
BEGIN {
chdir 't' if -d 't';
- @INC = '../lib' if -d '../lib';
+ unshift @INC, '../lib' if -d '../lib';
}
-use re 'eval';
-
$iters = shift || 1; # Poor man performance suite, 10000 is OK.
open(TESTS,'op/re_tests') || open(TESTS,'t/op/re_tests') ||
@@ -46,6 +46,10 @@ $numtests = $.;
seek(TESTS,0,0);
$. = 0;
+$bang = sprintf "\\%03o", ord "!"; # \41 would not be portable.
+$ffff = chr(0xff) x 2;
+$nulnul = "\0" x 2;
+
$| = 1;
print "1..$numtests\n# $iters iterations\n";
TEST:
@@ -57,11 +61,18 @@ while (<TESTS>) {
infty_subst(\$pat);
infty_subst(\$expect);
$pat = "'$pat'" unless $pat =~ /^[:']/;
+ $pat =~ s/(\$\{\w+\})/$1/eeg;
$pat =~ s/\\n/\n/g;
+ $subject =~ s/(\$\{\w+\})/$1/eeg;
$subject =~ s/\\n/\n/g;
+ $expect =~ s/(\$\{\w+\})/$1/eeg;
$expect =~ s/\\n/\n/g;
$expect = $repl = '-' if $skip_amp and $input =~ /\$[&\`\']/;
- for $study ("", "study \$subject") {
+ $skip = ($skip_amp ? ($result =~ s/B//i) : ($result =~ s/B//));
+ # Certain tests don't work with utf8 (the re_test should be in UTF8)
+ $skip = 1 if ($^H &= ~0x00000008) && $pat =~ /\[:\^(alnum|print|word):\]/;
+ $result =~ s/B//i unless $skip;
+ for $study ('', 'study \$subject') {
$c = $iters;
eval "$study; \$match = (\$subject =~ m$pat) while \$c--; \$got = \"$repl\";";
chomp( $err = $@ );
@@ -69,6 +80,9 @@ while (<TESTS>) {
if ($err !~ m!^\Q$expect!) { print "not ok $. (compile) $input => `$err'\n"; next TEST }
last; # no need to study a syntax error
}
+ elsif ( $skip ) {
+ print "ok $. # skipped\n"; next TEST;
+ }
elsif ($@) {
print "not ok $. $input => error `$err'\n"; next TEST;
}
diff --git a/t/op/repeat.t b/t/op/repeat.t
index 54fa590836..c030ba9a12 100755
--- a/t/op/repeat.t
+++ b/t/op/repeat.t
@@ -2,7 +2,7 @@
# $RCSfile: repeat.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:21 $
-print "1..19\n";
+print "1..20\n";
# compile time
@@ -40,3 +40,59 @@ print join(':', () x 4) eq '' ? "ok 16\n" : "not ok 16\n";
print join(':', (9) x 4) eq '9:9:9:9' ? "ok 17\n" : "not ok 17\n";
print join(':', (9,9) x 4) eq '9:9:9:9:9:9:9:9' ? "ok 18\n" : "not ok 18\n";
print join('', (split(//,"123")) x 2) eq '123123' ? "ok 19\n" : "not ok 19\n";
+
+#
+# The test #20 is actually testing for Digital C compiler optimizer bug,
+# present in Dec C versions 5.* and 6.0 (used in Digital UNIX and VMS),
+# found in December 1998. The bug was reported to Digital^WCompaq as
+# DECC 2745 (21-Dec-1998)
+# GEM_BUGS 7619 (23-Dec-1998)
+# As of April 1999 the bug has been fixed in Tru64 UNIX 5.0 and is planned
+# to be fixed also in 4.0G.
+#
+# The bug was as follows: broken code was produced for util.c:repeatcpy()
+# (a utility function for the 'x' operator) in the case *all* these
+# four conditions held:
+#
+# (1) len == 1
+# (2) "from" had the 8th bit on in its single character
+# (3) count > 7 (the 'x' count > 16)
+# (4) the highest optimization level was used in compilation
+# (which is the default when compiling Perl)
+#
+# The bug looked like this (. being the eight-bit character and ? being \xff):
+#
+# 16 ................
+# 17 .........???????.
+# 18 .........???????..
+# 19 .........???????...
+# 20 .........???????....
+# 21 .........???????.....
+# 22 .........???????......
+# 23 .........???????.......
+# 24 .........???????.???????
+# 25 .........???????.???????.
+#
+# The bug was triggered in the "if (len == 1)" branch. The fix
+# was to introduce a new temporary variable. In diff -u format:
+#
+# register char *frombase = from;
+#
+# if (len == 1) {
+#- todo = *from;
+#+ register char c = *from;
+# while (count-- > 0)
+#- *to++ = todo;
+#+ *to++ = c;
+# return;
+# }
+#
+# The bug could also be (obscurely) avoided by changing "from" to
+# be an unsigned char pointer.
+#
+# This obscure bug was not found by the then test suite but instead
+# by Mark.Martinec@nsc.ijs.si while trying to install Digest-MD5-2.00.
+#
+# jhi@iki.fi
+#
+print "\xdd" x 24 eq "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd" ? "ok 20\n" : "not ok 20\n";
diff --git a/t/op/runlevel.t b/t/op/runlevel.t
index 307e2a0bb5..a1551775e3 100755
--- a/t/op/runlevel.t
+++ b/t/op/runlevel.t
@@ -7,7 +7,7 @@
##
chdir 't' if -d 't';
-@INC = "../lib";
+unshift @INC, "../lib";
$Is_VMS = $^O eq 'VMS';
$Is_MSWin32 = $^O eq 'MSWin32';
$ENV{PERL5LIB} = "../lib" unless $Is_VMS;
@@ -35,7 +35,7 @@ for (@prgs){
`MCR $^X "-I[-.lib]" $switch $tmpfile` :
$Is_MSWin32 ?
`.\\perl -I../lib $switch $tmpfile 2>&1` :
- `sh -c './perl $switch $tmpfile' 2>&1`;
+ `./perl $switch $tmpfile 2>&1`;
my $status = $?;
$results =~ s/\n+$//;
# allow expected output to be written as if $prog is on STDIN
@@ -315,3 +315,23 @@ main|-|9|main::__ANON__
In DIE
main|-|10|(eval)
main|-|10|main::foo
+########
+package TEST;
+
+sub TIEARRAY {
+ return bless [qw(foo fee fie foe)], $_[0];
+}
+sub FETCH {
+ my ($s,$i) = @_;
+ if ($i) {
+ goto bbb;
+ }
+bbb:
+ return $s->[$i];
+}
+
+package main;
+tie my @bar, 'TEST';
+print join('|', @bar[0..3]), "\n";
+EXPECT
+foo|fee|fie|foe
diff --git a/t/op/sort.t b/t/op/sort.t
index a6829e01e4..f7bba3d263 100755
--- a/t/op/sort.t
+++ b/t/op/sort.t
@@ -1,25 +1,51 @@
#!./perl
-# $RCSfile: sort.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:24 $
+BEGIN {
+ chdir 't' if -d 't';
+ unshift @INC, '../lib';
+}
+print "1..38\n";
-print "1..21\n";
+# XXX known to leak scalars
+$ENV{PERL_DESTRUCT_LEVEL} = 0 unless $ENV{PERL_DESTRUCT_LEVEL} > 3;
sub backwards { $a lt $b ? 1 : $a gt $b ? -1 : 0 }
+my $upperfirst = 'A' lt 'a';
+
+# Beware: in future this may become hairier because of possible
+# collation complications: qw(A a B c) can be sorted at least as
+# any of the following
+#
+# A a B b
+# A B a b
+# a b A B
+# a A b B
+#
+# All the above orders make sense.
+#
+# That said, EBCDIC sorts all small letters first, as opposed
+# to ASCII which sorts all big letters first.
+
@harry = ('dog','cat','x','Cain','Abel');
@george = ('gone','chased','yz','punished','Axed');
$x = join('', sort @harry);
-print ($x eq 'AbelCaincatdogx' ? "ok 1\n" : "not ok 1\n");
-print "# x = '$x'\n";
+$expected = $upperfirst ? 'AbelCaincatdogx' : 'catdogxAbelCain';
+print "# 1: x = '$x', expected = '$expected'\n";
+print ($x eq $expected ? "ok 1\n" : "not ok 1\n");
$x = join('', sort( backwards @harry));
-print ($x eq 'xdogcatCainAbel' ? "ok 2\n" : "not ok 2\n");
-print "# x = '$x'\n";
+$expected = $upperfirst ? 'xdogcatCainAbel' : 'CainAbelxdogcat';
+print "# 2: x = '$x', expected = '$expected'\n";
+print ($x eq $expected ? "ok 2\n" : "not ok 2\n");
$x = join('', sort @george, 'to', @harry);
-print ($x eq 'AbelAxedCaincatchaseddoggonepunishedtoxyz'?"ok 3\n":"not ok 3\n");
-print "# x = '$x'\n";
+$expected = $upperfirst ?
+ 'AbelAxedCaincatchaseddoggonepunishedtoxyz' :
+ 'catchaseddoggonepunishedtoxyzAbelAxedCain' ;
+print "# 3: x = '$x', expected = '$expected'\n";
+print ($x eq $expected ?"ok 3\n":"not ok 3\n");
@a = ();
@b = reverse @a;
@@ -47,7 +73,9 @@ print ("@b" eq "2 3 4 10" ? "ok 9\n" : "not ok 9 (@b)\n");
$sub = 'backwards';
$x = join('', sort $sub @harry);
-print ($x eq 'xdogcatCainAbel' ? "ok 10\n" : "not ok 10\n");
+$expected = $upperfirst ? 'xdogcatCainAbel' : 'CainAbelxdogcat';
+print "# 10: x = $x, expected = '$expected'\n";
+print ($x eq $expected ? "ok 10\n" : "not ok 10\n");
# literals, combinations
@@ -102,3 +130,76 @@ eval <<'CODE';
my @result = sort 'one', 'two';
CODE
print $@ ? "not ok 21\n# $@" : "ok 21\n";
+
+{
+ my $sortsub = \&backwards;
+ my $sortglob = *backwards;
+ my $sortglobr = \*backwards;
+ my $sortname = 'backwards';
+ @b = sort $sortsub 4,1,3,2;
+ print ("@b" eq '4 3 2 1' ? "ok 22\n" : "not ok 22 |@b|\n");
+ @b = sort $sortglob 4,1,3,2;
+ print ("@b" eq '4 3 2 1' ? "ok 23\n" : "not ok 23 |@b|\n");
+ @b = sort $sortname 4,1,3,2;
+ print ("@b" eq '4 3 2 1' ? "ok 24\n" : "not ok 24 |@b|\n");
+ @b = sort $sortglobr 4,1,3,2;
+ print ("@b" eq '4 3 2 1' ? "ok 25\n" : "not ok 25 |@b|\n");
+}
+
+{
+ local $sortsub = \&backwards;
+ local $sortglob = *backwards;
+ local $sortglobr = \*backwards;
+ local $sortname = 'backwards';
+ @b = sort $sortsub 4,1,3,2;
+ print ("@b" eq '4 3 2 1' ? "ok 26\n" : "not ok 26 |@b|\n");
+ @b = sort $sortglob 4,1,3,2;
+ print ("@b" eq '4 3 2 1' ? "ok 27\n" : "not ok 27 |@b|\n");
+ @b = sort $sortname 4,1,3,2;
+ print ("@b" eq '4 3 2 1' ? "ok 28\n" : "not ok 28 |@b|\n");
+ @b = sort $sortglobr 4,1,3,2;
+ print ("@b" eq '4 3 2 1' ? "ok 29\n" : "not ok 29 |@b|\n");
+}
+
+## exercise sort builtins... ($a <=> $b already tested)
+@a = ( 5, 19, 1996, 255, 90 );
+@b = sort { $b <=> $a } @a;
+print ("@b" eq '1996 255 90 19 5' ? "ok 30\n" : "not ok 30\n");
+print "# x = '@b'\n";
+$x = join('', sort { $a cmp $b } @harry);
+$expected = $upperfirst ? 'AbelCaincatdogx' : 'catdogxAbelCain';
+print ($x eq $expected ? "ok 31\n" : "not ok 31\n");
+print "# x = '$x'; expected = '$expected'\n";
+$x = join('', sort { $b cmp $a } @harry);
+$expected = $upperfirst ? 'xdogcatCainAbel' : 'CainAbelxdogcat';
+print ($x eq $expected ? "ok 32\n" : "not ok 32\n");
+print "# x = '$x'; expected = '$expected'\n";
+{
+ use integer;
+ @b = sort { $a <=> $b } @a;
+ print ("@b" eq '5 19 90 255 1996' ? "ok 33\n" : "not ok 33\n");
+ print "# x = '@b'\n";
+ @b = sort { $b <=> $a } @a;
+ print ("@b" eq '1996 255 90 19 5' ? "ok 34\n" : "not ok 34\n");
+ print "# x = '@b'\n";
+ $x = join('', sort { $a cmp $b } @harry);
+ $expected = $upperfirst ? 'AbelCaincatdogx' : 'catdogxAbelCain';
+ print ($x eq $expected ? "ok 35\n" : "not ok 35\n");
+ print "# x = '$x'; expected = '$expected'\n";
+ $x = join('', sort { $b cmp $a } @harry);
+ $expected = $upperfirst ? 'xdogcatCainAbel' : 'CainAbelxdogcat';
+ print ($x eq $expected ? "ok 36\n" : "not ok 36\n");
+ print "# x = '$x'; expected = '$expected'\n";
+}
+
+# test that an optimized-away comparison block doesn't take any other
+# arguments away with it
+$x = join('', sort { $a <=> $b } 3, 1, 2);
+print $x eq "123" ? "ok 37\n" : "not ok 37\n";
+
+# test sorting in non-main package
+package Foo;
+@a = ( 5, 19, 1996, 255, 90 );
+@b = sort { $b <=> $a } @a;
+print ("@b" eq '1996 255 90 19 5' ? "ok 38\n" : "not ok 38\n");
+print "# x = '@b'\n";
diff --git a/t/op/sprintf.t b/t/op/sprintf.t
index 7556c80a41..ef5b94cb11 100755
--- a/t/op/sprintf.t
+++ b/t/op/sprintf.t
@@ -14,8 +14,8 @@ $SIG{__WARN__} = sub {
};
$w = 0;
-$x = sprintf("%3s %-4s%%foo %.0d%5d %#x%c%3.1f","hi",123,0,456,0,65,3.0999);
-if ($x eq ' hi 123 %foo 456 0A3.1' && $w == 0) {
+$x = sprintf("%3s %-4s%%foo %.0d%5d %#x%c%3.1f %b","hi",123,0,456,0,ord('A'),3.0999,11);
+if ($x eq ' hi 123 %foo 456 0A3.1 1011' && $w == 0) {
print "ok 1\n";
} else {
print "not ok 1 '$x'\n";
diff --git a/t/op/stat.t b/t/op/stat.t
index 03bfd8da39..0af55bbaab 100755
--- a/t/op/stat.t
+++ b/t/op/stat.t
@@ -4,7 +4,7 @@
BEGIN {
chdir 't' if -d 't';
- @INC = '../lib';
+ unshift @INC, '../lib';
}
use Config;
@@ -13,28 +13,40 @@ print "1..58\n";
$Is_MSWin32 = $^O eq 'MSWin32';
$Is_Dos = $^O eq 'dos';
+$Is_Dosish = $Is_Dos || $^O eq 'os2' || $Is_MSWin32;
chop($cwd = ($Is_MSWin32 ? `cd` : `pwd`));
-$DEV = `ls -l /dev` unless ($Is_MSWin32 || $Is_Dos);
+$DEV = `ls -l /dev` unless $Is_Dosish;
unlink "Op.stat.tmp";
-open(FOO, ">Op.stat.tmp");
-
-# hack to make Apollo update link count:
-$junk = `ls Op.stat.tmp` unless ($Is_MSWin32 || $Is_Dos);
-
-($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
- $blksize,$blocks) = stat(FOO);
-if ($nlink == 1) {print "ok 1\n";} else {print "not ok 1\n";}
-if ($Is_MSWin32 || ($mtime && $mtime == $ctime)) {print "ok 2\n";}
-else {print "# |$mtime| vs |$ctime|\nnot ok 2\n";}
-
-print FOO "Now is the time for all good men to come to.\n";
-close(FOO);
-
-sleep 2;
+if (open(FOO, ">Op.stat.tmp")) {
+ # hack to make Apollo update link count:
+ $junk = `ls Op.stat.tmp` unless ($Is_MSWin32 || $Is_Dos);
+
+ ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
+ $blksize,$blocks) = stat(FOO);
+ if ($nlink == 1) {
+ print "ok 1\n";
+ }
+ else {
+ print "# res=$res, nlink=$nlink.\nnot ok 1\n";
+ }
+ if ($Is_MSWin32 || ($mtime && $mtime == $ctime)) {
+ print "ok 2\n";
+ }
+ else {
+ print "# |$mtime| vs |$ctime|\nnot ok 2\n";
+ }
+
+ print FOO "Now is the time for all good men to come to.\n";
+ close(FOO);
+
+ sleep 2;
+} else {
+ print "# open failed: $!\nnot ok 1\nnot ok 2\n";
+}
-if ($Is_MSWin32 || $Is_Dos) { unlink "Op.stat.tmp2" }
+if ($Is_Dosish) { unlink "Op.stat.tmp2"}
else {
`rm -f Op.stat.tmp2;ln Op.stat.tmp Op.stat.tmp2; chmod 644 Op.stat.tmp`;
}
@@ -42,15 +54,19 @@ else {
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
$blksize,$blocks) = stat('Op.stat.tmp');
-if ($Is_MSWin32 || $Is_Dos || $Config{dont_use_nlink} || $nlink == 2)
- {print "ok 3\n";} else {print "# \$nlink is |$nlink|\nnot ok 3\n";}
+if ($Is_Dosish || $Config{dont_use_nlink})
+ {print "ok 3 # skipped: no link count\n";}
+elsif ($nlink == 2)
+ {print "ok 3\n";}
+else {print "# \$nlink is |$nlink|\nnot ok 3\n";}
-if ( ($mtime && $mtime != $ctime)
- || $Is_MSWin32
- || $Is_Dos
+if ( $Is_Dosish
|| ($cwd =~ m#^/tmp# and $mtime && $mtime==$ctime) # Solaris tmpfs bug
|| $cwd =~ m#/afs/#
|| $^O eq 'amigaos') {
+ print "ok 4 # skipped: different semantic of mtime/ctime\n";
+}
+elsif ( ($mtime && $mtime != $ctime) ) {
print "ok 4\n";
}
else {
@@ -60,7 +76,7 @@ else {
}
print "#4 :$mtime: should != :$ctime:\n";
-unlink "Op.stat.tmp";
+unlink "Op.stat.tmp" or print "# unlink failed: $!\n";
if ($Is_MSWin32) { open F, '>Op.stat.tmp' and close F }
else { `touch Op.stat.tmp` }
@@ -71,7 +87,7 @@ $Is_MSWin32 ? `cmd /c echo hi > Op.stat.tmp` : `echo hi >Op.stat.tmp`;
if (! -z 'Op.stat.tmp') {print "ok 7\n";} else {print "not ok 7\n";}
if (-s 'Op.stat.tmp') {print "ok 8\n";} else {print "not ok 8\n";}
-unlink 'Op.stat.tmp';
+unlink 'Op.stat.tmp' or print "# unlink failed: $!\n";
$olduid = $>; # can't test -r if uid == 0
$Is_MSWin32 ? `cmd /c echo hi > Op.stat.tmp` : `echo hi >Op.stat.tmp`;
chmod 0,'Op.stat.tmp';
@@ -88,10 +104,15 @@ foreach ((12,13,14,15,16,17)) {
print "ok $_\n"; #deleted tests
}
+# in ms windows, Op.stat.tmp inherits owner uid from directory
+# not sure about os/2, but chown is harmless anyway
+eval { chown $>,'Op.stat.tmp'; 1 } or print "# $@" ;
chmod 0700,'Op.stat.tmp';
if (-r 'Op.stat.tmp') {print "ok 18\n";} else {print "not ok 18\n";}
if (-w 'Op.stat.tmp') {print "ok 19\n";} else {print "not ok 19\n";}
-if ($Is_MSWin32 or $Is_Dos or -x 'Op.stat.tmp') {print "ok 20\n";} else {print "not ok 20\n";}
+if ($Is_Dosish) {print "ok 20 # skipped: -x by extension\n";}
+elsif (-x 'Op.stat.tmp') {print "ok 20\n";}
+else {print "not ok 20\n";}
if (-f 'Op.stat.tmp') {print "ok 21\n";} else {print "not ok 21\n";}
if (! -d 'Op.stat.tmp') {print "ok 22\n";} else {print "not ok 22\n";}
@@ -99,7 +120,7 @@ if (! -d 'Op.stat.tmp') {print "ok 22\n";} else {print "not ok 22\n";}
if (-d '.') {print "ok 23\n";} else {print "not ok 23\n";}
if (! -f '.') {print "ok 24\n";} else {print "not ok 24\n";}
-if (!($Is_MSWin32 || $Is_Dos) and `ls -l perl` =~ /^l.*->/) {
+if (!$Is_Dosish and `ls -l perl` =~ /^l.*->/) {
if (-l 'perl') {print "ok 25\n";} else {print "not ok 25\n";}
}
else {
@@ -142,7 +163,9 @@ else
{print "not ok 33\n";}
if (! -b '.') {print "ok 34\n";} else {print "not ok 34\n";}
-if ($^O eq 'amigaos' or $Is_MSWin32 || $Is_Dos) {print "ok 35\n"; goto tty_test;}
+if ($^O eq 'amigaos' or $Is_Dosish) {
+ print "ok 35 # skipped: no -u\n"; goto tty_test;
+}
$cnt = $uid = 0;
@@ -175,14 +198,23 @@ unless($ENV{PERL_SKIP_TTY_TEST}) {
print "ok 37\n";
}
else {
- unless (open(tty,"/dev/tty")) {
- print STDERR "Can't open /dev/tty--run t/TEST outside of make.\n";
+ my $TTY = "/dev/tty";
+
+ $TTY = "/dev/ttyp0" if $^O eq 'rhapsody';
+
+ if (defined $TTY) {
+ unless (open(TTY, $TTY)) {
+ print STDERR "Can't open $TTY--run t/TEST outside of make.\n";
+ }
+ if (-t TTY) {print "ok 36\n";} else {print "not ok 36\n";}
+ if (-c TTY) {print "ok 37\n";} else {print "not ok 37\n";}
+ close(TTY);
+ } else { # if some platform completely undefines $TTY
+ print "ok 36 # skipped\n";
+ print "ok 37 # skipped\n";
}
- if (-t tty) {print "ok 36\n";} else {print "not ok 36\n";}
- if (-c tty) {print "ok 37\n";} else {print "not ok 37\n";}
- close(tty);
}
- if (! -t tty) {print "ok 38\n";} else {print "not ok 38\n";}
+ if (! -t TTY) {print "ok 38\n";} else {print "not ok 38\n";}
if (-t) {print "ok 39\n";} else {print "not ok 39\n";}
}
else {
@@ -240,4 +272,4 @@ $_ = 'Op.stat.tmp';
if (-f) {print "ok 57\n";} else {print "not ok 57\n";}
if (-f()) {print "ok 58\n";} else {print "not ok 58\n";}
-unlink 'Op.stat.tmp';
+unlink 'Op.stat.tmp' or print "# unlink failed: $!\n";
diff --git a/t/op/subst.t b/t/op/subst.t
index 2d42eeb386..2d15df4dc1 100755
--- a/t/op/subst.t
+++ b/t/op/subst.t
@@ -1,12 +1,12 @@
#!./perl
-
BEGIN {
chdir 't' if -d 't';
- @INC = '../lib' if -d '../lib';
+ unshift @INC, '../lib' if -d '../lib';
+ require Config; import Config;
}
-print "1..71\n";
+print "1..83\n";
$x = 'foo';
$_ = "x";
@@ -187,13 +187,22 @@ 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];
+if ($Config{ebcdic} eq 'define') { # EBCDIC.
+ no utf8;
+ y[\301-\351][\201-\251];
+} else { # Ye Olde ASCII. Or something like it.
+ 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";
+if (ord("+") == ord(",") - 1 && ord(",") == ord("-") - 1 &&
+ ord("a") == ord("b") - 1 && ord("b") == ord("c") - 1) {
+ $_ = '+,-';
+ tr/+--/a-c/;
+ print "not " unless $_ eq 'abc';
+}
+print "ok 54\n";
$_ = '+,-';
tr/+\--/a\/c/;
@@ -303,6 +312,67 @@ s{ \d+ \b [,.;]? (?{ 'digits' })
print ($_ eq $foo ? "ok 70\n" : "not ok 70\n#'$_'\n#'$foo'\n");
$_ = 'x' x 20;
-s/\d*|x/<$&>/g;
+s/(\d*|x)/<$1>/g;
$foo = '<>' . ('<x><>' x 20) ;
print ($_ eq $foo ? "ok 71\n" : "not ok 71\n#'$_'\n#'$foo'\n");
+
+$t = 'aaaaaaaaa';
+
+$_ = $t;
+pos = 6;
+s/\Ga/xx/g;
+print "not " unless $_ eq 'aaaaaaxxxxxx';
+print "ok 72\n";
+
+$_ = $t;
+pos = 6;
+s/\Ga/x/g;
+print "not " unless $_ eq 'aaaaaaxxx';
+print "ok 73\n";
+
+$_ = $t;
+pos = 6;
+s/\Ga/xx/;
+print "not " unless $_ eq 'aaaaaaxxaa';
+print "ok 74\n";
+
+$_ = $t;
+pos = 6;
+s/\Ga/x/;
+print "not " unless $_ eq 'aaaaaaxaa';
+print "ok 75\n";
+
+$_ = $t;
+s/\Ga/xx/g;
+print "not " unless $_ eq 'xxxxxxxxxxxxxxxxxx';
+print "ok 76\n";
+
+$_ = $t;
+s/\Ga/x/g;
+print "not " unless $_ eq 'xxxxxxxxx';
+print "ok 77\n";
+
+$_ = $t;
+s/\Ga/xx/;
+print "not " unless $_ eq 'xxaaaaaaaa';
+print "ok 78\n";
+
+$_ = $t;
+s/\Ga/x/;
+print "not " unless $_ eq 'xaaaaaaaa';
+print "ok 79\n";
+
+$_ = 'aaaa';
+s/\ba/./g;
+print "#'$_'\nnot " unless $_ eq '.aaa';
+print "ok 80\n";
+
+eval q% s/a/"b"}/e %;
+print ($@ =~ /Bad evalled substitution/ ? "ok 81\n" : "not ok 81\n");
+eval q% ($_ = "x") =~ s/(.)/"$1 "/e %;
+print +($_ eq "x " and !length $@) ? "ok 82\n" : "not ok 82\n# \$_ eq $_, $@\n";
+$x = $x = 'interp';
+eval q% ($_ = "x") =~ s/x(($x)*)/"$1"/e %;
+print +($_ eq '' and !length $@) ? "ok 83\n" : "not ok 83\n# \$_ eq $_, $@\n";
+
+
diff --git a/t/op/subst_amp.t b/t/op/subst_amp.t
new file mode 100755
index 0000000000..e2e7c0e542
--- /dev/null
+++ b/t/op/subst_amp.t
@@ -0,0 +1,104 @@
+#!./perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ unshift @INC, '../lib' if -d '../lib';
+ require Config; import Config;
+}
+
+print "1..13\n";
+
+$_ = 'x' x 20;
+s/\d*|x/<$&>/g;
+$foo = '<>' . ('<x><>' x 20) ;
+print ($_ eq $foo ? "ok 1\n" : "not ok 1\n#'$_'\n#'$foo'\n");
+
+$t = 'aaa';
+
+$_ = $t;
+@res = ();
+pos = 1;
+s/\Ga(?{push @res, $_, $`})/xx/g;
+print "not " unless "$_ @res" eq 'axxxx aaa a aaa aa';
+print "ok 2\n";
+
+$_ = $t;
+@res = ();
+pos = 1;
+s/\Ga(?{push @res, $_, $`})/x/g;
+print "not " unless "$_ @res" eq 'axx aaa a aaa aa';
+print "ok 3\n";
+
+$_ = $t;
+@res = ();
+pos = 1;
+s/\Ga(?{push @res, $_, $`})/xx/;
+print "not " unless "$_ @res" eq 'axxa aaa a';
+print "ok 4\n";
+
+$_ = $t;
+@res = ();
+pos = 1;
+s/\Ga(?{push @res, $_, $`})/x/;
+print "not " unless "$_ @res" eq 'axa aaa a';
+print "ok 5\n";
+
+$a = $t;
+@res = ();
+pos ($a) = 1;
+$a =~ s/\Ga(?{push @res, $_, $`})/xx/g;
+print "#'$a' '@res'\nnot " unless "$a @res" eq 'axxxx aaa a aaa aa';
+print "ok 6\n";
+
+$a = $t;
+@res = ();
+pos ($a) = 1;
+$a =~ s/\Ga(?{push @res, $_, $`})/x/g;
+print "#'$a' '@res'\nnot " unless "$a @res" eq 'axx aaa a aaa aa';
+print "ok 7\n";
+
+$a = $t;
+@res = ();
+pos ($a) = 1;
+$a =~ s/\Ga(?{push @res, $_, $`})/xx/;
+print "#'$a' '@res'\nnot " unless "$a @res" eq 'axxa aaa a';
+print "ok 8\n";
+
+$a = $t;
+@res = ();
+pos ($a) = 1;
+$a =~ s/\Ga(?{push @res, $_, $`})/x/;
+print "#'$a' '@res'\nnot " unless "$a @res" eq 'axa aaa a';
+print "ok 9\n";
+
+sub x2 {'xx'}
+sub x1 {'x'}
+
+$a = $t;
+@res = ();
+pos ($a) = 1;
+$a =~ s/\Ga(?{push @res, $_, $`})/x2/ge;
+print "#'$a' '@res'\nnot " unless "$a @res" eq 'axxxx aaa a aaa aa';
+print "ok 10\n";
+
+$a = $t;
+@res = ();
+pos ($a) = 1;
+$a =~ s/\Ga(?{push @res, $_, $`})/x1/ge;
+print "#'$a' '@res'\nnot " unless "$a @res" eq 'axx aaa a aaa aa';
+print "ok 11\n";
+
+$a = $t;
+@res = ();
+pos ($a) = 1;
+$a =~ s/\Ga(?{push @res, $_, $`})/x2/e;
+print "#'$a' '@res'\nnot " unless "$a @res" eq 'axxa aaa a';
+print "ok 12\n";
+
+$a = $t;
+@res = ();
+pos ($a) = 1;
+$a =~ s/\Ga(?{push @res, $_, $`})/x1/e;
+print "#'$a' '@res'\nnot " unless "$a @res" eq 'axa aaa a';
+print "ok 13\n";
+
diff --git a/t/op/subst_wamp.t b/t/op/subst_wamp.t
new file mode 100755
index 0000000000..b716b30915
--- /dev/null
+++ b/t/op/subst_wamp.t
@@ -0,0 +1,11 @@
+#!./perl
+
+$dummy = defined $&; # Now we have it...
+for $file ('op/subst.t', 't/op/subst.t') {
+ if (-r $file) {
+ do $file;
+ exit;
+ }
+}
+die "Cannot find op/subst.t or t/op/subst.t\n";
+
diff --git a/t/op/sysio.t b/t/op/sysio.t
index 826cf383ae..22e60e30fc 100755
--- a/t/op/sysio.t
+++ b/t/op/sysio.t
@@ -1,12 +1,13 @@
#!./perl
-print "1..36\n";
+print "1..39\n";
chdir('op') || die "sysio.t: cannot look for myself: $!";
open(I, 'sysio.t') || die "sysio.t: cannot find myself: $!";
-$reopen = ($^O eq 'VMS' || $^O eq 'os2' || $^O eq 'MSWin32' || $^O eq 'dos');
+$reopen = ($^O eq 'VMS' || $^O eq 'os2' || $^O eq 'MSWin32' || $^O eq 'dos' ||
+ $^O eq 'mpeix');
$x = 'abc';
@@ -151,6 +152,21 @@ if ($reopen) { # must close file to update EOF marker for stat
print 'not ' unless (-s $outfile == 7);
print "ok 28\n";
+# with implicit length argument
+print 'not ' unless (syswrite(O, $x) == 3);
+print "ok 29\n";
+
+# $a still intact
+print 'not ' unless ($x eq "abc");
+print "ok 30\n";
+
+# $outfile should have grown now
+if ($reopen) { # must close file to update EOF marker for stat
+ close O; open(O, ">>$outfile") || die "sysio.t: cannot write $outfile: $!";
+}
+print 'not ' unless (-s $outfile == 10);
+print "ok 31\n";
+
close(O);
open(I, $outfile) || die "sysio.t: cannot read $outfile: $!";
@@ -158,30 +174,30 @@ open(I, $outfile) || die "sysio.t: cannot read $outfile: $!";
$b = 'xyz';
# reading too much only return as much as available
-print 'not ' unless (sysread(I, $b, 100) == 7);
-print "ok 29\n";
+print 'not ' unless (sysread(I, $b, 100) == 10);
+print "ok 32\n";
# this we should have
-print 'not ' unless ($b eq '#!ererl');
-print "ok 30\n";
+print 'not ' unless ($b eq '#!ererlabc');
+print "ok 33\n";
# test sysseek
print 'not ' unless sysseek(I, 2, 0) == 2;
-print "ok 31\n";
+print "ok 34\n";
sysread(I, $b, 3);
print 'not ' unless $b eq 'ere';
-print "ok 32\n";
+print "ok 35\n";
print 'not ' unless sysseek(I, -2, 1) == 3;
-print "ok 33\n";
+print "ok 36\n";
sysread(I, $b, 4);
print 'not ' unless $b eq 'rerl';
-print "ok 34\n";
+print "ok 37\n";
print 'not ' unless sysseek(I, 0, 0) eq '0 but true';
-print "ok 35\n";
+print "ok 38\n";
print 'not ' if defined sysseek(I, -1, 1);
-print "ok 36\n";
+print "ok 39\n";
close(I);
diff --git a/t/op/taint.t b/t/op/taint.t
index f2181d82fd..fdd1c79b83 100755
--- a/t/op/taint.t
+++ b/t/op/taint.t
@@ -9,12 +9,23 @@
BEGIN {
chdir 't' if -d 't';
- @INC = '../lib' if -d '../lib';
+ unshift @INC, '../lib' if -d '../lib';
}
use strict;
use Config;
+# We do not want the whole taint.t to fail
+# just because Errno possibly failing.
+eval { require Errno; import Errno };
+
+BEGIN {
+ if ($^O eq 'VMS' && !defined($Config{d_setenv})) {
+ $ENV{PATH} = $ENV{PATH};
+ $ENV{TERM} = $ENV{TERM} ne ''? $ENV{TERM} : 'dummy';
+ }
+}
+
my $Is_VMS = $^O eq 'VMS';
my $Is_MSWin32 = $^O eq 'MSWin32';
my $Is_Dos = $^O eq 'dos';
@@ -29,9 +40,9 @@ if ($Is_VMS) {
}
eval <<EndOfCleanup;
END {
- \$ENV{PATH} = '';
+ \$ENV{PATH} = '' if $Config{d_setenv};
warn "# Note: logical name 'PATH' may have been deleted\n";
- @ENV{keys %old} = values %old;
+ \@ENV{keys %old} = values %old;
}
EndOfCleanup
}
@@ -360,7 +371,12 @@ else {
test 71, eval { open FOO, $foo } eq '', 'open for read';
test 72, $@ eq '', $@; # NB: This should be allowed
- test 73, $! == 2 || ($Is_Dos && $! == 22); # File not found
+
+ # Try first new style but allow also old style.
+ test 73, $!{ENOENT} ||
+ $! == 2 || # File not found
+ ($Is_Dos && $! == 22) ||
+ ($^O eq 'mint' && $! == 33);
test 74, eval { open FOO, "> $foo" } eq '', 'open for write';
test 75, $@ =~ /^Insecure dependency/, $@;
@@ -374,10 +390,10 @@ else {
for (76..79) { print "ok $_ # Skipped: open('|') is not available\n" }
}
else {
- test 76, eval { open FOO, "| $foo" } eq '', 'popen to';
+ test 76, eval { open FOO, "| x$foo" } eq '', 'popen to';
test 77, $@ =~ /^Insecure dependency/, $@;
- test 78, eval { open FOO, "$foo |" } eq '', 'popen from';
+ test 78, eval { open FOO, "x$foo |" } eq '', 'popen from';
test 79, $@ =~ /^Insecure dependency/, $@;
}
diff --git a/t/op/tie.t b/t/op/tie.t
index 77e74db4e2..105b1d6f18 100755
--- a/t/op/tie.t
+++ b/t/op/tie.t
@@ -6,7 +6,7 @@
# Currently it only tests the untie warning
chdir 't' if -d 't';
-@INC = "../lib";
+unshift @INC, "../lib";
$ENV{PERL5LIB} = "../lib";
$|=1;
@@ -77,8 +77,8 @@ EXPECT
########
# strict behaviour, without any extra references
-#use warning 'untie';
-local $^W = 1 ;
+use warnings 'untie';
+#local $^W = 1 ;
use Tie::Hash ;
tie %h, Tie::StdHash;
untie %h;
@@ -86,8 +86,8 @@ EXPECT
########
# strict behaviour, with 1 extra references generating an error
-#use warning 'untie';
-local $^W = 1 ;
+use warnings 'untie';
+#local $^W = 1 ;
use Tie::Hash ;
$a = tie %h, Tie::StdHash;
untie %h;
@@ -96,8 +96,8 @@ untie attempted while 1 inner references still exist
########
# strict behaviour, with 1 extra references via tied generating an error
-#use warning 'untie';
-local $^W = 1 ;
+use warnings 'untie';
+#local $^W = 1 ;
use Tie::Hash ;
tie %h, Tie::StdHash;
$a = tied %h;
@@ -107,8 +107,8 @@ untie attempted while 1 inner references still exist
########
# strict behaviour, with 1 extra references which are destroyed
-#use warning 'untie';
-local $^W = 1 ;
+use warnings 'untie';
+#local $^W = 1 ;
use Tie::Hash ;
$a = tie %h, Tie::StdHash;
$a = 0 ;
@@ -117,8 +117,8 @@ EXPECT
########
# strict behaviour, with extra 1 references via tied which are destroyed
-#use warning 'untie';
-local $^W = 1 ;
+use warnings 'untie';
+#local $^W = 1 ;
use Tie::Hash ;
tie %h, Tie::StdHash;
$a = tied %h;
@@ -128,8 +128,8 @@ EXPECT
########
# strict error behaviour, with 2 extra references
-#use warning 'untie';
-local $^W = 1 ;
+use warnings 'untie';
+#local $^W = 1 ;
use Tie::Hash ;
$a = tie %h, Tie::StdHash;
$b = tied %h ;
@@ -139,17 +139,42 @@ untie attempted while 2 inner references still exist
########
# strict behaviour, check scope of strictness.
-#no warning 'untie';
-local $^W = 0 ;
+no warnings 'untie';
+#local $^W = 0 ;
use Tie::Hash ;
$A = tie %H, Tie::StdHash;
$C = $B = tied %H ;
{
- #use warning 'untie';
- local $^W = 1 ;
+ use warnings 'untie';
+ #local $^W = 1 ;
use Tie::Hash ;
tie %h, Tie::StdHash;
untie %h;
}
untie %H;
EXPECT
+########
+
+# verify no leak when underlying object is selfsame tied variable
+my ($a, $b);
+sub Self::TIEHASH { bless $_[1], $_[0] }
+sub Self::DESTROY { $b = $_[0] + 0; }
+{
+ my %b5;
+ $a = \%b5 + 0;
+ tie %b5, 'Self', \%b5;
+}
+die unless $a == $b;
+EXPECT
+########
+# Interaction of tie and vec
+
+my ($a, $b);
+use Tie::Scalar;
+tie $a,Tie::StdScalar or die;
+vec($b,1,1)=1;
+$a = $b;
+vec($a,1,1)=0;
+vec($b,1,1)=0;
+die unless $a eq $b;
+EXPECT
diff --git a/t/op/tiearray.t b/t/op/tiearray.t
index 8e78b2f76b..25fda3fb03 100755
--- a/t/op/tiearray.t
+++ b/t/op/tiearray.t
@@ -3,7 +3,7 @@
BEGIN {
chdir 't' if -d 't';
- @INC = '../lib';
+ unshift @INC, '../lib';
}
my %seen;
diff --git a/t/op/tiehandle.t b/t/op/tiehandle.t
index e3d24723a9..6ae3faaaec 100755
--- a/t/op/tiehandle.t
+++ b/t/op/tiehandle.t
@@ -2,7 +2,7 @@
BEGIN {
chdir 't' if -d 't';
- @INC = '../lib';
+ unshift @INC, '../lib';
}
my @expect;
@@ -64,7 +64,7 @@ sub READ {
sub WRITE {
compare(WRITE => @_);
$data = substr($_[1],$_[3] || 0, $_[2]);
- 4;
+ length($data);
}
sub CLOSE {
@@ -77,7 +77,7 @@ package main;
use Symbol;
-print "1..23\n";
+print "1..29\n";
my $fh = gensym;
@@ -132,6 +132,20 @@ $r = syswrite $fh,$buf,4,1;
ok($r == 4);
ok($data eq "wert");
+$buf = "qwerty";
+@expect = (WRITE => $ob, $buf, 4);
+$data = "";
+$r = syswrite $fh,$buf,4;
+ok($r == 4);
+ok($data eq "qwer");
+
+$buf = "qwerty";
+@expect = (WRITE => $ob, $buf, 6);
+$data = "";
+$r = syswrite $fh,$buf;
+ok($r == 6);
+ok($data eq "qwerty");
+
@expect = (CLOSE => $ob);
$r = close $fh;
ok($r == 5);
diff --git a/t/op/time.t b/t/op/time.t
index 1bec442fe2..658f9f35b9 100755
--- a/t/op/time.t
+++ b/t/op/time.t
@@ -2,7 +2,7 @@
# $RCSfile: time.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:32 $
-if ($does_gmtime = gmtime(time)) { print "1..5\n" }
+if ($does_gmtime = gmtime(time)) { print "1..6\n" }
else { print "1..3\n" }
($beguser,$begsys) = times;
@@ -45,3 +45,9 @@ if (index(" :0:1:-1:364:365:-364:-365:",':' . ($localyday - $yday) . ':') > 0)
{print "ok 5\n";}
else
{print "not ok 5\n";}
+
+# This could be stricter.
+if (gmtime() =~ /^(Sun|Mon|Tue|Wed|Thu|Fri|Sat) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Nov|Dec) ([ \d]\d) (\d\d):(\d\d):(\d\d) (\d\d\d\d)$/)
+ {print "ok 6\n";}
+else
+ {print "not ok 6\n";}
diff --git a/t/op/tr.t b/t/op/tr.t
new file mode 100755
index 0000000000..4e6667cd7f
--- /dev/null
+++ b/t/op/tr.t
@@ -0,0 +1,39 @@
+# tr.t
+
+BEGIN {
+ chdir 't' if -d 't';
+ unshift @INC, "../lib";
+}
+
+print "1..4\n";
+
+$_ = "abcdefghijklmnopqrstuvwxyz";
+
+tr/a-z/A-Z/;
+
+print "not " unless $_ eq "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+print "ok 1\n";
+
+tr/A-Z/a-z/;
+
+print "not " unless $_ eq "abcdefghijklmnopqrstuvwxyz";
+print "ok 2\n";
+
+tr/b-y/B-Y/;
+
+print "not " unless $_ eq "aBCDEFGHIJKLMNOPQRSTUVWXYz";
+print "ok 3\n";
+
+# In EBCDIC 'I' is \xc9 and 'J' is \0xd1, 'i' is \x89 and 'j' is \x91.
+# Yes, discontinuities. Regardless, the \xca in the below should stay
+# untouched (and not became \x8a).
+{
+ no utf8;
+ $_ = "I\xcaJ";
+
+ tr/I-J/i-j/;
+
+ print "not " unless $_ eq "i\xcaj";
+ print "ok 4\n";
+}
+#
diff --git a/t/op/undef.t b/t/op/undef.t
index 8ab2ec421f..8944ee3976 100755
--- a/t/op/undef.t
+++ b/t/op/undef.t
@@ -1,8 +1,11 @@
#!./perl
-# $RCSfile: undef.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:34 $
+BEGIN {
+ chdir 't' if -d 't';
+ unshift @INC, '../lib';
+}
-print "1..21\n";
+print "1..27\n";
print defined($a) ? "not ok 1\n" : "ok 1\n";
@@ -54,3 +57,25 @@ sub foo { print "ok 19\n"; }
print defined &foo ? "ok 20\n" : "not ok 20\n";
undef &foo;
print defined(&foo) ? "not ok 21\n" : "ok 21\n";
+
+eval { undef $1 };
+print $@ =~ /^Modification of a read/ ? "ok 22\n" : "not ok 22\n";
+
+eval { $1 = undef };
+print $@ =~ /^Modification of a read/ ? "ok 23\n" : "not ok 23\n";
+
+{
+ require Tie::Hash;
+ tie my %foo, 'Tie::StdHash';
+ print defined %foo ? "ok 24\n" : "not ok 24\n";
+ %foo = ( a => 1 );
+ print defined %foo ? "ok 25\n" : "not ok 25\n";
+}
+
+{
+ require Tie::Array;
+ tie my @foo, 'Tie::StdArray';
+ print defined @foo ? "ok 26\n" : "not ok 26\n";
+ @foo = ( a => 1 );
+ print defined @foo ? "ok 27\n" : "not ok 27\n";
+}
diff --git a/t/op/universal.t b/t/op/universal.t
index bd6c73afe9..eb6ec3ce97 100755
--- a/t/op/universal.t
+++ b/t/op/universal.t
@@ -5,7 +5,7 @@
BEGIN {
chdir 't' if -d 't';
- @INC = '../lib' if -d '../lib';
+ unshift @INC, '../lib' if -d '../lib';
}
print "1..72\n";
@@ -75,7 +75,11 @@ test ! (eval { $a->VERSION(2.719) }) &&
test (eval { $a->VERSION(2.718) }) && ! $@;
my $subs = join ' ', sort grep { defined &{"UNIVERSAL::$_"} } keys %UNIVERSAL::;
-test $subs eq "VERSION can isa";
+if ('a' lt 'A') {
+ test $subs eq "can isa VERSION";
+} else {
+ test $subs eq "VERSION can isa";
+}
test $a->isa("UNIVERSAL");
@@ -86,7 +90,11 @@ test $a->isa("UNIVERSAL");
my $sub2 = join ' ', sort grep { defined &{"UNIVERSAL::$_"} } keys %UNIVERSAL::;
# XXX import being here is really a bug
-test $sub2 eq "VERSION can import isa";
+if ('a' lt 'A') {
+ test $sub2 eq "can import isa VERSION";
+} else {
+ test $sub2 eq "VERSION can import isa";
+}
eval 'sub UNIVERSAL::sleep {}';
test $a->can("sleep");
diff --git a/t/op/write.t b/t/op/write.t
index 705fa7977b..9918b2f57f 100755
--- a/t/op/write.t
+++ b/t/op/write.t
@@ -2,7 +2,7 @@
# $RCSfile: write.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:38 $
-print "1..5\n";
+print "1..6\n";
my $CAT = ($^O eq 'MSWin32') ? 'type' : 'cat';
@@ -167,3 +167,26 @@ for (0..10) {
print $was1 eq $mustbe ? "ok 4\n" : "not ok 4\n";
print $was2 eq $mustbe ? "ok 5\n" : "not ok 5\n";
+$^A = '';
+
+# more test
+
+format OUT3 =
+^<<<<<<...
+$foo
+.
+
+open(OUT3, '>Op_write.tmp') || die "Can't create Op_write.tmp";
+
+$foo = 'fit ';
+write(OUT3);
+close OUT3;
+
+$right =
+"fit\n";
+
+if (`$CAT Op_write.tmp` eq $right)
+ { print "ok 6\n"; unlink 'Op_write.tmp'; }
+else
+ { print "not ok 6\n"; }
+