Skip to content

Commit

Permalink
Test comb(Regex) returns Seq
Browse files Browse the repository at this point in the history
Closes rakudo/rakudo#1564 R#1564
  • Loading branch information
zoffixznet committed Apr 7, 2018
1 parent 1719f50 commit f464b68
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
18 changes: 16 additions & 2 deletions S16-io/comb.t
@@ -1,7 +1,9 @@
use v6;
use lib $?FILE.IO.parent(2).add: 'packages';
use Test;
use Test::Util;

plan 25;
plan 26;

my $filename = $?FILE.IO.parent.child('comb.testing');
LEAVE unlink $filename; # cleanup
Expand Down Expand Up @@ -121,6 +123,18 @@ for 100000 -> $sep {
test-comb($text,@clean,$sep);
}

unlink $filename; # cleanup
# https://github.com/rakudo/rakudo/issues/1564
subtest '.comb(Regex) returns Seq' => {
plan 4;
my $path := make-temp-file :content<abc>;
given $path.open {
cmp-ok .comb(/\w/), 'eqv', <a b c>.Seq, 'IO::Handle';
.seek: 0, SeekFromBeginning;
cmp-ok .comb(/\w/, 2, :close), 'eqv', <a b>.Seq,
'IO::Handle, with limit';
}
cmp-ok $path.comb(/\w/), 'eqv', <a b c>.Seq, 'IO::Path';
cmp-ok $path.comb(/\w/, 2), 'eqv', <a b>.Seq, 'IO::Path with limit';
}

# vim: ft=perl6
2 changes: 1 addition & 1 deletion S32-io/io-cathandle.t
Expand Up @@ -66,7 +66,7 @@ subtest 'comb method' => {
\(2, 3), \(/../), \(/../, 2), \(/<:alpha>/, 3);
plan +@tests;

is-deeply cat.comb(|$_), $str.comb(|$_), .perl for @tests;
cmp-ok cat.comb(|$_), 'eqv', $str.comb(|$_), .perl for @tests;
}

subtest 'DESTROY method' => {
Expand Down
20 changes: 19 additions & 1 deletion S32-str/comb.t
Expand Up @@ -2,7 +2,7 @@ use v6;

use Test;

plan 82;
plan 83;

# L<S32::Str/Str/=item comb>

Expand Down Expand Up @@ -187,4 +187,22 @@ is (gather 'abc'.comb(/. { take $/.Str } <!> /)).join(','),
'a,b,c',
'$/ inside comb';

# https://github.com/rakudo/rakudo/issues/1564
subtest 'comb(Regex) returns Seq' => {
plan 8;
cmp-ok 'abc'.comb(/./), 'eqv', <a b c>.Seq, 'method (Str)';
cmp-ok comb(/./, 'abc'), 'eqv', <a b c>.Seq, 'sub (Str)';
cmp-ok 123.comb(/./), 'eqv', ('1', '2', '3').Seq, 'method (Cool)';
cmp-ok comb(/./, 123), 'eqv', ('1', '2', '3').Seq, 'sub (Cool)';

cmp-ok 'abc'.comb(/./, 2), 'eqv', <a b>.Seq,
'method (Str) with limit';
cmp-ok comb(/./, 'abc', 2), 'eqv', <a b>.Seq,
'sub (Str) with limit';
cmp-ok 123.comb(/./, 2), 'eqv', ('1', '2').Seq,
'method (Cool) with limit';
cmp-ok comb(/./, 123, 2), 'eqv', ('1', '2').Seq,
'sub (Cool) with limit';
}

# vim: ft=perl6

0 comments on commit f464b68

Please sign in to comment.