Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

t/op/int.t: add descriptions to test #12581

Closed
p5pRT opened this issue Nov 17, 2012 · 7 comments
Closed

t/op/int.t: add descriptions to test #12581

p5pRT opened this issue Nov 17, 2012 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Nov 17, 2012

Migrated from rt.perl.org#115786 (status was 'resolved')

Searchable as RT115786$

@p5pRT
Copy link
Author

p5pRT commented Nov 17, 2012

From bobernststl@gmail.com

Created at St. Louis Perl Monger Hackathon; please review.

@p5pRT
Copy link
Author

p5pRT commented Nov 17, 2012

From bobernststl@gmail.com

0001-Add-descriptions-to-tests-for-int.t.patch
From 4d7dc93c20764211ae7a1a99565b2dc75cae10d1 Mon Sep 17 00:00:00 2001
From: Bob Ernst <bobernst@cpan.org>
Date: Sat, 17 Nov 2012 19:57:39 +0000
Subject: [PATCH] Add descriptions to tests for int.t

---
 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 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');
-- 
1.7.2.5

@p5pRT
Copy link
Author

p5pRT commented Nov 20, 2012

From @jkeenan

On Sat Nov 17 12​:04​:57 2012, bobernststl@​gmail.com wrote​:

Created at St. Louis Perl Monger Hackathon; please review.

I have reviewed this patch and believe it should be applied. I have
taken the ticket for that purpose and will apply it in seven days unless
someone beats me to it or objects to the patch.

Thank you very much.
Jim Keenan

@p5pRT
Copy link
Author

p5pRT commented Nov 20, 2012

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Nov 26, 2012

From @jkeenan

Patch applied to blead in commit 7231abf

Closing ticket. Thank you very much.

Jim Keenan

@p5pRT
Copy link
Author

p5pRT commented Nov 26, 2012

From [Unknown Contact. See original ticket]

Patch applied to blead in commit 7231abf

Closing ticket. Thank you very much.

Jim Keenan

@p5pRT
Copy link
Author

p5pRT commented Nov 26, 2012

@jkeenan - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant