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 34 lines (24 sloc) 1.088 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
use v6;
use Test;

plan 12;

#L<S05/Modifiers/"If followed by an x, it means repetition.">

#?pugs emit skip_rest("Not yet implemented");

#?rakudo todo ':2x'
ok('abab' ~~ m:2x/ab/, ':2x (repetition) modifier (+)');
nok('ab' ~~ m:2x/ab/, ':2x (repetition) modifier (-)');

#?rakudo todo ':x(2)'
ok('abab' ~~ m:x(2)/ab/, ':2x (repetition) modifier (+)');
nok('ab' ~~ m:x(2)/ab/, ':2x (repetition) modifier (-)');

{
    ok 'ababc'.match(rx/ab/, :x(2)), ':x(2) with .match method (+)';
    nok 'abc'.match(rx/ab/, :x(2)), ':x(2) with .match method (-)';

    ok 'ababc'.match(rx/./, :x(3)), ':x(3) with .match method (bool)';
    is 'ababc'.match(rx/./, :x(3)).join('|'), 'a|b|a', ':x(3) with .match method (result)';
}

{
    ok 'abacad'.match(rx/a./, :x(1..3)), ':x(Range)';
    nok 'abcabc'.match(rx/a./, :x(3..4)), ':x(Range) > number of matches';
    is 'abacadae'.match(rx/a./, :x(1..3)).join('|'), 'ab|ac|ad', ':x(Range) (upper bound)';
    is 'abacad'.match(rx/a./, :x(2..5)).join('|'), 'ab|ac|ad', ':x(Range) (takes as much as it can)';
}

# vim: syn=perl6 sw=4 ts=4 expandtab
Something went wrong with that request. Please try again.