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 38 lines (28 sloc) 0.902 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 35 36 37
use v6;

use Test;

plan 13;

# L<S05/Substitution/>

my $str = 'hello';

#?pugs todo
ok $str.match(/h/), 'We can use match';
is $str, 'hello', '.. it does not do side effect';
ok $str.match(/h/)~~Match, '.. it returns a Match object';

#?DOES 6
{
    for ('a'..'f') {
        my $r = EVAL("rx/$_/");
        is $str.match($r), $str~~$r, ".. works as ~~ matching '$str' with /$_/";
    }
}

# it should work for everything that can be tied to a Str, according to S05
# but possibly it should just be defined in object as an exact alias to ~~ ?

$str = 'food';
my $m = $str.match(/$<x>=[f](o+)/);
ok $m ~~ Match, 'is a Match object';
#?pugs todo
is $m, 'foo', 'match object stringifies OK';
#?pugs todo
is $m<x>, 'f', 'match object indexes as a hash';
#?pugs todo
is $m[0], 'oo', 'match object indexes as an array';

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