Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 35 lines (29 sloc) 1.168 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
use v6;
use Test;
plan 12;

# L<S05/Modifiers/"causes certain whitespace sequences to be considered">
# L<S05/Modifiers/"any grammar is free to override the rule">

# test that implicit and explicit <.ws> rules are overridable
grammar T1 {
    token ws { 'x' };
    rule r1 {'a' 'b'};
    regex r2 { 'a' <.ws> 'b' };
    regex r3 { 'a' <ws> 'b' };
}

ok 'x' ~~ m/^<T1::ws>$/, 'basic sanity with custom <ws> rules';
is $/, 'x', 'correct text captured';
ok 'axb' ~~ m/^<T1::r1>$/, 'implicit <.ws> is overridden';
nok $<T1::r1><ws>.defined, 'implicit <.ws> did not capture';
ok 'axb' ~~ m/^<T1::r2>$/, 'explicit <.ws> is overridden';
nok $<T1::r2><ws>.defined, 'explicit <.ws> did not capture';
ok 'axb' ~~ m/^<T1::r3>$/, 'explicit <ws> is overridden';
is $<T1::r3><ws>, 'x', 'explicit <ws> did capture';

# RT #64094
{
    ok '' ~~ / <ws> /, 'match <ws> against empty string';
    ok '' ~~ / <ws>? /, 'match <ws>? against empty string';
    #?rakudo 2 skip 'infinite loop: RT #64094 (noauto)'
    ok '' ~~ / <ws>+ /, 'match <ws>+ against empty string';
    ok '' ~~ / <ws>* /, 'match <ws>* against empty string';
}

# vim: ft=perl6
Something went wrong with that request. Please try again.