use v6;
use Test;
plan 13;
my $str = 'hello';
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';
{
for ('a'..'f') {
my $r = eval("rx/$_/");
is $str.match($r), $str~~$r, ".. works as ~~ matching '$str' with /$_/";
}
}
$str = 'food';
my $m = $str.match(/$<x>=[f](o+)/);
ok $m ~~ Match, 'is a Match object';
is $m, 'foo', 'match object stringifies OK';
is $m<x>, 'f', 'match object indexes as a hash';
is $m[0], 'oo', 'match object indexes as an array';