3 # This is a home for regular expression tests that don't fit into
4 # the format supported by re/regexp.t, that specifically should run fast.
6 # All the tests in this file are ones that run exceptionally slowly
7 # (each test taking seconds or even minutes) in the absence of particular
8 # optimisations. Thus it is a sort of canary for optimisations being
11 # Although it includes a watchdog timeout, this is set to a generous limit
12 # to allow for running on slow systems; therefore a broken optimisation
13 # might be indicated merely by this test file taking unusually long to
14 # run, rather than actually timing out.
28 @INC = ('../lib','.','../ext/re');
29 require Config; import Config;
31 skip_all('no re module') unless defined &DynaLoader::boot_DynaLoader;
32 skip_all_without_unicode_tables();
35 plan tests => 9; # Update this when adding/deleting tests.
37 run_tests() unless caller;
45 watchdog(($::running_as_thread && $::running_as_thread) ? 50 : 75);
49 # this code should be virtually instantaneous. If it takes 10s of
50 # seconds, there a bug in intuit_start.
51 # (this test doesn't actually test for slowness - that involves
52 # too much danger of false positives on loaded machines - but by
53 # putting it here, hopefully someone might notice if it suddenly
55 my $s = ('a' x 1_000_000) . 'b';
61 is($i, 0, "RT 120446: mustn't run slowly");
66 # these tests should be virtually instantaneous. If they take 10s of
67 # seconds, there's a bug in intuit_start.
69 my $s = 'ab' x 1_000_000;
71 1 while $s =~ m/\Ga+ba+b/g;
72 pass("RT#120692 \\G mustn't run slowly");
74 $s=~ /^a{1,2}x/ for 1..10_000;
75 pass("RT#120692 a{1,2} mustn't run slowly");
78 pass("RT#120692 ab.{1,2} mustn't run slowly");
80 $s = "-a-bc" x 250_000;
83 ok($s =~ /\da\d{0,30000}bc/, "\\d{30000}");
85 $s = "-ab\n" x 250_000;
87 ok($s =~ /^ab.*x/m, "distant float with /m");
90 $s = "abcd-xyz\n" x 500_000;
91 $s =~ /$r\d{1,2}xyz/m for 1..200;
92 pass("BOL within //m mustn't run slowly");
94 $s = "abcdefg" x 1_000_000;
95 $s =~ /(?-m:^)abcX?fg/m for 1..100;
96 pass("BOL within //m mustn't skip absolute anchored check");
98 $s = "abcdefg" x 1_000_000;
99 $s =~ /^XX\d{1,10}cde/ for 1..100;
100 pass("abs anchored float string should fail quickly");
104 } # End of sub run_tests