3 # This is a home for regular expression tests that don't fit into
4 # the format supported by re/regexp.t. If you want to add a test
5 # that does fit that format, add it to re/re_tests, not here.
7 # this file includes test that my burn a lot of CPU or otherwise be heavy
8 # on resources. Set env var $PERL_SKIP_PSYCHO_TEST to skip this file
22 @INC = ('../lib','.');
27 skip_all('$PERL_SKIP_PSYCHO_TEST set') if $ENV{PERL_SKIP_PSYCHO_TEST};
28 plan tests => 11; # Update this when adding/deleting tests.
30 run_tests() unless caller;
36 print "# Set PERL_SKIP_PSYCHO_TEST to skip these tests\n";
42 my @normal = qw [the are some normal words];
46 note "setting up trie psycho vars ...";
47 my @psycho = (@normal, map chr $_, 255 .. 20000);
48 my $psycho1 = "@psycho";
49 for (my $i = @psycho; -- $i;) {
50 my $j = int rand (1 + $i);
51 @psycho [$i, $j] = @psycho [$j, $i];
53 my $psycho2 = "@psycho";
55 foreach my $word (@normal) {
56 ok $word =~ /($psycho1)/ && $1 eq $word, qq{"$word" =~ /\$psycho1/};
57 ok $word =~ /($psycho2)/ && $1 eq $word, qq{"$word" =~ /\$psycho1/};
63 # stress test CURLYX/WHILEM.
65 # This test includes varying levels of nesting, and according to
66 # profiling done against build 28905, exercises every code line in the
67 # CURLYX and WHILEM blocks, except those related to LONGJMP, the
68 # super-linear cache and warnings. It executes about 0.5M regexes
104 my $msg = "CURLYX stress test";
106 for my $a ("x","a","aa") {
107 for my $b ("x","bbb","bbbb") {
109 for my $c ("x","c","cc") {
111 for my $d ("x","d","dd") {
113 for my $e ("x","e","ee") {
115 for my $f ("x","f","ff") {
117 for my $g ("x","g","gg") {
119 for my $h ("x","h","hh") {
121 for my $i ("x","i","ii") {
123 for my $j ("x","j","jj") {
125 for my $k ("x","k","kk") {
127 for my $l ("x","l","ll") {
131 $msg .= ": unexpected match for [$ls]";
135 my $cap = "$1$2$3$4$5$6$7$8$9$10$11$12";
136 unless ($ls eq $cap) {
137 $msg .= ": capture: [$ls], got [$cap]";
143 unless ($ls =~ /x/) {
144 $msg = ": failed for [$ls]";
163 } # End of sub run_tests