From 19048d269f5d793a680a66f8aa2def3e698052df Mon Sep 17 00:00:00 2001 From: colomon Date: Thu, 17 Jun 2010 19:57:40 +0000 Subject: [PATCH] [t/spec] Unfudge series / Range tests Rakudo now passes, and add a few more tests in those areas. git-svn-id: http://svn.pugscode.org/pugs@31334 c213334d-75ef-0310-aa23-eaa082d1ae64 --- t/spec/S03-operators/range-basic.t | 7 ++++++- t/spec/S03-operators/range.t | 8 +++++++- t/spec/S03-operators/series-simple.t | 9 ++++++++- t/spec/S03-operators/series.t | 5 ++++- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/t/spec/S03-operators/range-basic.t b/t/spec/S03-operators/range-basic.t index e00651835..89259ff38 100644 --- a/t/spec/S03-operators/range-basic.t +++ b/t/spec/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 ' ' ~~ ' '..' ', "' ' ~~ ' '..' '"; diff --git a/t/spec/S03-operators/range.t b/t/spec/S03-operators/range.t index e646d4e2a..d98ecb2a9 100644 --- a/t/spec/S03-operators/range.t +++ b/t/spec/S03-operators/range.t @@ -2,7 +2,7 @@ use v6; use Test; -plan 110; +plan 114; # L @@ -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 ).join('|'), '1|a|2|b|3|c', 'Ranges and infix:'; is (1..2 Z ).join('|'), '1|a|2|b', 'Ranges and infix:'; diff --git a/t/spec/S03-operators/series-simple.t b/t/spec/S03-operators/series-simple.t index 4f6b0ec48..4cfe15d83 100644 --- a/t/spec/S03-operators/series-simple.t +++ b/t/spec/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; diff --git a/t/spec/S03-operators/series.t b/t/spec/S03-operators/series.t index 0487e4892..c2ef62bb6 100644 --- a/t/spec/S03-operators/series.t +++ b/t/spec/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; -- 2.11.4.GIT