summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorChip Salzenberg <chip@atlantic.net>1996-11-24 02:01:27 +1200
committerChip Salzenberg <chip@atlantic.net>1996-11-26 20:48:00 +1200
commitd1f8c7a45dc381aadd1554d536a49dff9ab0c3d5 (patch)
tree93bce952338db0ec9cf8f59f217b9c7ca8fd967b /t
parent6158a1acbe5b192950193bb2d789928975cfd9e6 (diff)
downloadperl-d1f8c7a45dc381aadd1554d536a49dff9ab0c3d5.tar.gz
Fix bitwise op test; clean up a couple of others
Diffstat (limited to 't')
-rwxr-xr-xt/lib/bigintpm.t7
-rwxr-xr-xt/op/bop.t23
-rwxr-xr-xt/op/overload.t7
3 files changed, 27 insertions, 10 deletions
diff --git a/t/lib/bigintpm.t b/t/lib/bigintpm.t
index b229d7c67b..ebaecac21a 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 7cf200ff25..0c55029b93 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 183cb273f7..fca26b4085 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: