3 Tests methods on the re object
11 use Test::More 'no_plan';#tests => 6;
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 like $f, qr/i/, 'str flags /i';
33 like $f, qr/x/, 'str flags /x';
34 like $f, 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 # This needs a less sucky name
44 # Pattern: ' foobar zoobar ', set $1 to "foobar" (if I counted this right:)
45 # $re->offset_captures( [1, 7], ... );
47 # This name sucks as well
48 # $re->named_captures2offset_captures( myNameIs => 0 ): # $+{myNameIs} = $1
50 # Pattern contains "foo", "bar" and "zoo", return a true
51 return $re->pattern =~ /zoo/;
55 my $re = qr< foobar zoobar >xi;
57 if ("input" =~ $re ) {
58 pass 'pattern matched';
60 fail "pattern didn't match";