Front page | perl.perl5.changes |
Postings from May 2008
Change 33791: [PATCH] extra tests for t/op/range.t (was Re: [perl #53554] Range
From:
Rafael Garcia-Suarez
Date:
May 8, 2008 08:45
Subject:
Change 33791: [PATCH] extra tests for t/op/range.t (was Re: [perl #53554] Range
Change 33791 by rgs@scipion on 2008/05/08 15:32:34
Subject: [PATCH] extra tests for t/op/range.t (was Re: [perl #53554] Range
From: Bram <p5p@perl.wizbit.be>
Date: Mon, 05 May 2008 20:03:32 +0200
Message-ID: <20080505200332.pke1i5vu7gos8kc0@horde.wizbit.be>
Affected files ...
... //depot/perl/t/op/range.t#21 edit
Differences ...
==== //depot/perl/t/op/range.t#21 (xtext) ====
Index: perl/t/op/range.t
--- perl/t/op/range.t#20~32979~ 2008-01-15 03:11:07.000000000 -0800
+++ perl/t/op/range.t 2008-05-08 08:32:34.000000000 -0700
@@ -9,7 +9,7 @@
use Config;
-plan (115);
+plan (135);
is(join(':',1..5), '1:2:3:4:5');
@@ -341,4 +341,66 @@
ok($@, 'Lower bound rejected: ' . -$ii);
}
+# double/tripple magic tests
+sub TIESCALAR { bless { value => $_[1], orig => $_[1] } }
+sub STORE { $_[0]{store}++; $_[0]{value} = $_[1] }
+sub FETCH { $_[0]{fetch}++; $_[0]{value} }
+sub stores { tied($_[0])->{value} = tied($_[0])->{orig};
+ delete(tied($_[0])->{store}) || 0 }
+sub fetches { delete(tied($_[0])->{fetch}) || 0 }
+
+tie $x, "main", 6;
+
+my @foo;
+@foo = 4 .. $x;
+is(scalar @foo, 3);
+is("@foo", "4 5 6");
+{
+ local $TODO = "test for double magic with range operator";
+ is(fetches($x), 1);
+}
+is(stores($x), 0);
+
+@foo = $x .. 8;
+is(scalar @foo, 3);
+is("@foo", "6 7 8");
+{
+ local $TODO = "test for double magic with range operator";
+ is(fetches($x), 1);
+}
+is(stores($x), 0);
+
+@foo = $x .. $x + 1;
+is(scalar @foo, 2);
+is("@foo", "6 7");
+{
+ local $TODO = "test for double magic with range operator";
+ is(fetches($x), 2);
+}
+is(stores($x), 0);
+
+@foo = ();
+for (4 .. $x) {
+ push @foo, $_;
+}
+is(scalar @foo, 3);
+is("@foo", "4 5 6");
+{
+ local $TODO = "test for double magic with range operator";
+ is(fetches($x), 1);
+}
+is(stores($x), 0);
+
+@foo = ();
+for (reverse 4 .. $x) {
+ push @foo, $_;
+}
+is(scalar @foo, 3);
+is("@foo", "6 5 4");
+{
+ local $TODO = "test for double magic with range operator";
+ is(fetches($x), 1);
+}
+is(stores($x), 0);
+
# EOF
End of Patch.
-
Change 33791: [PATCH] extra tests for t/op/range.t (was Re: [perl #53554] Range
by Rafael Garcia-Suarez