Permalink
Browse files

Update spectests for Range endpoint exceptions.

  • Loading branch information...
1 parent bbe88fe commit 01d116253876aef0601b9cfd70bd924ee1bcfc05 @pmichaud pmichaud committed Mar 16, 2013
Showing with 17 additions and 6 deletions.
  1. +9 −1 S03-operators/range-basic.t
  2. +8 −5 S03-operators/range.t
@@ -1,8 +1,10 @@
use v6;
use Test;
+BEGIN { @*INC.push('t/spec/packages') };
+use Test::Util;
-plan 136;
+plan 144;
{
my $range = 2..6;
@@ -112,6 +114,12 @@ plan 136;
is $range.excludes_max, Bool::True, "1^..^*.excludes_max is true";
}
+# some range constructions are invalid
+throws_like '10 .. ^20', X::Range::InvalidArg ;
+throws_like '^10 .. 20', X::Range::InvalidArg ;
+throws_like '* .. ^20', X::Range::InvalidArg ;
+throws_like '^10 .. *', X::Range::InvalidArg ;
+
ok 3 ~~ 1..5, '3 ~~ 1..5';
ok 2.5 ~~ 1..5, '2.5 ~~ 1..5';
ok 2.5e0 ~~ 1..5, '2.5e0 ~~ 1..5';
View
@@ -234,17 +234,20 @@ is (1..6 Z 'a' .. 'c').join, '1a2b3c', 'Ranges and infix:<Z>';
is ~$range, "1 2 3", 'range is correct';
}
-# L<S03/Nonchaining binary precedence/it is illegal to use a Range or a
-# List as implicitly numeric:>
+# L<S03/Nonchaining binary precedence/it is illegal to use a Range as
+# implicity numeric>
-#?rakudo todo 'forbid Ranges and Lists as Range endpoints'
-#?niecza todo
+#?niecza todo 'forbid Ranges as Range endpoints'
#?pugs todo
{
ok !defined(try { 0 .. ^10 }), '0 .. ^10 is illegal';
- ok !defined(try { 0 .. (0, 1, 2) }), '0 .. List is illegal';
}
+# Lists are allowed on the rhs if the lhs is numeric (Real):
+#?niecza todo 'allow List as rhs endpoint'
+#?pugs todo
+is ~(2 .. [<a b c d e>]), "2 3 4 5", '2 .. @list is legal';
+
# RT #68788
#?pugs skip 'Missing required parameters: $_'
#?DOES 2

0 comments on commit 01d1162

Please sign in to comment.