3 Test that lexical importing works, check BEGIN-ish stuff etc.
8 use Test::More tests => 8;
9 use re::engine::Plugin ();
11 like "a", qr/^a$/, "import didn't run, perl's regex engine in effect";
14 re::engine::Plugin->import(
15 exec => sub { $_[0]->pattern eq $_[1] }
19 ok "^hello" =~ /^hello/ => "regex modified to match a literal pattern";
23 re::engine::Plugin->import(
24 exec => sub { $_[0]->pattern ne $_[1] }
28 ok "^hello" !~ /^hello/ => "regex modified not to match a literal pattern";
31 re::engine::Plugin->import(
32 exec => sub { $_[0]->pattern eq '^[abc]$' }
35 ok "whatever" =~ /^[abc]$/ => "regex modified to match some exact nonsense";
36 BEGIN { re::engine::Plugin->unimport };
37 ok "whatever" !~ /^[abc]$/ => "regex modified to match some exact nonsense unimported";
39 ok "^hello" !~ /^hello/ => "regex modified not to match a literal pattern";
42 ok "^hello" =~ /^hello/ => "regex modified to match a literal pattern";
44 # Another import at the same scope
46 re::engine::Plugin->import(
47 exec => sub { $_[0]->pattern ne $_[1] }
51 ok "^hello" !~ /^hello/ => "regex modified not to match a literal pattern";