3 Test that lexical importing works, check BEGIN-ish stuff etc.
11 use Test::More tests => 7;
13 use re::engine::Plugin ();
15 like "a", qr/^a$/, "import didn't run, perl's regex engine in effect";
18 re::engine::Plugin->import(
19 comp => sub {}, # TODO: remove when this can be omitted
20 exec => sub { $_[0]->pattern eq $_[1] }
24 ok "^hello" =~ /^hello/ => "regex modified to match a literal pattern";
28 re::engine::Plugin->import(
29 comp => sub {}, # TODO: remove when this can be omitted
30 exec => sub { $_[0]->pattern ne $_[1] }
34 ok "^hello" !~ /^hello/ => "regex modified not to match a literal pattern";
37 re::engine::Plugin->import(
38 comp => sub {}, # TODO: remove when this can be omitted
39 exec => sub { $_[0]->pattern eq '^[abc]$' }
42 ok "whatever" =~ /^[abc]$/ => "regex modified to match some exact nonsense";
43 BEGIN { re::engine::Plugin->unimport };
44 ok "whatever" !~ /^[abc]$/ => "regex modified to match some exact nonsense unimported";
46 ok "^hello" !~ /^hello/ => "regex modified not to match a literal pattern";
49 ok "^hello" =~ /^hello/ => "regex modified to match a literal pattern";