In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/bdb2361834f8e3746bc3cfae583d1fe35729f04d?hp=db9306af4ddf47b54fb142041f8f950b1ec18f08>
- Log ----------------------------------------------------------------- commit bdb2361834f8e3746bc3cfae583d1fe35729f04d Merge: 84721e9 db9306a Author: James E Keenan <[email protected]> Date: Thu Nov 29 21:30:47 2012 -0500 Merge branch 'blead' of [email protected]:/perl into blead commit 84721e938609f86051742bdfdd0ffa0d8bbd9337 Author: James E Keenan <[email protected]> Date: Fri Nov 23 14:20:56 2012 -0500 Add descriptions to tests in t/op/arith.t. For: RT #115806 M t/op/arith.t commit 86f5deca8b071976b668a234c58664437e9cbbfa Author: James E Keenan <[email protected]> Date: Thu Nov 29 21:25:07 2012 -0500 t/win32/runenv.t: Correct syntax error reported by bulk88++. Part of: RT #115788 M t/win32/runenv.t commit 39214b38608146a8090dadd637f31607fcaa53b0 Author: James E Keenan <[email protected]> Date: Sat Nov 17 14:08:39 2012 -0600 Add descriptions to tests lacking them. Accomplished programmatically by modifying sub try(). M t/run/runenv.t commit de9564ec3e951401d41e1055b310cf86416e9d7f Author: James E Keenan <[email protected]> Date: Sat Nov 17 12:40:44 2012 -0600 t/run/switchx.t: Add descriptions to tests lacking them. The tests which lacked descriptions are in sample files used by the test file. Better description as suggested by Lukas Mai. For: RT #115782 M t/run/switchx.aux M t/run/switchx2.aux commit c3857f2299e371b08650d7fbe90d20833900fcca Author: James E Keenan <[email protected]> Date: Fri Nov 23 13:18:05 2012 -0500 t/run/switchF1.t: Add descriptions to tests in t/run/switchF1.t. For: RT #115896 M t/run/switchF1.t commit 582764570d49953e2c7a2cc13e1857e0213fe561 Author: James E Keenan <[email protected]> Date: Sat Nov 17 11:10:28 2012 -0600 t/run/script.t: Add descriptions to all tests. Replace hard-coded tests with functions from test.pl. Correct error in calling plan. For: RT #115776 M t/run/script.t commit bae5df401b0cbf50d65f4ef73b579403d21c1d1c Author: James E Keenan <[email protected]> Date: Sat Nov 17 16:08:11 2012 -0600 t/op/args.t: Add descriptions for tests lacking them. In one case, used an inline comment as test description. For: RT #115792 M t/op/args.t commit 6e31dd8854ce2c156d5c83736a23dfcc0225a477 Author: James E Keenan <[email protected]> Date: Sat Nov 17 13:02:19 2012 -0600 t/run/switchd.t: Add descriptions to tests lacking them. For: RT #115784 M t/run/switchd.t commit 12d9438a6794129c7f3d1b679150952b0089a42a Author: James E Keenan <[email protected]> Date: Sat Nov 17 12:30:52 2012 -0600 t/run/switchp.t: Add descriptions to all tests. For: RT #115780 M t/run/switchp.t commit 610466d93b7a7b6e156392aa379874397c53aadf Author: James E Keenan <[email protected]> Date: Sat Nov 17 12:12:06 2012 -0600 t/run/switchI.t: Add descriptions to tests lacking them. This entailed placing the 'grep' in a 'do' block. Trying to add the description without the 'do' block merely added it to the list being grepped -- which prevented the description from being printed. Thanks to Matt Follett and Steve Lembark at St. Louis Perl Hackathon for diagnosis. M t/run/switchI.t ----------------------------------------------------------------------- Summary of changes: t/op/args.t | 33 ++-- t/op/arith.t | 514 ++++++++++++++++++++++++++++------------------------ t/run/runenv.t | 15 +- t/run/script.t | 9 +- t/run/switchF1.t | 12 +- t/run/switchI.t | 5 +- t/run/switchd.t | 12 +- t/run/switchp.t | 6 +- t/run/switchx.aux | 4 +- t/run/switchx2.aux | 4 +- t/win32/runenv.t | 4 +- 11 files changed, 339 insertions(+), 279 deletions(-) diff --git a/t/op/args.t b/t/op/args.t index 02d6352..bfa015e 100644 --- a/t/op/args.t +++ b/t/op/args.t @@ -14,32 +14,32 @@ sub new1 { bless \@_ } { my $x = new1("x"); my $y = new1("y"); - is("@$y","y"); - is("@$x","x"); + is("@$y","y", 'bless'); + is("@$x","x", 'bless'); } sub new2 { splice @_, 0, 0, "a", "b", "c"; return \@_ } { my $x = new2("x"); my $y = new2("y"); - is("@$x","a b c x"); - is("@$y","a b c y"); + is("@$x","a b c x", 'splice'); + is("@$y","a b c y", 'splice'); } sub new3 { goto &new1 } { my $x = new3("x"); my $y = new3("y"); - is("@$y","y"); - is("@$x","x"); + is("@$y","y", 'goto: single element'); + is("@$x","x", 'goto: single element'); } sub new4 { goto &new2 } { my $x = new4("x"); my $y = new4("y"); - is("@$x","a b c x"); - is("@$y","a b c y"); + is("@$x","a b c x", 'goto: multiple elements'); + is("@$y","a b c y", 'goto: multiple elements'); } # see if POPSUB gets to see the right pad across a dounwind() with @@ -54,24 +54,27 @@ sub method { &methimpl; } +my $failcount = 0; sub try { eval { method('foo', 'bar'); }; print "# $@" if $@; + $failcount++; } for (1..5) { try() } -pass(); +is($failcount, 5, + 'POPSUB sees right pad across a dounwind() with reified @_'); # bug #21542 local $_[0] causes reify problems and coredumps sub local1 { local $_[0] } my $foo = 'foo'; local1($foo); local1($foo); -print "got [$foo], expected [foo]\nnot " if $foo ne 'foo'; -pass(); +is($foo, 'foo', + "got 'foo' as expected rather than '\$foo': RT \#21542"); sub local2 { local $_[0]; last L } L: { local2 } -pass(); +pass("last to label"); # the following test for local(@_) used to be in t/op/nothr5005.t (because it # failed with 5005threads) @@ -82,9 +85,9 @@ sub foo { local(@_) = ('p', 'q', 'r'); } sub bar { unshift @_, 'D'; @_ } sub baz { push @_, 'E'; return @_ } for (1..3) { - is(join('',foo('a', 'b', 'c')),'pqr'); - is(join('',bar('d')),'Dd'); - is(join('',baz('e')),'eE'); + is(join('',foo('a', 'b', 'c')),'pqr', 'local @_'); + is(join('',bar('d')),'Dd', 'unshift @_'); + is(join('',baz('e')),'eE', 'push @_'); } # [perl #28032] delete $_[0] was freeing things too early diff --git a/t/op/arith.t b/t/op/arith.t index 8041276..3c91971 100644 --- a/t/op/arith.t +++ b/t/op/arith.t @@ -7,47 +7,53 @@ BEGIN { print "1..167\n"; -sub try ($$) { - print +($_[1] ? "ok" : "not ok"), " $_[0]\n"; +sub try ($$$) { + print +($_[1] ? "ok" : "not ok"), " $_[0] - $_[2]\n"; } -sub tryeq ($$$) { +sub tryeq ($$$$) { if ($_[1] == $_[2]) { - print "ok $_[0]\n"; + print "ok $_[0]"; } else { - print "not ok $_[0] # $_[1] != $_[2]\n"; + print "not ok $_[0] # $_[1] != $_[2]"; } + print " - $_[3]\n"; } -sub tryeq_sloppy ($$$) { +sub tryeq_sloppy ($$$$) { if ($_[1] == $_[2]) { - print "ok $_[0]\n"; + print "ok $_[0]"; } else { my $error = abs (($_[1] - $_[2]) / $_[1]); if ($error < 1e-9) { - print "ok $_[0] # $_[1] is close to $_[2], \$^O eq $^O\n"; + print "ok $_[0] # $_[1] is close to $_[2], \$^O eq $^O"; } else { - print "not ok $_[0] # $_[1] != $_[2]\n"; + print "not ok $_[0] # $_[1] != $_[2]"; } } + print " - $_[3]\n"; } my $T = 1; -tryeq $T++, 13 % 4, 1; -tryeq $T++, -13 % 4, 3; -tryeq $T++, 13 % -4, -3; -tryeq $T++, -13 % -4, -1; +tryeq $T++, 13 % 4, 1, 'modulo: positive positive'; +tryeq $T++, -13 % 4, 3, 'modulo: negative positive'; +tryeq $T++, 13 % -4, -3, 'modulo: positive negative'; +tryeq $T++, -13 % -4, -1, 'modulo: negative negative'; # Give abs() a good work-out before using it in anger -tryeq $T++, abs(0), 0; -tryeq $T++, abs(1), 1; -tryeq $T++, abs(-1), 1; -tryeq $T++, abs(2147483647), 2147483647; -tryeq $T++, abs(-2147483647), 2147483647; -tryeq $T++, abs(4294967295), 4294967295; -tryeq $T++, abs(-4294967295), 4294967295; -tryeq $T++, abs(9223372036854775807), 9223372036854775807; -tryeq $T++, abs(-9223372036854775807), 9223372036854775807; -tryeq $T++, abs(1e50), 1e50; # Assume no change whatever; no slop needed -tryeq $T++, abs(-1e50), 1e50; # Assume only sign bit flipped +tryeq $T++, abs(0), 0, 'abs(): 0 0'; +tryeq $T++, abs(1), 1, 'abs(): 1 1'; +tryeq $T++, abs(-1), 1, 'abs(): -1 1'; +tryeq $T++, abs(2147483647), 2147483647, 'abs(): 2**31-1: pos pos'; +tryeq $T++, abs(-2147483647), 2147483647, 'abs(): 2**31-1: neg pos'; +tryeq $T++, abs(4294967295), 4294967295, 'abs(): 2**32-1: pos pos'; +tryeq $T++, abs(-4294967295), 4294967295, 'abs(): 2**32-1: neg pos'; +tryeq $T++, abs(9223372036854775807), 9223372036854775807, + 'abs(): 2**63-1: pos pos'; +tryeq $T++, abs(-9223372036854775807), 9223372036854775807, + 'abs(): 2**63-1: neg pos'; +# Assume no change whatever; no slop needed +tryeq $T++, abs(1e50), 1e50, 'abs(): 1e50: pos pos'; +# Assume only sign bit flipped +tryeq $T++, abs(-1e50), 1e50, 'abs(): 1e50: neg pos'; my $limit = 1e6; @@ -55,220 +61,252 @@ my $limit = 1e6; # seem to be rather sloppy in Cray. $limit = 1e8 if $^O eq 'unicos'; -try $T++, abs( 13e21 % 4e21 - 1e21) < $limit; -try $T++, abs(-13e21 % 4e21 - 3e21) < $limit; -try $T++, abs( 13e21 % -4e21 - -3e21) < $limit; -try $T++, abs(-13e21 % -4e21 - -1e21) < $limit; - -# UVs should behave properly - -tryeq $T++, 4063328477 % 65535, 27407; -tryeq $T++, 4063328477 % 4063328476, 1; -tryeq $T++, 4063328477 % 2031664238, 1; -tryeq $T++, 2031664238 % 4063328477, 2031664238; - -# These should trigger wrapping on 32 bit IVs and UVs - -tryeq $T++, 2147483647 + 0, 2147483647; - -# IV + IV promote to UV -tryeq $T++, 2147483647 + 1, 2147483648; -tryeq $T++, 2147483640 + 10, 2147483650; -tryeq $T++, 2147483647 + 2147483647, 4294967294; -# IV + UV promote to NV -tryeq $T++, 2147483647 + 2147483649, 4294967296; -# UV + IV promote to NV -tryeq $T++, 4294967294 + 2, 4294967296; -# UV + UV promote to NV -tryeq $T++, 4294967295 + 4294967295, 8589934590; - -# UV + IV to IV -tryeq $T++, 2147483648 + -1, 2147483647; -tryeq $T++, 2147483650 + -10, 2147483640; -# IV + UV to IV -tryeq $T++, -1 + 2147483648, 2147483647; -tryeq $T++, -10 + 4294967294, 4294967284; -# IV + IV to NV -tryeq $T++, -2147483648 + -2147483648, -4294967296; -tryeq $T++, -2147483640 + -10, -2147483650; - -# Hmm. Don't forget the simple stuff -tryeq $T++, 1 + 1, 2; -tryeq $T++, 4 + -2, 2; -tryeq $T++, -10 + 100, 90; -tryeq $T++, -7 + -9, -16; -tryeq $T++, -63 + +2, -61; -tryeq $T++, 4 + -1, 3; -tryeq $T++, -1 + 1, 0; -tryeq $T++, +29 + -29, 0; -tryeq $T++, -1 + 4, 3; -tryeq $T++, +4 + -17, -13; +try $T++, abs( 13e21 % 4e21 - 1e21) < $limit, 'abs() for floating point'; +try $T++, abs(-13e21 % 4e21 - 3e21) < $limit, 'abs() for floating point'; +try $T++, abs( 13e21 % -4e21 - -3e21) < $limit, 'abs() for floating point'; +try $T++, abs(-13e21 % -4e21 - -1e21) < $limit, 'abs() for floating point'; + +tryeq $T++, 4063328477 % 65535, 27407, 'UV behaves properly: modulo'; +tryeq $T++, 4063328477 % 4063328476, 1, 'UV behaves properly: modulo'; +tryeq $T++, 4063328477 % 2031664238, 1, 'UV behaves properly: modulo'; +tryeq $T++, 2031664238 % 4063328477, 2031664238, + 'UV behaves properly: modulo'; + +tryeq $T++, 2147483647 + 0, 2147483647, + 'trigger wrapping on 32 bit IVs and UVs'; + +tryeq $T++, 2147483647 + 1, 2147483648, 'IV + IV promotes to UV'; +tryeq $T++, 2147483640 + 10, 2147483650, 'IV + IV promotes to UV'; +tryeq $T++, 2147483647 + 2147483647, 4294967294, 'IV + IV promotes to UV'; +tryeq $T++, 2147483647 + 2147483649, 4294967296, 'IV + UV promotes to NV'; +tryeq $T++, 4294967294 + 2, 4294967296, 'UV + IV promotes to NV'; +tryeq $T++, 4294967295 + 4294967295, 8589934590, 'UV + UV promotes to NV'; + +tryeq $T++, 2147483648 + -1, 2147483647, 'UV + IV promotes to IV'; +tryeq $T++, 2147483650 + -10, 2147483640, 'UV + IV promotes to IV'; +tryeq $T++, -1 + 2147483648, 2147483647, 'IV + UV promotes to IV'; +tryeq $T++, -10 + 4294967294, 4294967284, 'IV + UV promotes to IV'; +tryeq $T++, -2147483648 + -2147483648, -4294967296, 'IV + IV promotes to NV'; +tryeq $T++, -2147483640 + -10, -2147483650, 'IV + IV promotes to NV'; + +# Hmm. Do not forget the simple stuff +# addition +tryeq $T++, 1 + 1, 2, 'addition of 2 positive integers'; +tryeq $T++, 4 + -2, 2, 'addition of positive and negative integer'; +tryeq $T++, -10 + 100, 90, 'addition of negative and positive integer'; +tryeq $T++, -7 + -9, -16, 'addition of 2 negative integers'; +tryeq $T++, -63 + +2, -61, 'addition of signed negative and positive integers'; +tryeq $T++, 4 + -1, 3, 'addition of positive and negative integer'; +tryeq $T++, -1 + 1, 0, 'addition which sums to 0'; +tryeq $T++, +29 + -29, 0, 'addition which sums to 0'; +tryeq $T++, -1 + 4, 3, 'addition of signed negative and positive integers'; +tryeq $T++, +4 + -17, -13, 'addition of signed positive and negative integers'; # subtraction -tryeq $T++, 3 - 1, 2; -tryeq $T++, 3 - 15, -12; -tryeq $T++, 3 - -7, 10; -tryeq $T++, -156 - 5, -161; -tryeq $T++, -156 - -5, -151; -tryeq $T++, -5 - -12, 7; -tryeq $T++, -3 - -3, 0; -tryeq $T++, 15 - 15, 0; - -tryeq $T++, 2147483647 - 0, 2147483647; -tryeq $T++, 2147483648 - 0, 2147483648; -tryeq $T++, -2147483648 - 0, -2147483648; - -tryeq $T++, 0 - -2147483647, 2147483647; -tryeq $T++, -1 - -2147483648, 2147483647; -tryeq $T++, 2 - -2147483648, 2147483650; - -tryeq $T++, 4294967294 - 3, 4294967291; -tryeq $T++, -2147483648 - -1, -2147483647; - -# IV - IV promote to UV -tryeq $T++, 2147483647 - -1, 2147483648; -tryeq $T++, 2147483647 - -2147483648, 4294967295; -# UV - IV promote to NV -tryeq $T++, 4294967294 - -3, 4294967297; -# IV - IV promote to NV -tryeq $T++, -2147483648 - +1, -2147483649; -# UV - UV promote to IV -tryeq $T++, 2147483648 - 2147483650, -2; -# IV - UV promote to IV -tryeq $T++, 2000000000 - 4000000000, -2000000000; +tryeq $T++, 3 - 1, 2, 'subtraction of two positive integers'; +tryeq $T++, 3 - 15, -12, + 'subtraction of two positive integers: minuend smaller'; +tryeq $T++, 3 - -7, 10, 'subtraction of positive and negative integer'; +tryeq $T++, -156 - 5, -161, 'subtraction of negative and positive integer'; +tryeq $T++, -156 - -5, -151, 'subtraction of two negative integers'; +tryeq $T++, -5 - -12, 7, + 'subtraction of two negative integers: minuend smaller'; +tryeq $T++, -3 - -3, 0, 'subtraction of two negative integers with result of 0'; +tryeq $T++, 15 - 15, 0, 'subtraction of two positive integers with result of 0'; +tryeq $T++, 2147483647 - 0, 2147483647, 'subtraction from large integer'; +tryeq $T++, 2147483648 - 0, 2147483648, 'subtraction from large integer'; +tryeq $T++, -2147483648 - 0, -2147483648, + 'subtraction from large negative integer'; +tryeq $T++, 0 - -2147483647, 2147483647, + 'subtraction of large negative integer from 0'; +tryeq $T++, -1 - -2147483648, 2147483647, + 'subtraction of large negative integer from negative integer'; +tryeq $T++, 2 - -2147483648, 2147483650, + 'subtraction of large negative integer from positive integer'; +tryeq $T++, 4294967294 - 3, 4294967291, 'subtraction from large integer'; +tryeq $T++, -2147483648 - -1, -2147483647, + 'subtraction from large negative integer'; +tryeq $T++, 2147483647 - -1, 2147483648, 'IV - IV promote to UV'; +tryeq $T++, 2147483647 - -2147483648, 4294967295, 'IV - IV promote to UV'; +tryeq $T++, 4294967294 - -3, 4294967297, 'UV - IV promote to NV'; +tryeq $T++, -2147483648 - +1, -2147483649, 'IV - IV promote to NV'; +tryeq $T++, 2147483648 - 2147483650, -2, 'UV - UV promote to IV'; +tryeq $T++, 2000000000 - 4000000000, -2000000000, 'IV - UV promote to IV'; # No warnings should appear; my $a; $a += 1; -tryeq $T++, $a, 1; +tryeq $T++, $a, 1, '+= with positive'; undef $a; $a += -1; -tryeq $T++, $a, -1; +tryeq $T++, $a, -1, '+= with negative'; undef $a; $a += 4294967290; -tryeq $T++, $a, 4294967290; +tryeq $T++, $a, 4294967290, '+= with positive'; undef $a; $a += -4294967290; -tryeq $T++, $a, -4294967290; +tryeq $T++, $a, -4294967290, '+= with negative'; undef $a; $a += 4294967297; -tryeq $T++, $a, 4294967297; +tryeq $T++, $a, 4294967297, '+= with positive'; undef $a; $a += -4294967297; -tryeq $T++, $a, -4294967297; +tryeq $T++, $a, -4294967297, '+= with negative'; my $s; $s -= 1; -tryeq $T++, $s, -1; +tryeq $T++, $s, -1, '-= with positive'; undef $s; $s -= -1; -tryeq $T++, $s, +1; +tryeq $T++, $s, +1, '-= with negative'; undef $s; $s -= -4294967290; -tryeq $T++, $s, +4294967290; +tryeq $T++, $s, +4294967290, '-= with negative'; undef $s; $s -= 4294967290; -tryeq $T++, $s, -4294967290; +tryeq $T++, $s, -4294967290, '-= with negative'; undef $s; $s -= 4294967297; -tryeq $T++, $s, -4294967297; +tryeq $T++, $s, -4294967297, '-= with positive'; undef $s; $s -= -4294967297; -tryeq $T++, $s, +4294967297; +tryeq $T++, $s, +4294967297, '-= with positive'; -# Multiplication - -tryeq $T++, 1 * 3, 3; -tryeq $T++, -2 * 3, -6; -tryeq $T++, 3 * -3, -9; -tryeq $T++, -4 * -3, 12; +# multiplication +tryeq $T++, 1 * 3, 3, 'multiplication of two positive integers'; +tryeq $T++, -2 * 3, -6, 'multiplication of negative and positive integer'; +tryeq $T++, 3 * -3, -9, 'multiplication of positive and negative integer'; +tryeq $T++, -4 * -3, 12, 'multiplication of two negative integers'; # check with 0xFFFF and 0xFFFF -tryeq $T++, 65535 * 65535, 4294836225; -tryeq $T++, 65535 * -65535, -4294836225; -tryeq $T++, -65535 * 65535, -4294836225; -tryeq $T++, -65535 * -65535, 4294836225; +tryeq $T++, 65535 * 65535, 4294836225, + 'multiplication: 0xFFFF and 0xFFFF: pos pos'; +tryeq $T++, 65535 * -65535, -4294836225, + 'multiplication: 0xFFFF and 0xFFFF: pos neg'; +tryeq $T++, -65535 * 65535, -4294836225, + 'multiplication: 0xFFFF and 0xFFFF: pos neg'; +tryeq $T++, -65535 * -65535, 4294836225, + 'multiplication: 0xFFFF and 0xFFFF: neg neg'; # check with 0xFFFF and 0x10001 -tryeq $T++, 65535 * 65537, 4294967295; -tryeq $T++, 65535 * -65537, -4294967295; -tryeq $T++, -65535 * 65537, -4294967295; -tryeq $T++, -65535 * -65537, 4294967295; +tryeq $T++, 65535 * 65537, 4294967295, + 'multiplication: 0xFFFF and 0x10001: pos pos'; +tryeq $T++, 65535 * -65537, -4294967295, + 'multiplication: 0xFFFF and 0x10001: pos neg'; +tryeq $T++, -65535 * 65537, -4294967295, + 'multiplication: 0xFFFF and 0x10001: neg pos'; +tryeq $T++, -65535 * -65537, 4294967295, + 'multiplication: 0xFFFF and 0x10001: neg neg'; # check with 0x10001 and 0xFFFF -tryeq $T++, 65537 * 65535, 4294967295; -tryeq $T++, 65537 * -65535, -4294967295; -tryeq $T++, -65537 * 65535, -4294967295; -tryeq $T++, -65537 * -65535, 4294967295; +tryeq $T++, 65537 * 65535, 4294967295, + 'multiplication: 0x10001 and 0xFFFF: pos pos'; +tryeq $T++, 65537 * -65535, -4294967295, + 'multiplication: 0x10001 and 0xFFFF: pos neg'; +tryeq $T++, -65537 * 65535, -4294967295, + 'multiplication: 0x10001 and 0xFFFF: neg pos'; +tryeq $T++, -65537 * -65535, 4294967295, + 'multiplication: 0x10001 and 0xFFFF: neg neg'; # These should all be dones as NVs -tryeq $T++, 65537 * 65537, 4295098369; -tryeq $T++, 65537 * -65537, -4295098369; -tryeq $T++, -65537 * 65537, -4295098369; -tryeq $T++, -65537 * -65537, 4295098369; +tryeq $T++, 65537 * 65537, 4295098369, 'multiplication: NV: pos pos'; +tryeq $T++, 65537 * -65537, -4295098369, 'multiplication: NV: pos neg'; +tryeq $T++, -65537 * 65537, -4295098369, 'multiplication: NV: neg pos'; +tryeq $T++, -65537 * -65537, 4295098369, 'multiplication: NV: neg neg'; # will overflow an IV (in 32-bit) -tryeq $T++, 46340 * 46342, 0x80001218; -tryeq $T++, 46340 * -46342, -0x80001218; -tryeq $T++, -46340 * 46342, -0x80001218; -tryeq $T++, -46340 * -46342, 0x80001218; - -tryeq $T++, 46342 * 46340, 0x80001218; -tryeq $T++, 46342 * -46340, -0x80001218; -tryeq $T++, -46342 * 46340, -0x80001218; -tryeq $T++, -46342 * -46340, 0x80001218; +tryeq $T++, 46340 * 46342, 0x80001218, + 'multiplication: overflow an IV in 32-bit: pos pos'; +tryeq $T++, 46340 * -46342, -0x80001218, + 'multiplication: overflow an IV in 32-bit: pos neg'; +tryeq $T++, -46340 * 46342, -0x80001218, + 'multiplication: overflow an IV in 32-bit: neg pos'; +tryeq $T++, -46340 * -46342, 0x80001218, + 'multiplication: overflow an IV in 32-bit: neg neg'; + +tryeq $T++, 46342 * 46340, 0x80001218, + 'multiplication: overflow an IV in 32-bit: pos pos'; +tryeq $T++, 46342 * -46340, -0x80001218, + 'multiplication: overflow an IV in 32-bit: pos neg'; +tryeq $T++, -46342 * 46340, -0x80001218, + 'multiplication: overflow an IV in 32-bit: neg pos'; +tryeq $T++, -46342 * -46340, 0x80001218, + 'multiplication: overflow an IV in 32-bit: neg neg'; # will overflow a positive IV (in 32-bit) -tryeq $T++, 65536 * 32768, 0x80000000; -tryeq $T++, 65536 * -32768, -0x80000000; -tryeq $T++, -65536 * 32768, -0x80000000; -tryeq $T++, -65536 * -32768, 0x80000000; - -tryeq $T++, 32768 * 65536, 0x80000000; -tryeq $T++, 32768 * -65536, -0x80000000; -tryeq $T++, -32768 * 65536, -0x80000000; -tryeq $T++, -32768 * -65536, 0x80000000; +tryeq $T++, 65536 * 32768, 0x80000000, + 'multiplication: overflow a positive IV in 32-bit: pos pos'; +tryeq $T++, 65536 * -32768, -0x80000000, + 'multiplication: overflow a positive IV in 32-bit: pos neg'; +tryeq $T++, -65536 * 32768, -0x80000000, + 'multiplication: overflow a positive IV in 32-bit: neg pos'; +tryeq $T++, -65536 * -32768, 0x80000000, + 'multiplication: overflow a positive IV in 32-bit: neg neg'; + +tryeq $T++, 32768 * 65536, 0x80000000, + 'multiplication: overflow a positive IV in 32-bit: pos pos'; +tryeq $T++, 32768 * -65536, -0x80000000, + 'multiplication: overflow a positive IV in 32-bit: pos neg'; +tryeq $T++, -32768 * 65536, -0x80000000, + 'multiplication: overflow a positive IV in 32-bit: neg pos'; +tryeq $T++, -32768 * -65536, 0x80000000, + 'multiplication: overflow a positive IV in 32-bit: neg neg'; # 2147483647 is prime. bah. -tryeq $T++, 46339 * 46341, 0x7ffea80f; -tryeq $T++, 46339 * -46341, -0x7ffea80f; -tryeq $T++, -46339 * 46341, -0x7ffea80f; -tryeq $T++, -46339 * -46341, 0x7ffea80f; +tryeq $T++, 46339 * 46341, 0x7ffea80f, + 'multiplication: hex product: pos pos'; +tryeq $T++, 46339 * -46341, -0x7ffea80f, + 'multiplication: hex product: pos neg'; +tryeq $T++, -46339 * 46341, -0x7ffea80f, + 'multiplication: hex product: neg pos'; +tryeq $T++, -46339 * -46341, 0x7ffea80f, + 'multiplication: hex product: neg neg'; # leading space should be ignored -tryeq $T++, 1 + " 1", 2; -tryeq $T++, 3 + " -1", 2; -tryeq $T++, 1.2, " 1.2"; -tryeq $T++, -1.2, " -1.2"; - -# divide - -tryeq $T++, 28/14, 2; -tryeq $T++, 28/-7, -4; -tryeq $T++, -28/4, -7; -tryeq $T++, -28/-2, 14; - -tryeq $T++, 0x80000000/1, 0x80000000; -tryeq $T++, 0x80000000/-1, -0x80000000; -tryeq $T++, -0x80000000/1, -0x80000000; -tryeq $T++, -0x80000000/-1, 0x80000000; +tryeq $T++, 1 + " 1", 2, 'ignore leading space: addition'; +tryeq $T++, 3 + " -1", 2, 'ignore leading space: subtraction'; +tryeq $T++, 1.2, " 1.2", 'floating point and string equivalent: positive'; +tryeq $T++, -1.2, " -1.2", 'floating point and string equivalent: negative'; + +# division +tryeq $T++, 28/14, 2, 'division of two positive integers'; +tryeq $T++, 28/-7, -4, 'division of positive integer by negative'; +tryeq $T++, -28/4, -7, 'division of negative integer by positive'; +tryeq $T++, -28/-2, 14, 'division of negative integer by negative'; + +tryeq $T++, 0x80000000/1, 0x80000000, + 'division of positive hex by positive integer'; +tryeq $T++, 0x80000000/-1, -0x80000000, + 'division of positive hex by negative integer'; +tryeq $T++, -0x80000000/1, -0x80000000, + 'division of negative hex by negative integer'; +tryeq $T++, -0x80000000/-1, 0x80000000, + 'division of negative hex by positive integer'; # The example for sloppy divide, rigged to avoid the peephole optimiser. -tryeq_sloppy $T++, "20." / "5.", 4; - -tryeq $T++, 2.5 / 2, 1.25; -tryeq $T++, 3.5 / -2, -1.75; -tryeq $T++, -4.5 / 2, -2.25; -tryeq $T++, -5.5 / -2, 2.75; - -# Bluuurg if your floating point can't accurately cope with powers of 2 +tryeq_sloppy $T++, "20." / "5.", 4, 'division of floating point without fractional part'; + +tryeq $T++, 2.5 / 2, 1.25, + 'division of positive floating point by positive integer'; +tryeq $T++, 3.5 / -2, -1.75, + 'division of positive floating point by negative integer'; +tryeq $T++, -4.5 / 2, -2.25, + 'division of negative floating point by positive integer'; +tryeq $T++, -5.5 / -2, 2.75, + 'division of negative floating point by negative integer'; + +# Bluuurg if your floating point can not accurately cope with powers of 2 # [I suspect this is parsing string->float problems, not actual arith] -tryeq_sloppy $T++, 18446744073709551616/1, 18446744073709551616; # Bluuurg -tryeq_sloppy $T++, 18446744073709551616/2, 9223372036854775808; -tryeq_sloppy $T++, 18446744073709551616/4294967296, 4294967296; -tryeq_sloppy $T++, 18446744073709551616/9223372036854775808, 2; +tryeq_sloppy $T++, 18446744073709551616/1, 18446744073709551616, + 'division of very large number by 1'; # Bluuurg +tryeq_sloppy $T++, 18446744073709551616/2, 9223372036854775808, + 'division of very large number by 2'; +tryeq_sloppy $T++, 18446744073709551616/4294967296, 4294967296, + 'division of two very large numbers'; +tryeq_sloppy $T++, 18446744073709551616/9223372036854775808, 2, + 'division of two very large numbers'; { # The peephole optimiser is wrong to think that it can substitute intops @@ -277,27 +315,27 @@ tryeq_sloppy $T++, 18446744073709551616/9223372036854775808, 2; my $n = 1127; my $float = ($n % 1000) * 167772160.0; - tryeq_sloppy $T++, $float, 21307064320; + tryeq_sloppy $T++, $float, 21307064320, 'integer times floating point'; # On a 32 bit machine, if the i_multiply op is used, you will probably get - # -167772160. It's actually undefined behaviour, so anything may happen. + # -167772160. It is actually undefined behaviour, so anything may happen. my $int = ($n % 1000) * 167772160; - tryeq $T++, $int, 21307064320; + tryeq $T++, $int, 21307064320, 'integer times integer'; my $float2 = ($n % 1000 + 0.0) * 167772160; - tryeq $T++, $float2, 21307064320; + tryeq $T++, $float2, 21307064320, 'floating point times integer'; my $int2 = ($n % 1000 + 0) * 167772160; - tryeq $T++, $int2, 21307064320; + tryeq $T++, $int2, 21307064320, 'integer plus zero times integer'; # zero, but in a way that ought to be able to defeat any future optimizer: my $zero = $$ - $$; my $int3 = ($n % 1000 + $zero) * 167772160; - tryeq $T++, $int3, 21307064320; + tryeq $T++, $int3, 21307064320, 'defeat any future optimizer'; my $t = time; my $t1000 = time() * 1000; - try $T++, abs($t1000 -1000 * $t) <= 2000; + try $T++, abs($t1000 -1000 * $t) <= 2000, 'absolute value'; } { @@ -305,57 +343,26 @@ tryeq_sloppy $T++, 18446744073709551616/9223372036854775808, 2; my $n = 1127; my $float = ($n % 1000) * 720575940379279360.0; - tryeq_sloppy $T++, $float, 9.15131444281685e+19; + tryeq_sloppy $T++, $float, 9.15131444281685e+19, + '64 bit: integer times floating point'; my $int = ($n % 1000) * 720575940379279360; - tryeq_sloppy $T++, $int, 9.15131444281685e+19; + tryeq_sloppy $T++, $int, 9.15131444281685e+19, + '64 bit: integer times integer'; my $float2 = ($n % 1000 + 0.0) * 720575940379279360; - tryeq_sloppy $T++, $float2, 9.15131444281685e+19; + tryeq_sloppy $T++, $float2, 9.15131444281685e+19, + '64 bit: floating point times integer'; my $int2 = ($n % 1000 + 0) * 720575940379279360; - tryeq_sloppy $T++, $int2, 9.15131444281685e+19; + tryeq_sloppy $T++, $int2, 9.15131444281685e+19, + '64 bit: integer plus zero times integer'; # zero, but in a way that ought to be able to defeat any future optimizer: my $zero = $$ - $$; my $int3 = ($n % 1000 + $zero) * 720575940379279360; - tryeq_sloppy $T++, $int3, 9.15131444281685e+19; -} - -my $vms_no_ieee; -if ($^O eq 'VMS') { - use vars '%Config'; - eval {require Config; import Config}; - $vms_no_ieee = 1 unless defined($Config{useieee}); -} - -if ($^O eq 'vos') { - print "not ok ", $T++, " # TODO VOS raises SIGFPE instead of producing infinity.\n"; -} -elsif ($vms_no_ieee) { - print $T++, " # SKIP -- the IEEE infinity model is unavailable in this configuration.\n" -} -elsif ($^O eq 'ultrix') { - print "not ok ", $T++, " # TODO Ultrix enters deep nirvana instead of producing infinity.\n"; -} -else { - # The computation of $v should overflow and produce "infinity" - # on any system whose max exponent is less than 10**1506. - # The exact string used to represent infinity varies by OS, - # so we don't test for it; all we care is that we don't die. - # - # Perl considers it to be an error if SIGFPE is raised. - # Chances are the interpreter will die, since it doesn't set - # up a handler for SIGFPE. That's why this test is last; to - # minimize the number of test failures. --PG - - my $n = 5000; - my $v = 2; - while (--$n) - { - $v *= 2; - } - print "ok ", $T++, "\n"; + tryeq_sloppy $T++, $int3, 9.15131444281685e+19, + '64 bit: defeat any future optimizer'; } # [perl #109542] $1 and "$1" should be treated the same way @@ -408,3 +415,40 @@ print "not "x($a ne $b), "ok ", $T++, qq ' - \$1 vs "\$1" % something\n'; $a = (97656250000000000 % $1); $b = (97656250000000000 % "$1"); print "not "x($a ne $b), "ok ", $T++, qq ' - something % \$1 vs "\$1"\n'; + +my $vms_no_ieee; +if ($^O eq 'VMS') { + use vars '%Config'; + eval {require Config; import Config}; + $vms_no_ieee = 1 unless defined($Config{useieee}); +} + +if ($^O eq 'vos') { + print "not ok ", $T++, " # TODO VOS raises SIGFPE instead of producing infinity.\n"; +} +elsif ($vms_no_ieee) { + print $T++, " # SKIP -- the IEEE infinity model is unavailable in this configuration.\n" +} +elsif ($^O eq 'ultrix') { + print "not ok ", $T++, " # TODO Ultrix enters deep nirvana instead of producing infinity.\n"; +} +else { + # The computation of $v should overflow and produce "infinity" + # on any system whose max exponent is less than 10**1506. + # The exact string used to represent infinity varies by OS, + # so we don't test for it; all we care is that we don't die. + # + # Perl considers it to be an error if SIGFPE is raised. + # Chances are the interpreter will die, since it doesn't set + # up a handler for SIGFPE. That's why this test is last; to + # minimize the number of test failures. --PG + + my $n = 5000; + my $v = 2; + while (--$n) + { + $v *= 2; + } + print "ok ", $T++, " - infinity\n"; +} + diff --git a/t/run/runenv.t b/t/run/runenv.t index 521ba8b..a52b5ee 100644 --- a/t/run/runenv.t +++ b/t/run/runenv.t @@ -53,7 +53,7 @@ sub runperl_and_capture { } open STDOUT, '>', $STDOUT or exit $FAILURE_CODE; open STDERR, '>', $STDERR and do { exec $PERL, @$args }; - # it didn't_work: + # it did not work: print STDOUT "IWHCWJIHCI\cNHJWCJQWKJQJWCQW\n"; exit $FAILURE_CODE; } @@ -63,15 +63,20 @@ sub try { my ($env, $args, $stdout, $stderr) = @_; my ($actual_stdout, $actual_stderr) = runperl_and_capture($env, $args); local $::Level = $::Level + 1; + my @envpairs = (); + for my $k (sort keys %$env) { + push @envpairs, "$k => $env->{$k}"; + } + my $label = join(',' => (@envpairs, @$args)); if (ref $stdout) { - ok ( $actual_stdout =~/$stdout/ ); + ok ( $actual_stdout =~/$stdout/, $label . ' stdout' ); } else { - is ($stdout, $actual_stdout); + is ( $actual_stdout, $stdout, $label . ' stdout' ); } if (ref $stderr) { - ok ( $actual_stderr =~/$stderr/); + ok ( $actual_stderr =~/$stderr/, $label . ' stderr' ); } else { - is ($stderr, $actual_stderr); + is ( $actual_stderr, $stderr, $label . ' stderr' ); } } diff --git a/t/run/script.t b/t/run/script.t index 83d733a..2553e00 100644 --- a/t/run/script.t +++ b/t/run/script.t @@ -4,17 +4,16 @@ BEGIN { chdir 't'; @INC = '../lib'; require './test.pl'; # for which_perl() etc + plan(3); } my $Perl = which_perl(); my $filename = tempfile(); -print "1..3\n"; - $x = `$Perl -le "print 'ok';"`; -if ($x eq "ok\n") {print "ok 1\n";} else {print "not ok 1\n";} +is($x, "ok\n", "Got expected 'perl -le' output"); open(try,">$filename") || (die "Can't open temp file."); print try 'print "ok\n";'; print try "\n"; @@ -22,8 +21,8 @@ close try or die "Could not close: $!"; $x = `$Perl $filename`; -if ($x eq "ok\n") {print "ok 2\n";} else {print "not ok 2\n";} +is($x, "ok\n", "Got expected output of command from script"); $x = `$Perl <$filename`; -if ($x eq "ok\n") {print "ok 3\n";} else {print "not ok 3\n";} +is($x, "ok\n", "Got expected output of command read from script"); diff --git a/t/run/switchF1.t b/t/run/switchF1.t index f94c159..b781a3b 100644 --- a/t/run/switchF1.t +++ b/t/run/switchF1.t @@ -14,10 +14,10 @@ BEGIN { print "@F"; __DATA__ -okx1 -okq2 -ok\3 -ok'4 +okx1x- use of alternate delimiter (lower case letter) in -F +okq2q- use of alternate delimiter (lower case letter) in -F +ok\3\- use of alternate delimiter (backslash) in -F +ok'4'- use of alternate delimiter (apostrophe) in -F EOT # 2 of the characters toke.c used to use to quote the split parameter: @@ -26,6 +26,8 @@ $prog =~ s/QQ/\x01\x80/; print F $prog; close F or die "Close $file: $!"; -print system ($^X, $file) ? "not ok 5\n" : "ok 5\n"; +$count = 5; +$result = "ok $count - complete test of alternate delimiters in -F\n"; +print system ($^X, $file) ? "not $result" : $result; unlink $file or die "Unlink $file: $!"; diff --git a/t/run/switchI.t b/t/run/switchI.t index 27f78a6..7fb222b 100644 --- a/t/run/switchI.t +++ b/t/run/switchI.t @@ -11,11 +11,12 @@ my $Is_VMS = $^O eq 'VMS'; my $lib; $lib = 'Bla'; -ok(grep { $_ eq $lib } @INC[0..($#INC-1)]); +ok do { grep { $_ eq $lib } @INC[0..($#INC-1)] }, 'Identified entry in @INC'; SKIP: { skip 'Double colons not allowed in dir spec', 1 if $Is_VMS; $lib = 'Foo::Bar'; - ok(grep { $_ eq $lib } @INC[0..($#INC-1)]); + ok do { grep { $_ eq $lib } @INC[0..($#INC-1)] }, + 'Identified entry in @INC with double colons'; } $lib = 'Bla2'; diff --git a/t/run/switchd.t b/t/run/switchd.t index d2a56bb..4334262 100644 --- a/t/run/switchd.t +++ b/t/run/switchd.t @@ -35,19 +35,25 @@ __SWDTEST__ progfile => $filename, args => ['3'], ); - like($r, qr/^sub<Devel::switchd::import>;import<Devel::switchd>;DB<main,$::tempfile_regexp,9>;sub<Foo::foo>;DB<Foo,$::tempfile_regexp,5>;DB<Foo,$::tempfile_regexp,6>;sub<Bar::bar>;DB<Bar,$::tempf ... [104 chars truncated] + like($r, +qr/^sub<Devel::switchd::import>;import<Devel::switchd>;DB<main,$::tempfile_regexp,9>;sub<Foo::foo>;DB<Foo,$::tempfile_regexp,5>;DB<Foo,$::tempfile_regexp,6>;sub<Bar::bar>;DB<Bar,$::tempfile_regexp,2> ... [90 chars truncated] + 'Got debugging output: 1'); $r = runperl( switches => [ '-Ilib', '-f', '-d:switchd=a,42' ], progfile => $filename, args => ['4'], ); - like($r, qr/^sub<Devel::switchd::import>;import<Devel::switchd a 42>;DB<main,$::tempfile_regexp,9>;sub<Foo::foo>;DB<Foo,$::tempfile_regexp,5>;DB<Foo,$::tempfile_regexp,6>;sub<Bar::bar>;DB<Bar,$:: ... [109 chars truncated] + like($r, +qr/^sub<Devel::switchd::import>;import<Devel::switchd a 42>;DB<main,$::tempfile_regexp,9>;sub<Foo::foo>;DB<Foo,$::tempfile_regexp,5>;DB<Foo,$::tempfile_regexp,6>;sub<Bar::bar>;DB<Bar,$::tempfile_rege ... [95 chars truncated] + 'Got debugging output: 2'); $r = runperl( switches => [ '-Ilib', '-f', '-d:-switchd=a,42' ], progfile => $filename, args => ['4'], ); - like($r, qr/^sub<Devel::switchd::unimport>;unimport<Devel::switchd a 42>;DB<main,$::tempfile_regexp,9>;sub<Foo::foo>;DB<Foo,$::tempfile_regexp,5>;DB<Foo,$::tempfile_regexp,6>;sub<Bar::bar>;DB<Bar ... [113 chars truncated] + like($r, +qr/^sub<Devel::switchd::unimport>;unimport<Devel::switchd a 42>;DB<main,$::tempfile_regexp,9>;sub<Foo::foo>;DB<Foo,$::tempfile_regexp,5>;DB<Foo,$::tempfile_regexp,6>;sub<Bar::bar>;DB<Bar,$::tempfile_ ... [99 chars truncated] + 'Got debugging output: 3'); } # [perl #71806] diff --git a/t/run/switchp.t b/t/run/switchp.t index 1d1fe14..c92e973 100644 --- a/t/run/switchp.t +++ b/t/run/switchp.t @@ -6,11 +6,11 @@ BEGIN { } END { - print "ok 3\n"; + print "ok 3 - -p switch tested\n"; } s/^not //; __DATA__ -not ok 1 -not ok 2 +not ok 1 - -p switch first iteration +not ok 2 - -p switch second iteration diff --git a/t/run/switchx.aux b/t/run/switchx.aux index 0db6103..b59df4a 100644 --- a/t/run/switchx.aux +++ b/t/run/switchx.aux @@ -19,9 +19,9 @@ still not perl print "1..7"; if (-f 'run/switchx.aux') { - print "ok 1"; + print "ok 1 - Test file exists"; } -print "ok 2"; +print "ok 2 - Test file utilized"; # other tests are in switchx2.aux __END__ diff --git a/t/run/switchx2.aux b/t/run/switchx2.aux index c1fb6ee..6d54a2d 100644 --- a/t/run/switchx2.aux +++ b/t/run/switchx2.aux @@ -21,10 +21,10 @@ if [[ -z $FOO ]]; then echo 'not ok 1'; fi # These lines get executed my $test = $ARGV[0]; if (-f 'switchx.t') { - print("ok $test"); + print("ok $test - perl -l option tested"); } $test++; -print "ok $test"; +print "ok $test - Second test file utilized"; __END__ diff --git a/t/win32/runenv.t b/t/win32/runenv.t index a833c1a..b2d7895 100644 --- a/t/win32/runenv.t +++ b/t/win32/runenv.t @@ -73,8 +73,8 @@ sub try { my ($env, $args, $stdout, $stderr) = @_; my ($actual_stdout, $actual_stderr) = runperl_and_capture($env, $args); local $::Level = $::Level + 1; - is ($stdout, $actual_stdout); - is ($stderr, $actual_stderr); + is $actual_stdout, $stdout; + is $actual_stderr, $stderr; } # PERL5OPT Command-line options (switches). Switches in -- Perl5 Master Repository
