In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/e759bc314f0fb0eebf211ca20ce3b52cbce6bd71?hp=2f54119d20adde7812afae1aa17e80481871bc2f>
- Log ----------------------------------------------------------------- commit e759bc314f0fb0eebf211ca20ce3b52cbce6bd71 Author: Bob Ernst <[email protected]> Date: Sun Nov 18 00:03:58 2012 +0000 Add descriptions to tests for exp.t M t/op/exp.t commit 66745c0bdc21eaccfcea80c9af21d23eadd859ab Author: Bob Ernst <[email protected]> Date: Sat Nov 17 22:14:53 2012 +0000 Add descriptions to tests for fh.t M t/op/fh.t commit af1b6079f4f58b6c4af6ba7874b8b96fa7dfd92d Author: Bob Ernst <[email protected]> Date: Sat Nov 17 21:18:20 2012 +0000 Added descriptions to tests in reverse.t M t/op/reverse.t commit 7231abfa401098a696dd1efea7bea4e81edbe44f Author: Bob Ernst <[email protected]> Date: Sat Nov 17 19:57:39 2012 +0000 Add descriptions to tests for int.t M t/op/int.t ----------------------------------------------------------------------- Summary of changes: t/op/exp.t | 32 ++++++++++++++++---------------- t/op/fh.t | 16 ++++++++-------- t/op/int.t | 30 +++++++++++++++++------------- t/op/reverse.t | 52 ++++++++++++++++++++++++++-------------------------- 4 files changed, 67 insertions(+), 63 deletions(-) diff --git a/t/op/exp.t b/t/op/exp.t index 9bc44b4..d132b1f 100644 --- a/t/op/exp.t +++ b/t/op/exp.t @@ -11,24 +11,24 @@ plan tests => 16; # compile time evaluation $s = sqrt(2); -is(substr($s,0,5), '1.414'); +is(substr($s,0,5), '1.414', 'compile time sqrt(2) == 1.414'); $s = exp(1); -is(substr($s,0,7), '2.71828'); +is(substr($s,0,7), '2.71828', 'compile time exp(1) == e'); -cmp_ok(exp(log(1)), '==', 1); +cmp_ok(exp(log(1)), '==', 1, 'compile time exp(log(1)) == 1'); # run time evaluation $x1 = 1; $x2 = 2; $s = sqrt($x2); -is(substr($s,0,5), '1.414'); +is(substr($s,0,5), '1.414', 'run time sqrt(2) == 1.414'); $s = exp($x1); -is(substr($s,0,7), '2.71828'); +is(substr($s,0,7), '2.71828', 'run time exp(1) = e'); -cmp_ok(exp(log($x1)), '==', 1); +cmp_ok(exp(log($x1)), '==', 1, 'run time exp(log(1)) == 1'); # tests for transcendental functions @@ -41,18 +41,18 @@ sub round { } # sin() tests -cmp_ok(sin(0), '==', 0.0); -cmp_ok(round(sin($pi)), '==', 0.0); -cmp_ok(round(sin(-1 * $pi)), '==', 0.0); -cmp_ok(round(sin($pi_2)), '==', 1.0); -cmp_ok(round(sin(-1 * $pi_2)), '==', -1.0); +cmp_ok(sin(0), '==', 0.0, 'sin(0) == 0'); +cmp_ok(round(sin($pi)), '==', 0.0, 'sin(pi) == 0'); +cmp_ok(round(sin(-1 * $pi)), '==', 0.0, 'sin(-pi) == 0'); +cmp_ok(round(sin($pi_2)), '==', 1.0, 'sin(pi/2) == 1'); +cmp_ok(round(sin(-1 * $pi_2)), '==', -1.0, 'sin(-pi/2) == -1'); # cos() tests -cmp_ok(cos(0), '==', 1.0); -cmp_ok(round(cos($pi)), '==', -1.0); -cmp_ok(round(cos(-1 * $pi)), '==', -1.0); -cmp_ok(round(cos($pi_2)), '==', 0.0); -cmp_ok(round(cos(-1 * $pi_2)), '==', 0.0); +cmp_ok(cos(0), '==', 1.0, 'cos(0) == 1'); +cmp_ok(round(cos($pi)), '==', -1.0, 'cos(pi) == -1'); +cmp_ok(round(cos(-1 * $pi)), '==', -1.0, 'cos(-pi) == -1'); +cmp_ok(round(cos($pi_2)), '==', 0.0, 'cos(pi/2) == 0'); +cmp_ok(round(cos(-1 * $pi_2)), '==', 0.0, 'cos(-pi/2) == 0'); # atan2() tests were removed due to differing results from calls to # atan2() on various OS's and architectures. See perlport.pod for diff --git a/t/op/fh.t b/t/op/fh.t index 16ba186..afca57b 100644 --- a/t/op/fh.t +++ b/t/op/fh.t @@ -12,18 +12,18 @@ plan tests => 8; $|=1; my $a = "SYM000"; -ok(!defined(fileno($a))); -ok(!defined *{$a}); +ok(!defined(fileno($a)), 'initial file handle is undefined'); +ok(!defined *{$a}, 'initial typeglob of file handle is undefined'); select select $a; -ok(defined *{$a}); +ok(defined *{$a}, 'typeglob of file handle defined after select'); $a++; -ok(!close $a); -ok(!defined *{$a}); +ok(!close $a, 'close does not succeed with incremented file handle'); +ok(!defined *{$a}, 'typeglob of file handle not defined after increment'); -ok(open($a, ">&STDOUT")); -ok(defined *{$a}); +ok(open($a, ">&STDOUT"), 'file handle used with open of standard output'); +ok(defined *{$a}, 'typeglob of file handle defined after opening standard output'); -ok(close $a); +ok(close $a, 'close standard output via file handle;'); diff --git a/t/op/int.t b/t/op/int.t index 6d3b5b4..9aad020 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'); diff --git a/t/op/reverse.t b/t/op/reverse.t index 916724c..bbc9336 100644 --- a/t/op/reverse.t +++ b/t/op/reverse.t @@ -8,46 +8,46 @@ BEGIN { plan tests => 26; -is(reverse("abc"), "cba"); +is(reverse("abc"), "cba", 'simple reverse'); $_ = "foobar"; -is(reverse(), "raboof"); +is(reverse(), "raboof", 'reverse of the default variable'); { my @a = ("foo", "bar"); my @b = reverse @a; - is($b[0], $a[1]); - is($b[1], $a[0]); + is($b[0], $a[1], 'array reversal moved second element to first'); + is($b[1], $a[0], 'array reversal moved first element to second'); } { my @a = (1, 2, 3, 4); @a = reverse @a; - is("@a", "4 3 2 1"); + is("@a", "4 3 2 1", 'four element array reversed'); delete $a[1]; @a = reverse @a; - ok(!exists $a[2]); - is($a[0] . $a[1] . $a[3], '124'); + ok(!exists $a[2], 'array reversed with deleted second element'); + is($a[0] . $a[1] . $a[3], '124', 'remaining elements ok after delete and reverse'); @a = (5, 6, 7, 8, 9); @a = reverse @a; - is("@a", "9 8 7 6 5"); + is("@a", "9 8 7 6 5", 'five element array reversed'); delete $a[3]; @a = reverse @a; - ok(!exists $a[1]); - is($a[0] . $a[2] . $a[3] . $a[4], '5789'); + ok(!exists $a[1], 'five element array reversed with deleted fourth element'); + is($a[0] . $a[2] . $a[3] . $a[4], '5789', 'remaining elements ok after delete and reverse'); delete $a[2]; @a = reverse @a; - ok(!exists $a[2] && !exists $a[3]); - is($a[0] . $a[1] . $a[4], '985'); + ok(!exists $a[2] && !exists $a[3], 'test position of two deleted elements after reversal'); + is($a[0] . $a[1] . $a[4], '985', 'check value of remaining elements'); my @empty; @empty = reverse @empty; - is("@empty", ""); + is("@empty", "", 'reversed empty array is still empty'); } use Tie::Array; @@ -57,30 +57,30 @@ use Tie::Array; @a = (1, 2, 3, 4); @a = reverse @a; - is("@a", "4 3 2 1"); + is("@a", "4 3 2 1", 'tie array reversal'); delete $a[1]; @a = reverse @a; - ok(!exists $a[2]); - is($a[0] . $a[1] . $a[3], '124'); + ok(!exists $a[2], 'deleted element position ok after reversal of tie array'); + is($a[0] . $a[1] . $a[3], '124', 'remaining elements ok after delete and reversal for tie array'); @a = (5, 6, 7, 8, 9); @a = reverse @a; - is("@a", "9 8 7 6 5"); + is("@a", "9 8 7 6 5", 'five element tie array reversal'); delete $a[3]; @a = reverse @a; - ok(!exists $a[1]); - is($a[0] . $a[2] . $a[3] . $a[4], '5789'); + ok(!exists $a[1], 'deleted element position ok after tie array reversal'); + is($a[0] . $a[2] . $a[3] . $a[4], '5789', 'remaining elements ok after tie array delete and reversal'); delete $a[2]; @a = reverse @a; - ok(!exists $a[2] && !exists $a[3]); - is($a[0] . $a[1] . $a[4], '985'); + ok(!exists $a[2] && !exists $a[3], 'two deleted element positions ok after tie array reversal'); + is($a[0] . $a[1] . $a[4], '985', 'remaining elements ok after two deletes and reversals'); tie my @empty, "Tie::StdArray"; @empty = reverse @empty; - is(scalar(@empty), 0); + is(scalar(@empty), 0, 'reversed tie array still empty after reversal'); } { @@ -89,17 +89,17 @@ use Tie::Array; my $a = "\x{263A}\x{263A}x\x{263A}y\x{263A}"; my $b = scalar reverse($a); my $c = scalar reverse($b); - is($a, $c); + is($a, $c, 'Unicode string double reversal matches original'); } { # Lexical $_. sub blurp { my $_ = shift; reverse } - is(blurp("foo"), "oof"); - is(sub { my $_ = shift; reverse }->("bar"), "rab"); + is(blurp("foo"), "oof", 'reversal of default variable in function'); + is(sub { my $_ = shift; reverse }->("bar"), "rab", 'reversal of default variable in anonymous function'); { local $_ = "XXX"; - is(blurp("paz"), "zap"); + is(blurp("paz"), "zap", 'reversal of default variable with local value set' ); } } -- Perl5 Master Repository
