3 Tests methods on the re object
11 use Test::More tests => 9;
13 use re::engine::Plugin (
17 # Use a stash to pass a single scalar value to each executing
18 # routine, references work perfectly a reference to anything
19 # can be passed as well
20 $re->stash( { x => 5, y => sub { 6 } } );
22 # Return value not used for now..
28 cmp_ok($re->pattern, 'eq', ' foobar zoobar ' => '->pattern ok');
32 ok(exists $mod{i}, 'str flags /i');
33 ok(exists $mod{x}, 'str flags /x');
34 like(join('', keys %mod), qr/^[cgimosx]+$/, 'flags contain all-good characters');
37 cmp_ok($re->stash->{"x"}, '==', 5, "data correct in stash");
38 cmp_ok(ref $re->stash->{"y"}, 'eq', 'CODE', "data correct in stash");
39 cmp_ok(ref $re->stash->{"y"}, 'eq', 'CODE', "data correct in stash");
40 cmp_ok($re->stash->{"y"}->(), '==', 6, "data correct in stash");
42 # Pattern contains "foo", "bar" and "zoo", return a true
43 return $re->pattern =~ /zoo/;
47 my $re = qr< foobar zoobar >xi;
49 if ("input" =~ $re ) {
50 pass 'pattern matched';
52 fail "pattern didn't match";