diff options
author | Bob Ernst <bobernst@cpan.org> | 2012-11-17 19:57:39 +0000 |
---|---|---|
committer | James E Keenan <jkeenan@cpan.org> | 2012-11-25 19:50:33 -0500 |
commit | 7231abfa401098a696dd1efea7bea4e81edbe44f (patch) | |
tree | 85f2f76e6969b30f9ee1b585cfbf93a150636b3f /t | |
parent | 2f54119d20adde7812afae1aa17e80481871bc2f (diff) | |
download | perl-7231abfa401098a696dd1efea7bea4e81edbe44f.tar.gz |
Add descriptions to tests for int.t
Diffstat (limited to 't')
-rw-r--r-- | t/op/int.t | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/t/op/int.t b/t/op/int.t index 6d3b5b496c..9aad020a48 100644 --- a/t/op/int.t +++ b/t/op/int.t @@ -10,26 +10,28 @@ plan 15; # compile time evaluation -if (int(1.234) == 1) {pass()} else {fail()} +my $test1_descr = 'compile time evaluation 1.234'; +if (int(1.234) == 1) {pass($test1_descr)} else {fail($test1_descr)} -if (int(-1.234) == -1) {pass()} else {fail()} +my $test2_descr = 'compile time evaluation -1.234'; +if (int(-1.234) == -1) {pass($test2_descr)} else {fail($test2_descr)} # run time evaluation $x = 1.234; -cmp_ok(int($x), '==', 1); -cmp_ok(int(-$x), '==', -1); +cmp_ok(int($x), '==', 1, 'run time evaluation 1'); +cmp_ok(int(-$x), '==', -1, 'run time evaluation -1'); $x = length("abc") % -10; -cmp_ok($x, '==', -7); +cmp_ok($x, '==', -7, 'subtract from string length'); { my $fail; use integer; $x = length("abc") % -10; $y = (3/-10)*-10; - ok($x+$y == 3) or ++$fail; - ok(abs($x) < 10) or ++$fail; + ok($x+$y == 3, 'x+y equals 3') or ++$fail; + ok(abs($x) < 10, 'abs(x) < 10') or ++$fail; if ($fail) { diag("\$x == $x", "\$y == $y"); } @@ -38,32 +40,34 @@ cmp_ok($x, '==', -7); @x = ( 6, 8, 10); cmp_ok($x["1foo"], '==', 8, 'check bad strings still get converted'); +# 4,294,967,295 is largest unsigned 32 bit integer + $x = 4294967303.15; $y = int ($x); is($y, "4294967303", 'check values > 32 bits work'); $y = int (-$x); -is($y, "-4294967303"); +is($y, "-4294967303", 'negative value more than maximum unsigned 32 bit value'); $x = 4294967294.2; $y = int ($x); -is($y, "4294967294"); +is($y, "4294967294", 'floating point value slightly less than the largest unsigned 32 bit'); $x = 4294967295.7; $y = int ($x); -is($y, "4294967295"); +is($y, "4294967295", 'floating point value slightly more than largest unsigned 32 bit'); $x = 4294967296.11312; $y = int ($x); -is($y, "4294967296"); +is($y, "4294967296", 'floating point value more than largest unsigned 32 bit'); $y = int(279964589018079/59); -cmp_ok($y, '==', 4745162525730); +cmp_ok($y, '==', 4745162525730, 'compile time division, result of about 42 bits'); $y = 279964589018079; $y = int($y/59); -cmp_ok($y, '==', 4745162525730); +cmp_ok($y, '==', 4745162525730, 'run time divison, result of about 42 bits'); |