]> git.vpit.fr Git - perl/modules/re-engine-Plugin.git/blob - t/import.t
Importing re-engine-Plugin-0.01.tar.gz
[perl/modules/re-engine-Plugin.git] / t / import.t
1 =pod
2
3 Test that lexical importing works, check BEGIN-ish stuff etc.
4
5 =cut
6
7 use strict;
8
9 use Data::Dumper;
10
11 use Test::More tests => 7;
12
13 use re::engine::Plugin ();
14
15 like "a", qr/^a$/, "import didn't run, perl's regex engine in effect";
16
17 BEGIN {
18     re::engine::Plugin->import(
19         comp => sub {}, # TODO: remove when this can be omitted
20         exec => sub { $_[0]->pattern eq $_[1] }
21     );
22 }
23
24 ok "^hello" =~ /^hello/ => "regex modified to match a literal pattern";
25
26 {
27     BEGIN {
28         re::engine::Plugin->import(
29             comp => sub {}, # TODO: remove when this can be omitted
30             exec => sub { $_[0]->pattern ne $_[1] }
31         );
32     }
33
34     ok "^hello" !~ /^hello/ => "regex modified not to match a literal pattern";
35     {
36         BEGIN {
37             re::engine::Plugin->import(
38                 comp => sub {}, # TODO: remove when this can be omitted
39                 exec => sub { $_[0]->pattern eq '^[abc]$' }
40             );
41         }
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";
45     }
46     ok "^hello" !~ /^hello/ => "regex modified not to match a literal pattern";
47 }
48
49 ok "^hello" =~ /^hello/ => "regex modified to match a literal pattern";
50
51
52
53
54
55
56
57
58
59
60
61
62