fix re debug segvs in global destruction, and a tweak to Benchmark to prevent infinit...
[p5sagit/p5-mst-13.2.git] / ext / re / t / regop.t
CommitLineData
3dab1dad 1#!./perl
2
3BEGIN {
8e11feef 4 chdir 't' if -d 't';
5 @INC = '../lib';
6 require Config;
7 if (($Config::Config{'extensions'} !~ /\bre\b/) ){
8 print "1..0 # Skip -- Perl configured without re module\n";
9 exit 0;
10 }
3dab1dad 11}
12
13use strict;
8e11feef 14require "./test.pl";
07be1b83 15our $NUM_SECTS;
16chomp(my @strs= grep { !/^\s*\#/ } <DATA>);
17my $out = runperl(progfile => "../ext/re/t/regop.pl", stderr => 1 );
18my @tests = grep { /\S/ } split /(?=Compiling REx)/, $out;
19# on debug builds we get an EXECUTING... message in there at the top
20shift @tests
21 if $tests[0] =~ /EXECUTING.../;
3dab1dad 22
07be1b83 23plan( @tests + 2 + ( @strs - grep { !$_ or /^---/ } @strs ));
3dab1dad 24
07be1b83 25is( scalar @tests, $NUM_SECTS,
26 "Expecting output for $NUM_SECTS patterns" );
27ok( defined $out, 'regop.pl returned something defined' );
3dab1dad 28
07be1b83 29$out ||= "";
30my $test= 1;
31foreach my $testout ( @tests ) {
32 my ( $pattern )= $testout=~/Compiling REx "([^"]+)"/;
33 ok( $pattern, "Pattern for test " . ($test++) );
8e11feef 34 while (@strs) {
07be1b83 35 local $_= shift @strs;
36 last if !$_
37 or /^---/;
38 next if /^\s*#/;
39 s/^\s+//;
40 s/\s+$//;
41 ok( $testout=~/\Q$_\E/, "$_: /$pattern/" );
8e11feef 42 }
43}
3dab1dad 44
07be1b83 45# The format below is simple. Each line is an exact
46# string that must be found in the output.
47# Lines starting the # are comments.
48# Lines starting with --- are seperators indicating
49# that the tests for this result set are finished.
50# If you add a test make sure you update $NUM_SECTS
51# the commented output is just for legacy/debugging purposes
52BEGIN{ $NUM_SECTS= 6 }
53
3dab1dad 54__END__
55#Compiling REx "X(A|[B]Q||C|D)Y"
56#size 34
57#first at 1
58# 1: EXACT <X>(3)
59# 3: OPEN1(5)
60# 5: TRIE-EXACT(21)
61# [Words:5 Chars:5 Unique:5 States:6 Start-Class:A-D]
62# <A>
63# <BQ>
64# <>
65# <C>
66# <D>
67# 21: CLOSE1(23)
68# 23: EXACT <Y>(25)
69# 25: END(0)
70#anchored "X" at 0 floating "Y" at 1..3 (checking floating) minlen 2
71#Guessing start of match, REx "X(A|[B]Q||C|D)Y" against "XY"...
72#Found floating substr "Y" at offset 1...
73#Found anchored substr "X" at offset 0...
74#Guessed: match at offset 0
75#Matching REx "X(A|[B]Q||C|D)Y" against "XY"
76# Setting an EVAL scope, savestack=140
77# 0 <> <XY> | 1: EXACT <X>
78# 1 <X> <Y> | 3: OPEN1
79# 1 <X> <Y> | 5: TRIE-EXACT
80# matched empty string...
81# 1 <X> <Y> | 21: CLOSE1
82# 1 <X> <Y> | 23: EXACT <Y>
83# 2 <XY> <> | 25: END
84#Match successful!
85#%MATCHED%
86#Freeing REx: "X(A|[B]Q||C|D)Y"
87Compiling REx "X(A|[B]Q||C|D)Y"
88Start-Class:A-D]
89TRIE-EXACT
90<BQ>
91matched empty string
92Match successful!
93Found floating substr "Y" at offset 1...
94Found anchored substr "X" at offset 0...
95Guessed: match at offset 0
96checking floating
97minlen 2
98Words:5
99Unique:5
100States:6
101%MATCHED%
102---
103#Compiling REx "[f][o][o][b][a][r]"
104#size 67
105#first at 1
106# 1: EXACT <foobar>(13)
107# 13: END(0)
108#anchored "foobar" at 0 (checking anchored isall) minlen 6
109#Guessing start of match, REx "[f][o][o][b][a][r]" against "foobar"...
110#Found anchored substr "foobar" at offset 0...
111#Guessed: match at offset 0
112#Freeing REx: "[f][o][o][b][a][r]"
113foobar
114checking anchored isall
115minlen 6
116anchored "foobar" at 0
117Guessed: match at offset 0
118Compiling REx "[f][o][o][b][a][r]"
119Freeing REx: "[f][o][o][b][a][r]"
120%MATCHED%
121---
122#Compiling REx ".[XY]."
123#size 14
124#first at 1
125# 1: REG_ANY(2)
126# 2: ANYOF[XY](13)
127# 13: REG_ANY(14)
128# 14: END(0)
129#minlen 3
130#%FAILED%
131#Freeing REx: ".[XY]."
132%FAILED%
133minlen 3
134---
135#Compiling REx "(?:ABCP|ABCG|ABCE|ABCB|ABCA|ABCD)"
136#size 20 nodes
137# 1: EXACT <ABC>(3)
138# 3: TRIE-EXACT(20)
139# [Start:4 Words:6 Chars:24 Unique:7 States:10 Minlen:1 Maxlen:1 Start-Class:A-EGP]
140# <ABCP>
141# <ABCG>
142# <ABCE>
143# <ABCB>
144# <ABCA>
145# <ABCD>
146# 19: TAIL(20)
147# 20: END(0)
148#minlen 4
149#Matching REx "(?:ABCP|ABCG|ABCE|ABCB|ABCA|ABCD)" against "ABCD"
150# Setting an EVAL scope, savestack=140
151# 0 <> <ABCD> | 1: EXACT <ABC>
152# 3 <ABC> <D> | 3: TRIE-EXACT
153# only one match : #6 <ABCD>
154# 4 <ABCD> <> | 20: END
155#Match successful!
156#POP STATE(1)
157#%MATCHED%
158#Freeing REx: "(?:ABCP|ABCG|ABCE|ABCB|ABCA|ABCD)"
159%MATCHED%
160EXACT <ABC>
161Start-Class:A-EGP
162only one match : #6 <ABCD>
163Start:4
164minlen 4
07be1b83 165---
166#Compiling REx "(\.COM|\.EXE|\.BAT|\.CMD|\.VBS|\.VBE|\.JS|\.JSE|\.WSF|\.WSH|\.pyo|\.pyc|\.pyw|\.py)$"
167#size 48 nodes first at 3
168#first at 3
169#rarest char
170# at 0
171# 1: OPEN1(3)
172# 3: EXACTF <.>(5)
173# 5: TRIE-EXACTF(45)
174# [Start:2 Words:14 Chars:54 Unique:18 States:29 Minlen:2 Maxlen:3 Start-Class:BCEJPVWbcejpvw]
175# <.COM>
176# ... yada yada ... (dmq)
177# <.py>
178# 45: CLOSE1(47)
179# 47: EOL(48)
180# 48: END(0)
181#floating ""$ at 3..4 (checking floating) stclass "EXACTF <.>" minlen 3
182#Offsets: [48]
183# 1:1[1] 3:2[1] 5:2[81] 45:83[1] 47:84[1] 48:85[0]
184#Guessing start of match, REx "(\.COM|\.EXE|\.BAT|\.CMD|\.VBS|\.VBE|\.JS|\.JSE|\.WSF|\.WSH|..." against "D:dev/perl/ver/28321_/perl.exe"...
185#Found floating substr ""$ at offset 30...
186#Starting position does not contradict /^/m...
187#Does not contradict STCLASS...
188#Guessed: match at offset 26
189#Matching REx "(\.COM|\.EXE|\.BAT|\.CMD|\.VBS|\.VBE|\.JS|\.JSE|\.WSF|\.WSH|\.pyo|\.pyc|\.pyw|\.py)$..." against ".exe"
190#Matching stclass "EXACTF <.>" against ".exe"
191# Setting an EVAL scope, savestack=140
192# 26 <21_/perl> <.exe> | 1: OPEN1
193# 26 <21_/perl> <.exe> | 3: EXACTF <.>
194# 27 <21_/perl.> <exe> | 5: TRIE-EXACTF
195# only one match : #2 <.EXE>
196# 30 <21_/perl.exe> <> | 45: CLOSE1
197# 30 <21_/perl.exe> <> | 47: EOL
198# 30 <21_/perl.exe> <> | 48: END
199#Match successful!
200#POP STATE(1)
201#%MATCHED%
202#Freeing REx: "(\\.COM|\\.EXE|\\.BAT|\\.CMD|\\.VBS|\\.VBE|\\.JS|\\.JSE|\\."......
203%MATCHED%
204floating ""$ at 3..4 (checking floating)
2051:1[1] 3:2[1] 5:2[81] 45:83[1] 47:84[1] 48:85[0]
206stclass "EXACTF <.>" minlen 3
207Found floating substr ""$ at offset 30...
208Does not contradict STCLASS...
209Guessed: match at offset 26
210Matching stclass "EXACTF <.>" against ".exe"
211---
212#Compiling REx "[q]"
213#size 12 nodes Got 100 bytes for offset annotations.
214#first at 1
215#Final program:
216# 1: EXACT <q>(3)
217# 3: END(0)
218#anchored "q" at 0 (checking anchored isall) minlen 1
219#Offsets: [12]
220# 1:1[3] 3:4[0]
221#Guessing start of match, REx "[q]" against "q"...
222#Found anchored substr "q" at offset 0...
223#Guessed: match at offset 0
224#%MATCHED%
225#Freeing REx: "[q]"
226Got 100 bytes for offset annotations.
227Offsets: [12]
2281:1[3] 3:4[0]
229%MATCHED%