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