Skip to content

Commit 7530a15

Browse files
committed
Test for .prematch and .postmatch on zero-width matches
1 parent e6b125e commit 7530a15

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

S05-capture/match-object.t

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use Test;
44
# this file should become the test for systematically testing
55
# Match objects. Exception: .caps and .chunks are tested in caps.t
66

7-
plan 31;
7+
plan 35;
88

99
ok 'ab12de' ~~ /\d+/, 'match successful';
1010
is $/.WHAT, Match.WHAT, 'got right type';
@@ -22,6 +22,15 @@ is $/.values.elems, 0, '.values (empty)';
2222
is $/.pairs.elems, 0, '.pairs (empty)';
2323
is $/.kv.elems, 0, '.kv (empty)';
2424

25+
26+
# prematch and postmatch for zero-width matches,
27+
# which was broken in rakudo until https://github.com/rakudo/rakudo/commit/c04b8b5cc9
28+
29+
ok 'abc def' ~~ />>/, 'sanity 1';
30+
is $/.from, 3, 'sanity 2';
31+
is $/.prematch, 'abc', '.prematch for zero-width matches';
32+
is $/.postmatch, ' def', '.postmatch for zero-width matches';
33+
2534
nok 'abde' ~~ /\d/, 'no match';
2635
nok $/.Bool, 'failed match is False';
2736
is $/.Str, '', 'false match stringifies to empty string';

0 commit comments

Comments
 (0)