Ejemplo n.º 1
0
use Regexp::Assemble;

my $fixed = 'The scalar remains the same';
$_ = $fixed;
*/
$ra = new Regexp_Assemble();
is_deeply($ra->__mbegin, [], 'mbegin is [] on non-tracked R::A object');
is_deeply($ra->__mend, [], 'mend is [] on non-tracked R::A object');
$re = new Regexp_Assemble();
$re->add('cat')->add('dog');
$regexp = $re->re();
ok($re->match('cat'), 'match without tracking');
ok(!$re->match('eagle'), 'match fail without tracking');
$re = new Regexp_Assemble();
$re->track(1)->add('dog');
ok($re->match('dog'), 're pattern-0 dog match');
is($re->source(0), 'dog', 'source is dog');
$re = new Regexp_Assemble(['track' => 1]);
$re->add('dog', 'dogged', 'fish', 'fetish', 'flash', 'fresh');
$re->add('foolish-\\d+');
ok($re->match('dog'), 're pattern-1 dog match');
//    SKIP: {
//        skip( "matched() is not implemented in this version of perl ($])", 1 ) if $PERL_VERSION_TOO_LOW;
is($re->matched, 'dog', 're pattern-1 dog matched');
//    }
ok($re->match('dogged'), 're pattern-1 dogged match');
//    SKIP: {
//        skip( "matched() is not implemented in this version of perl ($])", 1 ) if $PERL_VERSION_TOO_LOW;
is($re->matched, 'dogged', 're pattern-1 dogged matched');
//    }