]> git.vpit.fr Git - perl/modules/re-engine-Hooks.git/blob - t/10-base.t
Hook convertion of branches into tries
[perl/modules/re-engine-Hooks.git] / t / 10-base.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use blib 't/re-engine-Hooks-TestDist';
7
8 use Test::More tests => 4 * 3;
9
10 my $ops;
11 BEGIN { $ops = [ ] }
12
13 {
14  use re::engine::Hooks::TestDist 'foo' => $ops;
15
16  BEGIN { @$ops = () }
17  @$ops = ();
18
19  my $res = "lettuce" =~ /t{2,3}/;
20
21  BEGIN {
22   is "@$ops", 'c:EXACT c:CURLY c:END',  'match compilation';
23  }
24  is "@$ops", 'e:CURLY e:END', 'match execution';
25
26  ok $res, 'regexp match result';
27 }
28
29 {
30  use re::engine::Hooks::TestDist 'foo';
31
32  BEGIN { @$ops = () }
33  @$ops = ();
34
35  my @captures = "babaorum" =~ /([aeiou])/g;
36
37  BEGIN {
38   is "@$ops", 'c:OPEN c:ANYOF c:CLOSE c:END', 'capture compilation';
39  }
40  my $expect = join ' ', ('e:OPEN e:ANYOF e:CLOSE e:END') x 4;
41  is "@$ops", $expect, 'capture execution';
42
43  is "@captures", 'a a o u', 'regexp capture result';
44 }
45
46 my $expected_comp_branch;
47 BEGIN {
48  $expected_comp_branch
49 }
50
51 {
52  use re::engine::Hooks::TestDist 'foo';
53
54  BEGIN { @$ops = () }
55  @$ops = ();
56
57  my $res = "tomato" =~ /t(?:z|.)/g;
58
59  BEGIN {
60   is "@$ops", 'c:EXACT c:EXACT c:BRANCH c:BRANCH c:REG_ANY c:TAIL c:END',
61               'branch compilation';
62  }
63  my $expect = join ' ', ('e:EXACT e:BRANCH') x2, 'e:REG_ANY e:END';
64  is "@$ops", $expect, 'branch execution';
65
66  ok $res, 'branch execution result';
67 }
68
69 {
70  use re::engine::Hooks::TestDist 'foo';
71
72  BEGIN { @$ops = () }
73  @$ops = ();
74
75  my $res = "potato" =~ /t(?:z|o)/g;
76
77  BEGIN {
78   is "@$ops", 'c:EXACT c:EXACT c:BRANCH c:BRANCH c:EXACT c:TAIL c:END c:TRIE',
79               'trie compilation';
80  }
81  my $expect = join ' ', ('e:EXACT e:TRIE') x2, 'e:END';
82  is "@$ops", $expect, 'trie execution';
83
84  ok $res, 'trie execution result';
85 }