Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[t/spec] Test bug from colomon++

git-svn-id: http://svn.pugscode.org/pugs@27729 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
commit 82915ee25c5d82a643f38d412cefb2130ac94f8d 1 parent 4726a9d
kyle authored
Showing with 22 additions and 1 deletion.
  1. +22 −1 S03-operators/range.t
View
23 S03-operators/range.t
@@ -2,7 +2,7 @@ use v6;
use Test;
-plan 80;
+plan 90;
# 3..2 must *not* produce "3 2". Use reverse to get a reversed range. -lwall
@@ -138,5 +138,26 @@ is (1..6 Z 'a' .. 'c').join, '1a2b3c', 'Ranges and infix:<Z>';
is (1..3).reduce({ $^a + $^b}), 6, '.reduce works on ranges';
}
+{
+ my $range;
+ lives_ok { '1 3' ~~ /(\d+) \s (\d+)/; $range = $0..$1 },
+ 'can make range from match vars';
+ is $range.from, 1, 'range starts at one';
+ is $range.to, 3, 'range ends at three';
+ #?rakudo todo 'range from match vars defies stringification'
+ lives_ok { "$range" }, 'can stringify range';
+ #?rakudo skip 'range from match vars defies comparison'
+ is $range, (1,2,3), 'range is correct';
+}
+{
+ my $range;
+ lives_ok { '1 3' ~~ /(\d+) \s (\d+)/; $range = +$0..+$1 },
+ 'can make range from match vars with numeric context forced';
+ is $range.from, 1, 'range starts at one';
+ is $range.to, 3, 'range ends at three';
+ lives_ok { "$range" }, 'can stringify range';
+ is $range, (1,2,3), 'range is correct';
+}
+
# For tests involving :by, see t/spec/S03-operators/range-by.t
# and t/operators/adverbial_modifiers.t
Please sign in to comment.
Something went wrong with that request. Please try again.