Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble mixing match objects and ranges #1171

Closed
p6rt opened this issue Jul 25, 2009 · 5 comments
Closed

Trouble mixing match objects and ranges #1171

p6rt opened this issue Jul 25, 2009 · 5 comments
Labels
Bug LHF Low-hanging fruit, easy to resolve

Comments

@p6rt
Copy link

p6rt commented Jul 25, 2009

Migrated from rt.perl.org#67882 (status was 'resolved')

Searchable as RT67882$

@p6rt
Copy link
Author

p6rt commented Jul 25, 2009

From @colomon

Rakudo commit version​: 241545b9d6c73f95bd8e5255187c30d5e77e6381
Parrot revision number​: 40185

Test code written by KyleHa++​:

  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';

Multiple Dispatch​: No suitable candidate found for 'cmp', with signature 'PP->I'
in method Range​::true (src/gen_setting.pm​:1650)
called from method Range​::Str (src/gen_setting.pm​:1654)
called from sub Test​::is (Test.pm​:62)
called from Main (t/spec/S03-operators/range.rakudo​:149)

(This is on OS X, but probably universal.)

--
Solomon Foster​: colomon@​gmail.com
HarmonyWare, Inc​: http://www.harmonyware.com

@p6rt
Copy link
Author

p6rt commented May 30, 2010

From @moritz

Works now, tests pass, happiness spreads over the world.

@p6rt
Copy link
Author

p6rt commented May 30, 2010

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented May 30, 2010

@moritz - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed May 30, 2010
@p6rt
Copy link
Author

p6rt commented May 30, 2010

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S03-operators/range.t

commit 6a8a76abd5ba1ae9227b37b434aaa4eccb5fa75b
Author​: moritz <moritz@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Sun May 30 12​:44​:54 2010 +0000

  [t/spec] unfudge tests for RT #​67882, and add a few more (because I did not see the existing tests early enough)
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;30991 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S03-operators/range.t b/t/spec/S03-operators/range.t
index d80a290..7124829 100644
--- a/t/spec/S03-operators/range.t
+++ b/t/spec/S03-operators/range.t
@@ -2,7 +2,7 @@ use v6;
 
 use Test;
 
-plan 107;
+plan 110;
 
 
 # L<S03/Nonchaining binary precedence/Range object constructor>
@@ -159,7 +159,6 @@ is (1..6 Z 'a' .. 'c').join, '1a2b3c',   'Ranges and infix:<Z>';
 }
  
 # RT #67882
-#?rakudo skip "Does not automatically turn match objects into strings / numbers"
 {
     my $range;
     lives_ok { '1 3' ~~ /(\d+) \s (\d+)/; $range = $0..$1 },
@@ -169,6 +168,13 @@ is (1..6 Z 'a' .. 'c').join, '1a2b3c',   'Ranges and infix:<Z>';
     lives_ok { "$range" }, 'can stringify range';
     is ~$range, "1 2 3", 'range is correct';
 }
+# and another set, just for the lulz
+# RT #67882
+{
+    ok '1 3' ~~ /(\d) . (\d)/, 'regex sanity';
+    isa_ok $0..$1, Range, '$0..$1 constructs a Range';
+    is ($0..$1).join('|'), '1|2|3', 'range from $0..$1';
+}
 {
     my $range;
     lives_ok { '1 3' ~~ /(\d+) \s (\d+)/; $range = +$0..+$1 },
@@ -199,4 +205,5 @@ is (1..6 Z 'a' .. 'c').join, '1a2b3c',   'Ranges and infix:<Z>';
     ok !defined(try { 0 .. (0, 1, 2) }), '0 .. List is illegal';
 }
 
+
 # # vim: ft=perl6

@p6rt p6rt added Bug LHF Low-hanging fruit, easy to resolve labels Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug LHF Low-hanging fruit, easy to resolve
Projects
None yet
Development

No branches or pull requests

1 participant