From: Chip Salzenberg Date: Sat, 23 Nov 1996 14:01:27 +0000 (+1200) Subject: Fix bitwise op test; clean up a couple of others X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d1f8c7a45dc381aadd1554d536a49dff9ab0c3d5;p=p5sagit%2Fp5-mst-13.2.git Fix bitwise op test; clean up a couple of others --- diff --git a/t/lib/bigintpm.t b/t/lib/bigintpm.t index b229d7c..ebaecac 100755 --- a/t/lib/bigintpm.t +++ b/t/lib/bigintpm.t @@ -1,8 +1,11 @@ #!./perl -BEGIN { unshift @INC, './lib', '../lib'; - require Config; import Config; +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; } + +use Config; use Math::BigInt; $test = 0; diff --git a/t/op/bop.t b/t/op/bop.t index 7cf200f..0c55029 100755 --- a/t/op/bop.t +++ b/t/op/bop.t @@ -4,6 +4,11 @@ # test the bit operators '&', '|', '^', '~', '<<', and '>>' # +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; +} + print "1..18\n"; # numerics @@ -19,16 +24,22 @@ print ((33023 >> 7) == 257 ? "ok 6\n" : "not ok 6\n"); # signed vs. unsigned print ((~0 > 0 && do { use integer; ~0 } == -1) ? "ok 7\n" : "not ok 7\n"); -print (((2147483648 & -1) > 0 && do { use integer; 2147483648 & -1 } < 0) + +my $bits = 0; +for (my $i = ~0; $i; $i >>= 1) { ++$bits; } +my $cusp = 1 << ($bits - 1); + +print ((($cusp & -1) > 0 && do { use integer; $cusp & -1 } < 0) ? "ok 8\n" : "not ok 8\n"); -print (((2147483648 | 1) > 0 && do { use integer; 2147483648 | 1 } < 0) +print ((($cusp | 1) > 0 && do { use integer; $cusp | 1 } < 0) ? "ok 9\n" : "not ok 9\n"); -print (((2147483648 ^ 1) > 0 && do { use integer; 2147483648 ^ 1 } < 0) +print ((($cusp ^ 1) > 0 && do { use integer; $cusp ^ 1 } < 0) ? "ok 10\n" : "not ok 10\n"); -print (((1 << 31) == 2147483648 && do { use integer; 1 << 31 } == -2147483648) +print (((1 << ($bits - 1)) == $cusp && + do { use integer; 1 << ($bits - 1) } == -$cusp) ? "ok 11\n" : "not ok 11\n"); -print (((2147483648 >> 1) == 1073741824 && - do { use integer; 2147483648 >> 1 } == -1073741824) +print ((($cusp >> 1) == ($cusp / 2) && + do { use integer; $cusp >> 1 } == -($cusp / 2)) ? "ok 12\n" : "not ok 12\n"); # short strings diff --git a/t/op/overload.t b/t/op/overload.t index 183cb27..fca26b4 100755 --- a/t/op/overload.t +++ b/t/op/overload.t @@ -1,9 +1,12 @@ #!./perl -BEGIN { unshift @INC, './lib', '../lib'; - require Config; import Config; +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; } +use Config; + package Oscalar; use overload ( # Anonymous subroutines: