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/reverse.t: add description to test #12583

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

t/op/reverse.t: add description to test #12583

p5pRT opened this issue Nov 17, 2012 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Nov 17, 2012

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

Searchable as RT115790$

@p5pRT
Copy link
Author

p5pRT commented Nov 17, 2012

From bobernststl@gmail.com

Created at the St. Louis Perl Monger Hackathon, please review.

@p5pRT
Copy link
Author

p5pRT commented Nov 17, 2012

From bobernststl@gmail.com

0002-Added-descriptions-to-tests-in-reverse.t.patch
From d489c8780ffa5e7a558c4af5663106331ba38011 Mon Sep 17 00:00:00 2001
From: Bob Ernst <bobernst@cpan.org>
Date: Sat, 17 Nov 2012 21:18:20 +0000
Subject: [PATCH 2/2] Added descriptions to tests in reverse.t

---
 t/op/reverse.t |   52 ++++++++++++++++++++++++++--------------------------
 1 files changed, 26 insertions(+), 26 deletions(-)

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

@p5pRT
Copy link
Author

p5pRT commented Nov 20, 2012

From @jkeenan

On Sat Nov 17 13​:23​:13 2012, bobernststl@​gmail.com wrote​:

Created at the 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 committed to blead in commit af1b607

Closing ticket. Thank you very much.

Jim Keenan

@p5pRT
Copy link
Author

p5pRT commented Nov 26, 2012

From [Unknown Contact. See original ticket]

Patch committed to blead in commit af1b607

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