]> git.vpit.fr Git - perl/modules/re-engine-Hooks.git/blobdiff - t/10-base.t
Hook convertion of branches into tries
[perl/modules/re-engine-Hooks.git] / t / 10-base.t
index 0db53dcfcfaee81d5257e0d7f547d67e535e57d2..565f878c025366211be212cd0570c8c0d74c747f 100644 (file)
@@ -5,9 +5,7 @@ use warnings;
 
 use blib 't/re-engine-Hooks-TestDist';
 
-use Test::More tests => 6;
-
-my $res;
+use Test::More tests => 4 * 3;
 
 my $ops;
 BEGIN { $ops = [ ] }
@@ -18,17 +16,15 @@ BEGIN { $ops = [ ] }
  BEGIN { @$ops = () }
  @$ops = ();
 
- $res = "lettuce" =~ /t{2,3}/;
my $res = "lettuce" =~ /t{2,3}/;
 
  BEGIN {
   is "@$ops", 'c:EXACT c:CURLY c:END',  'match compilation';
  }
  is "@$ops", 'e:CURLY e:END', 'match execution';
-}
 
-ok $res, 'regexp match result';
-
-my @captures;
+ ok $res, 'regexp match result';
+}
 
 {
  use re::engine::Hooks::TestDist 'foo';
@@ -36,13 +32,54 @@ my @captures;
  BEGIN { @$ops = () }
  @$ops = ();
 
- @captures = "babaorum" =~ /([aeiou])/g;
my @captures = "babaorum" =~ /([aeiou])/g;
 
  BEGIN {
   is "@$ops", 'c:OPEN c:ANYOF c:CLOSE c:END', 'capture compilation';
  }
  my $expect = join ' ', ('e:OPEN e:ANYOF e:CLOSE e:END') x 4;
  is "@$ops", $expect, 'capture execution';
+
+ is "@captures", 'a a o u', 'regexp capture result';
+}
+
+my $expected_comp_branch;
+BEGIN {
+ $expected_comp_branch
+}
+
+{
+ use re::engine::Hooks::TestDist 'foo';
+
+ BEGIN { @$ops = () }
+ @$ops = ();
+
+ my $res = "tomato" =~ /t(?:z|.)/g;
+
+ BEGIN {
+  is "@$ops", 'c:EXACT c:EXACT c:BRANCH c:BRANCH c:REG_ANY c:TAIL c:END',
+              'branch compilation';
+ }
+ my $expect = join ' ', ('e:EXACT e:BRANCH') x2, 'e:REG_ANY e:END';
+ is "@$ops", $expect, 'branch execution';
+
+ ok $res, 'branch execution result';
 }
 
-is "@captures", 'a a o u', 'regexp capture result';
+{
+ use re::engine::Hooks::TestDist 'foo';
+
+ BEGIN { @$ops = () }
+ @$ops = ();
+
+ my $res = "potato" =~ /t(?:z|o)/g;
+
+ BEGIN {
+  is "@$ops", 'c:EXACT c:EXACT c:BRANCH c:BRANCH c:EXACT c:TAIL c:END c:TRIE',
+              'trie compilation';
+ }
+ my $expect = join ' ', ('e:EXACT e:TRIE') x2, 'e:END';
+ is "@$ops", $expect, 'trie execution';
+
+ ok $res, 'trie execution result';
+}