From e0041dd25f50f334ea964880f662ccb72407e14b Mon Sep 17 00:00:00 2001 From: TimToady Date: Wed, 8 Apr 2015 22:37:57 -0700 Subject: [PATCH] revised tests for new sequence iterators --- S03-sequence/basic.t | 42 +++++++++++++++++----------------- S03-sequence/nonnumeric.t | 5 +--- integration/advent2010-day04.t | 2 +- integration/advent2013-day15.t | 2 +- 4 files changed, 24 insertions(+), 27 deletions(-) diff --git a/S03-sequence/basic.t b/S03-sequence/basic.t index fc0c8212b4..df9034ee0d 100755 --- a/S03-sequence/basic.t +++ b/S03-sequence/basic.t @@ -33,15 +33,15 @@ is (1 ... 5, 6, 7).join(', '), '1, 2, 3, 4, 5, 6, 7', 'simple sequence with two is (1 ... 5, 4, 3).join(', '), '1, 2, 3, 4, 5, 4, 3', 'simple sequence with two extra terms on the RHS'; is (1 ... 5, 'xyzzy', 'plugh').join(', '), '1, 2, 3, 4, 5, xyzzy, plugh', 'simple sequence with two weird items on the RHS'; -# infinite sequence that go past their limit +# sequences that might go past their limit { -is (1 ... 5.5).[^6].join(', '), '1, 2, 3, 4, 5, 6', 'simple sequence with one item on the LHS'; -is (1 ... -3.5).[^6].join(', '), '1, 0, -1, -2, -3, -4', 'simple decreasing sequence with one item on the LHS'; -is (1, 3 ... 10).[^6].join(', '), '1, 3, 5, 7, 9, 11', 'simple additive sequence with two items on the LHS'; -is (1, 0 ... -3.5).[^6].join(', '), '1, 0, -1, -2, -3, -4', 'simple decreasing additive sequence with two items on the LHS'; -is (1, 3, 5 ... 10).[^6].join(', '), '1, 3, 5, 7, 9, 11', 'simple additive sequence with three items on the LHS'; -is (1, 3, 9 ... 100).[^6].join(', '), '1, 3, 9, 27, 81, 243', 'simple multiplicative sequence with three items on the LHS'; -is (81, 27, 9 ... 8/9).[^6], (81, 27, 9, 3, 1, 1/3), 'decreasing multiplicative sequence with three items on the LHS'; +is (1 ... 5.5).[^10].join(', '), '1, 2, 3, 4, 5', 'simple sequence with one item on the LHS'; +is (1 ... -3.5).[^10].join(', '), '1, 0, -1, -2, -3', 'simple decreasing sequence with one item on the LHS'; +is (1, 3 ... 10).[^10].join(', '), '1, 3, 5, 7, 9', 'simple additive sequence with two items on the LHS'; +is (1, 0 ... -3.5).[^10].join(', '), '1, 0, -1, -2, -3', 'simple decreasing additive sequence with two items on the LHS'; +is (1, 3, 5 ... 10).[^10].join(', '), '1, 3, 5, 7, 9', 'simple additive sequence with three items on the LHS'; +is (1, 3, 9 ... 100).[^10].join(', '), '1, 3, 9, 27, 81', 'simple multiplicative sequence with three items on the LHS'; +is (81, 27, 9 ... 8/9).[^10], (81, 27, 9, 3, 1), 'decreasing multiplicative sequence with three items on the LHS'; is (1, { $_ + 2 } ... 10).[^6].join(', '), '1, 3, 5, 7, 9, 11', 'simple sequence with one item and block closure on the LHS'; is (1, *+2 ... 10).[^6].join(', '), '1, 3, 5, 7, 9, 11', 'simple sequence with one item and * closure on the LHS'; is (1, { $_ - 2 } ... -8).[^6].join(', '), '1, -1, -3, -5, -7, -9', 'simple sequence with one item and closure on the LHS'; @@ -49,9 +49,9 @@ is (1, 3, 5, { $_ + 2 } ... 14).[^8].join(', '), '1, 3, 5, 7, 9, 11, 13, 15', 's is (1, { 1 / ((1 / $_) + 1) } ... 11/60).[^6].map({.perl}).join(', '), '1, 0.5, <1/3>, 0.25, 0.2, <1/6>', 'tricky sequence with one item and closure on the LHS'; is (1, { -$_ } ... 0).[^4].join(', '), '1, -1, 1, -1', 'simple alternating sequence with one item and closure on the LHS'; -is (1 ... 5.5, 6, 7).[^8].join(', '), '1, 2, 3, 4, 5, 6, 7, 8', 'simple sequence with two further terms on the RHS'; -is (1 ... 5.5, 4, 3).[^8].join(', '), '1, 2, 3, 4, 5, 6, 7, 8', 'simple sequence with two extra terms on the RHS'; -is (1 ... 5.5, 'xyzzy', 'plugh').[^8].join(', '), '1, 2, 3, 4, 5, 6, 7, 8', 'simple sequence with two weird items on the RHS'; +is (1 ... 5.5, 6, 7).[^8].join(', '), '1, 2, 3, 4, 5, 6, 7', 'simple sequence with two further terms on the RHS'; +is (1 ... 5.5, 4, 3).[^8].join(', '), '1, 2, 3, 4, 5, 4, 3', 'simple sequence with two extra terms on the RHS'; +is (1 ... 5.5, 'xyzzy', 'plugh').[^8].join(', '), '1, 2, 3, 4, 5, xyzzy, plugh', 'simple sequence with two weird items on the RHS'; } # infinite sequence without limits @@ -107,7 +107,7 @@ is (1, { 1 / ((1 / $_) + 1) } ... 0).[^5].map({.perl}).join(', '), '1, 0.5, <1/3 # L { -is (1, 2 ... 0).[^3], (1,2,3), 'No more: limit value is on the wrong side'; +is (1, 2 ... 0).[^3], (1,2), 'No more: limit value is on the wrong side'; } # L @@ -115,16 +115,16 @@ is (1, 2 ... 0).[^3], (1,2,3), 'No more: limit value is on the wrong side'; { is (1 ...^ 5).join(', '), '1, 2, 3, 4', 'exclusive sequence'; is (1 ...^ -3).join(', '), '1, 0, -1, -2', 'exclusive decreasing sequence'; - is (1 ...^ 5.5).[^6].join(', '), '1, 2, 3, 4, 5, 6', "exclusive sequence that couldn't hit its limit anyway"; + is (1 ...^ 5.5).[^6].join(', '), '1, 2, 3, 4, 5', "exclusive sequence that couldn't hit its limit anyway"; is (1, 3, 9 ...^ 81).join(', '), '1, 3, 9, 27', 'exclusive geometric sequence'; - is (81, 27, 9 ...^ 2).[^5].join(', '), '81, 27, 9, 3, 1', "exclusive decreasing geometric sequence that couldn't hit its limit anyway"; + is (81, 27, 9 ...^ 2).[^5].join(', '), '81, 27, 9, 3', "exclusive decreasing geometric sequence that couldn't hit its limit anyway"; is (2, -4, 8 ...^ 32).join(', '), '2, -4, 8, -16', 'exclusive alternating geometric sequence'; is (2, -4, 8 ...^ -32).[^6].join(', '), '2, -4, 8, -16, 32, -64', 'exclusive alternating geometric sequence (not an exact match)'; is (1, { $_ + 2 } ...^ 9).join(', '), '1, 3, 5, 7', 'exclusive sequence with closure'; is (1 ...^ 1), (), 'empty exclusive sequence'; is (1, 1 ...^ 1), (), 'empty exclusive constant sequence'; - is (1, 2 ...^ 0).[^3], (1, 2, 3), 'empty exclusive arithmetic sequence'; - is (1, 2 ...^ 0, 'xyzzy', 'plugh').[^3].join(', '), '1, 2, 3', 'exclusive sequence empty but for extra items'; + is (1, 2 ...^ 0).[^3], (1, 2), 'empty exclusive arithmetic sequence'; + is (1, 2 ...^ 0, 'xyzzy', 'plugh').[^5].join(', '), '1, 2, xyzzy, plugh', 'exclusive sequence empty but for extra items'; is ~(1 ...^ 0), '1', 'singleton exclusive sequence'; is (4...^5).join(', '), '4', '4...^5 should parse as 4 ...^ 5 and not 4 ... ^5'; } @@ -157,20 +157,20 @@ is EVAL((1 ... 5).perl).join(','), '1,2,3,4,5', is ~((1 ... *) Z~ ('a' ... 'z')).[^5], "1a 2b 3c 4d 5e", "Zipping two sequence in parallel"; { - is (1, 2, 4 ... 3).[^4], (1, 2, 4, 8), "sequence that does not hit the limit"; + is (1, 2, 4 ... 3).[^4], (1, 2, 4), "sequence that does not hit the limit"; is (1, 2, 4 ... 2), (1, 2), "sequence that aborts during LHS"; - is (1, 2, 4 ... 1.5).[^4], (1,2,4,8), "sequence that does not hit the limit"; + is (1, 2, 4 ... 1.5).[^4], (1,2,4), "sequence that does not hit the limit"; is (1, 2, 4 ... 1), (1), "sequence that aborts during LHS"; is ~(1, -2, 4 ... 1), '1', 'geometric sequence with smaller RHS and sign change'; is ~(1, -2, 4 ... 2).[^4], '1 -2 4 -8', 'geometric sequence with smaller RHS and sign change'; is ~(1, -2, 4 ... 3).[^4], '1 -2 4 -8', 'geometric sequence with smaller RHS and sign change'; - is ~(1, -2, 4 ... 25).[^10], '1 -2 4 -8 16 -32 64 -128 256 -512', 'geometric sequence with sign-change and non-matching end point'; + is ~(1, -2, 4 ... 25).[^10], '1 -2 4 -8 16', 'geometric sequence with sign-change and non-matching end point'; is (1, 2, 4, 5, 6 ... 2), (1, 2), "sequence that aborts during LHS, before actual calculations kick in"; - is (1, 2, 4, 5, 6 ... 3).[^6], (1,2,4,5,6,7), "sequence that aborts during LHS, before actual calculations kick in"; + is (1, 2, 4, 5, 6 ... 3).[^6], (1,2,4,5,6), "sequence that aborts during LHS, before actual calculations kick in"; } # tests for the types returned @@ -232,7 +232,7 @@ is (5,4,3, { $_ - 1 || last } ... *)[^10].join(', '), '5, 4, 3, 2, 1', "sequence is (1..* ... 5), (1, 2, 3, 4, 5), '1..* ... 5'; my @fib := (0, 1, *+* ... * ); # RT #98790 - is (@fib ... 8), (0 , 1, 1, 2 , 3, 5, 8), '@fib ... 8'; + is (@fib ... 8), (0, 1, 1, 2 , 3, 5, 8), '@fib ... 8'; } # RT #78324 diff --git a/S03-sequence/nonnumeric.t b/S03-sequence/nonnumeric.t index 3f1121f5a0..f790dac939 100644 --- a/S03-sequence/nonnumeric.t +++ b/S03-sequence/nonnumeric.t @@ -63,10 +63,7 @@ is ('☀' ...^ '☕').join(''), '☀☁☂☃☄★☆☇☈☉☊☋☌☍☎ "Str decrement fails after 'AA': leftmost characters are never removed", message => 'Decrement out of range'; is ('Y', 'Z' ... 'AA').join(' '), 'Y Z AA', "'Y', 'Z' ... 'AA' works"; - throws_like { 'Z' ... 'AA' }, - Exception, - "'Z' ... 'AA' fails: only 1 RHS value and ('Z' before 'AA') is False", - message => 'Decrement out of range'; + is ('Z' ... 'AA')[*-1], 'B', "A is before AA"; } is ('A' ...^ 'ZZ')[*-1], 'ZY', "'A' ...^ 'ZZ' omits last element"; diff --git a/integration/advent2010-day04.t b/integration/advent2010-day04.t index d2991fdd72..6fbef96df6 100644 --- a/integration/advent2010-day04.t +++ b/integration/advent2010-day04.t @@ -20,7 +20,7 @@ plan 11; { is (1, 1.1 ... 2).join(" "), "1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2", "1, 1.1 ... 2 is correct"; - is (1, 1.1 ... 2.01)[^14].join(" "), "1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 2.1 2.2 2.3", + is (1, 1.1 ... 2.01)[^14].join(" "), "1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2", "1, 1.1 ... 2.01 is correct"; } diff --git a/integration/advent2013-day15.t b/integration/advent2013-day15.t index f1b1ae7274..b3cd13afb9 100644 --- a/integration/advent2013-day15.t +++ b/integration/advent2013-day15.t @@ -32,7 +32,7 @@ my $pi = 3.14e0; my $earth-mass = 5.97e24; # kg is $earth-mass.WHAT.gist, '(Num)'; -is_approx (0, 1e-1 ... 1)[11], 1.1, 'missed the 1'; +is_approx (0, 1e-1 ... 2)[11], 1.1, 'missed the 1'; #?rakudo.jvm todo "jvm rounding quirks" is (0, 1e-1 ... * >= 1).gist, '0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 1.1', '(oops)'; is (1e0/10 + 1/10 + 1/10 == 0.3).gist, 'False', '(awww!)';