fold_grind.t: Modify trie test
authorKarl Williamson <public@khwilliamson.com>
Tue, 20 Aug 2013 04:38:43 +0000 (22:38 -0600)
committerKarl Williamson <public@khwilliamson.com>
Thu, 29 Aug 2013 16:56:59 +0000 (10:56 -0600)
The trie tests just add an alternation of a fixed string.  This commit
makes that string the same number of bytes as the first alternative, in
an effort to not bias the test.  Otherwise, something that might
otherwise appear to be too short might be long enough to match the fixed
string, defeating properly testing the length.

t/re/fold_grind.t

index 9d9f426..5782dfc 100644 (file)
@@ -697,7 +697,16 @@ foreach my $test (sort { numerically } keys %tests) {
           }
 
           # See if works on what could be a simple trie.
-          $eval = "my \$c = \"$lhs\"; my \$p = qr/$rhs|xyz/i$charset;$upgrade_target$upgrade_pattern \$c $op \$p";
+          my $alternate;
+          {
+            # Keep the alternate | branch the same length as the tested one so
+            # that it's length doesn't influence things
+            my $evaled = eval "\"$rhs\"";   # Convert e.g. \x{foo} into its
+                                            # chr equivalent
+            use bytes;
+            $alternate = 'q' x length $evaled;
+          }
+          $eval = "my \$c = \"$lhs\"; my \$p = qr/$rhs|$alternate/i$charset;$upgrade_target$upgrade_pattern \$c $op \$p";
           run_test($eval, "", "");
 
           # Check that works when the folded character follows something that