Skip to content

Commit 060cf7a

Browse files
committed
.split works on Cool same as it works on Str
RT#129242: https://rt.perl.org/Ticket/Display.html?id=129242
1 parent 0b80402 commit 060cf7a

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

S32-str/split.t

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use Test;
44

55
# L<S32-setting-library/Str"=item split">
66

7-
plan 59;
7+
plan 60;
88

99
# Legend:
1010
# r result
@@ -525,3 +525,25 @@ is "aaaaabbbbb".split(<aaa aa bb bbb>,:v), " aaa aa bbb bb ",
525525
# .List is to check it's not a BOOTArray (which doesn't have p6 method resolution)
526526
is *.split("-").("a-b-c").List,<a b c>,'*.split result is HLLized';
527527
}
528+
529+
# RT #129242
530+
subtest '.split works on Cool same as it works on Str' => {
531+
plan 11;
532+
533+
my $m = Match.new(
534+
ast => Any, list => (), hash => Map.new(()),
535+
orig => "123", to => 2, from => 1,
536+
);
537+
538+
is-deeply 123.split('2', :v), ('1', '2', '3'), ':v; Cool';
539+
is-deeply 123.split(/2/, :v), ('1', $m, '3'), ':v; Regex';
540+
is-deeply 123.split('2', :kv), ('1', 0, '2', '3'), ':kv; Cool';
541+
is-deeply 123.split(/2/, :kv), ('1', 0, $m, '3'), ':kv; Regex';
542+
is-deeply 123.split('2', :p), ('1', 0 => '2', '3'), ':p; Cool';
543+
is-deeply 123.split(/2/, :p), ('1', 0 => $m, '3'), ':p; Regex';
544+
is-deeply 123.split('2', :k), ('1', 0, '3'), ':k; Cool';
545+
is-deeply 123.split(/2/, :k), ('1', 0, '3'), ':k; Regex';
546+
is-deeply 4.split('', :skip-empty), ('4',), ':skip-empty; Cool';
547+
is-deeply 4.split(/<<|>>/, :skip-empty), ('4',), ':skip-empty; Regex';
548+
is-deeply 12345.split(('2', /4/)), ("1", "3", "5"), '@needles form';
549+
}

0 commit comments

Comments
 (0)