X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fop%2Fint.t;h=e9596a39a07bc9a43d356dbb1dff19b1c526033d;hb=36c66720946952b050ad9db88444230a58b3c69d;hp=6ac0866a2bc8d1c1053df0c264ee7f94f3c632f8;hpb=6e7c9e4dbac15378c097f03304f6025aebc78a15;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/op/int.t b/t/op/int.t index 6ac0866..e9596a3 100755 --- a/t/op/int.t +++ b/t/op/int.t @@ -2,10 +2,10 @@ BEGIN { chdir 't' if -d 't'; - unshift @INC, '../lib'; + @INC = '../lib'; } -print "1..6\n"; +print "1..14\n"; # compile time evaluation @@ -28,3 +28,71 @@ print $x == -7 ? "ok 5\n" : "# expected -7, got $x\nnot ok 5\n"; $y = (3/-10)*-10; print $x+$y == 3 && abs($x) < 10 ? "ok 6\n" : "not ok 6\n"; } + +# check bad strings still get converted + +@x = ( 6, 8, 10); +print "not " if $x["1foo"] != 8; +print "ok 7\n"; + +# check values > 32 bits work. + +$x = 4294967303.15; +$y = int ($x); + +if ($y eq "4294967303") { + print "ok 8\n" +} else { + print "not ok 8 # int($x) is $y, not 4294967303\n" +} + +$y = int (-$x); + +if ($y eq "-4294967303") { + print "ok 9\n" +} else { + print "not ok 9 # int($x) is $y, not -4294967303\n" +} + +$x = 4294967294.2; +$y = int ($x); + +if ($y eq "4294967294") { + print "ok 10\n" +} else { + print "not ok 10 # int($x) is $y, not 4294967294\n" +} + +$x = 4294967295.7; +$y = int ($x); + +if ($y eq "4294967295") { + print "ok 11\n" +} else { + print "not ok 11 # int($x) is $y, not 4294967295\n" +} + +$x = 4294967296.11312; +$y = int ($x); + +if ($y eq "4294967296") { + print "ok 12\n" +} else { + print "not ok 12 # int($x) is $y, not 4294967296\n" +} + +$y = int(279964589018079/59); +if ($y == 4745162525730) { + print "ok 13\n" +} else { + print "not ok 13 # int(279964589018079/59) is $y, not 4745162525730\n" +} + +$y = 279964589018079; +$y = int($y/59); +if ($y == 4745162525730) { + print "ok 14\n" +} else { + print "not ok 14 # int(279964589018079/59) is $y, not 4745162525730\n" +} +