Skip to content
Browse files

[t/spec] Unfudge series / Range tests Rakudo now passes, and add a fe…

…w more tests in those areas.

git-svn-id: http://svn.pugscode.org/pugs@31334 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
1 parent 9240f92 commit b5ee073d6eb366628981f1377d958b529606f254 colomon committed Jun 17, 2010
Showing with 25 additions and 4 deletions.
  1. +6 −1 S03-operators/range-basic.t
  2. +7 −1 S03-operators/range.t
  3. +8 −1 S03-operators/series-simple.t
  4. +4 −1 S03-operators/series.t
View
7 S03-operators/range-basic.t
@@ -2,7 +2,7 @@ use v6;
use Test;
-plan 132;
+plan 136;
{
my $range = 2..6;
@@ -191,6 +191,11 @@ nok 'a' ~~ 'b'..'g', "not 'a' ~~ 'b'..'g'";
nok 'h' ~~ 'b'..'g', "not 'h' ~~ 'b'..'g'";
nok 0 ~~ 'a'..'g', "not 0 ~~ 'a'..'g'";
+ok 'd' ~~ 'c'..*, "'d' ~~ 'c'..*";
+nok 'b' ~~ 'c'..*, "not 'b' ~~ 'c'..*";
+ok 'b' ~~ *..'c', "'b' ~~ *..'c'";
+nok 'd' ~~ *..'c', "not 'd' ~~ *..'c'";
+
# RT#75526: [BUG] Some non-alphanumeric ranges don't work
{
ok ' ' ~~ ' '..' ', "' ' ~~ ' '..' '";
View
8 S03-operators/range.t
@@ -2,7 +2,7 @@ use v6;
use Test;
-plan 110;
+plan 114;
# L<S03/Nonchaining binary precedence/Range object constructor>
@@ -17,6 +17,8 @@ is ~(8..11), "8 9 10 11", "(..) works on carried numbers (3)";
is ~("a".."c"), "a b c", "(..) works on chars (1)";
is ~("a".."a"), "a", "(..) works on chars (2)";
is ~("b".."a"), "", "(..) works on chars (3)";
+is ~("a".."z"), "a b c d e f g h i j k l m n o p q r s t u v w x y z", "(..) works on char range ending in z";
+is ~("A".."Z"), "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z", "(..) works on char range ending in Z";
#?rakudo todo "Think master still gets this one wrong"
is ~("Y".."AB"), "", "(..) works on carried chars (3)";
#?rakudo todo "This test is now incorrect"
@@ -77,6 +79,10 @@ is ~(^"5"), "0 1 2 3 4", 'unary ^"num" produces the range 0..^num';
is (^@a).perl, (0..^3).perl, 'unary ^@a produces 0..^+@a';
}
+# test iterating on infinite ranges
+is (1..*).[^5].join('|'), '1|2|3|4|5', '1..*';
+is ('a'..*).[^5].join('|'), 'a|b|c|d|e', '"a"..*';
+
# test that the zip operator works with ranges
is (1..5 Z <a b c>).join('|'), '1|a|2|b|3|c', 'Ranges and infix:<Z>';
is (1..2 Z <a b c>).join('|'), '1|a|2|b', 'Ranges and infix:<Z>';
View
9 S03-operators/series-simple.t
@@ -74,7 +74,14 @@ is ('c', 'c' ... *).[^10].join(', '), 'c, c, c, c, c, c, c, c, c, c', 'series st
is ('c', 'c', 'c' ... *).[^10].join(', '), 'c, c, c, c, c, c, c, c, c, c', 'series started with three identical letters';
# tests for alphabetical series crossing 'z'
-#?rakudo 1 todo "RT#74990: Series of letters doesn't stop at end point"
is ('x' ... 'z').join(', '), 'x, y, z', "series ending with 'z' don't cross to two-letter strings";
+is ('A' ... 'z').elems, 'z'.ord - 'A'.ord + 1, "series from 'A' to 'z' is finite and of correct length";
+
+# tests for alphabetical series which are not single-character
+ok ('A' ... 'ZZ').munch(1000).elems < 1000, "'A' ... 'ZZ' does not go on forever";
+ok ('AA' ... 'Z').munch(1000).elems < 1000, "'AA' ... 'Z' does not go on forever";
+#?rakudo skip "'ZZ' ... 'A' breaks Rakudo"
+ok ('ZZ' ... 'A').munch(1000).elems < 1000, "'ZZ' ... 'A' does not go on forever";
+ok ('Z' ... 'AA').munch(1000).elems < 1000, "'Z' ... 'AA' does not go on forever";
done_testing;
View
5 S03-operators/series.t
@@ -148,9 +148,12 @@ is (16, 8, 4 ... *).[^5].join(', '), '16, 8, 4, 2, 1', 'geom decreasing';
is ~(4 ... ^5), ~<4 3 2 1 0 1 2 3 4>, '4 ... ^5 works';
is ~(4 ... 0, 1, 2, 3, 4), ~<4 3 2 1 0 1 2 3 4>, '4 ... 0, 1, 2, 3,4 works';
- #?rakudo 2 skip "waiting for ciphertext patch RT#75674"
is ~(-4 ... ^5), ~<-4 -3 -2 -1 0 1 2 3 4>, '-4 ... ^5 works';
is ~(-4 ... 0, 1, 2, 3, 4), ~<-4 -3 -2 -1 0 1 2 3 4>, '-5 ... 0, 1, 2, 3, 4 works';
+
+ is ~(4, 3 ... ^5), ~<4 3 2 1 0 1 2 3 4>, '4, 3 ... ^5 works';
+ is ~(4, 2 ... 0, 1, 2, 3, 4), ~<4 2 0 1 2 3 4>, '4, 2 ... 0, 1, 2, 3, 4 works';
+ is ~(4, 1 ... 0, 1, 2, 3, 4), ~<4 1 1 2 3 4>, '4, 1 ... 0, 1, 2, 3, 4 works';
}
done_testing;

0 comments on commit b5ee073

Please sign in to comment.
Something went wrong with that request. Please try again.