Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue: rakudo/rakudo#1269 NQP fix: Raku/nqp@10e392477975168a0a9f53c0
- Loading branch information
1 parent
dcb982a
commit fe86784
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
use v6; | ||
use Test; | ||
|
||
plan 1; | ||
|
||
unless "a" ~~ rx:P5/a/ { | ||
skip-rest "skipped tests - P5 regex support appears to be missing"; | ||
exit; | ||
} | ||
|
||
subtest 'named captures' => { plan 7; | ||
sub test-cap (\c, \v, $desc) { | ||
subtest $desc => { plan 2; | ||
isa-ok c, Capture, 'correct type'; | ||
is c, v, 'correct value'; | ||
} | ||
} | ||
|
||
subtest 'one named (?<>) capture' => { plan 2; | ||
ok 'foo' ~~ m:P5/(?<meow>.+)/, 'matched'; | ||
test-cap $<meow>, 'foo', 'named capture'; | ||
} | ||
subtest 'two named (?<>) captures' => { plan 3; | ||
ok 'fooBAR' ~~ m:P5/(?<meow>[a-z]+)(?<moo>[A-Z]+)/, 'matched'; | ||
test-cap $<meow>, 'foo', 'first named capture'; | ||
test-cap $<moo>, 'BAR', 'second named capture'; | ||
} | ||
subtest 'two named (?<>) + one positional captures' => { plan 4; | ||
ok 'foo42BAR' ~~ m:P5/(?<meow>[a-z]+)(\d+)(?<moo>[A-Z]+)/, 'matched'; | ||
test-cap $/[0], '42', 'positional capture'; | ||
test-cap $<meow>, 'foo', 'first named capture'; | ||
test-cap $<moo>, 'BAR', 'second named capture'; | ||
} | ||
|
||
subtest 「one named (?'') capture」 => { plan 2; | ||
ok 'foo' ~~ m:P5/(?'meow'.+)/, 'matched'; | ||
test-cap $<meow>, 'foo', 'named capture'; | ||
} | ||
subtest 「two named (?'') captures」 => { plan 3; | ||
ok 'fooBAR' ~~ m:P5/(?'meow'[a-z]+)(?'moo'[A-Z]+)/, 'matched'; | ||
test-cap $<meow>, 'foo', 'first named capture'; | ||
test-cap $<moo>, 'BAR', 'second named capture'; | ||
} | ||
subtest 「two named (?'') + one positional captures」 => { plan 4; | ||
ok 'foo42BAR' ~~ m:P5/(?'meow'[a-z]+)(\d+)(?'moo'[A-Z]+)/, 'matched'; | ||
test-cap $/[0], '42', 'positional capture'; | ||
test-cap $<meow>, 'foo', 'first named capture'; | ||
test-cap $<moo>, 'BAR', 'second named capture'; | ||
} | ||
|
||
subtest 「named (?'') + named (?<>) + one positional captures」 => { plan 4; | ||
ok 'foo42BAR' ~~ m:P5/(?<meow>[a-z]+)(\d+)(?'moo'[A-Z]+)/, 'matched'; | ||
test-cap $/[0], '42', 'positional capture'; | ||
test-cap $<meow>, 'foo', 'first named (?<>) capture'; | ||
test-cap $<moo>, 'BAR', 「second named (?'') capture」; | ||
} | ||
} | ||
|
||
# vim: ft=perl6 |