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; |
8e11feef |
14 | require "./test.pl"; |
3dab1dad |
15 | |
16 | chomp(my @strs=grep { !/^\s*\#/ } <DATA>); |
8e11feef |
17 | my $out = runperl(progfile => "../ext/re/t/regop.pl", stderr => 1); |
18 | my @tests = grep { /\S/ && !/EXECUTING/ } split /(?=Compiling REx)/,$out; |
3dab1dad |
19 | |
8e11feef |
20 | plan(2 + (@strs - grep { !$_ or /^---/ } @strs) + @tests); |
3dab1dad |
21 | |
22 | my $numtests=4; |
8e11feef |
23 | is(scalar @tests, $numtests, "Expecting output for $numtests patterns"); |
3dab1dad |
24 | ok(defined $out,'regop.pl'); |
25 | $out||=""; |
26 | my $test=1; |
27 | foreach my $testout (@tests) { |
28 | my ($pattern)=$testout=~/Compiling REx "([^"]+)"/; |
8e11feef |
29 | ok($pattern, "Pattern found for test ".($test++)); |
30 | while (@strs) { |
3dab1dad |
31 | my $str=shift @strs; |
32 | last if !$str or $str=~/^---/; |
33 | next if $str=~/^\s*#/; |
8e11feef |
34 | ok($testout=~/\Q$str\E/,"$str: /$pattern/"); |
35 | } |
36 | } |
3dab1dad |
37 | |
38 | __END__ |
39 | #Compiling REx "X(A|[B]Q||C|D)Y" |
40 | #size 34 |
41 | #first at 1 |
42 | # 1: EXACT <X>(3) |
43 | # 3: OPEN1(5) |
44 | # 5: TRIE-EXACT(21) |
45 | # [Words:5 Chars:5 Unique:5 States:6 Start-Class:A-D] |
46 | # <A> |
47 | # <BQ> |
48 | # <> |
49 | # <C> |
50 | # <D> |
51 | # 21: CLOSE1(23) |
52 | # 23: EXACT <Y>(25) |
53 | # 25: END(0) |
54 | #anchored "X" at 0 floating "Y" at 1..3 (checking floating) minlen 2 |
55 | #Guessing start of match, REx "X(A|[B]Q||C|D)Y" against "XY"... |
56 | #Found floating substr "Y" at offset 1... |
57 | #Found anchored substr "X" at offset 0... |
58 | #Guessed: match at offset 0 |
59 | #Matching REx "X(A|[B]Q||C|D)Y" against "XY" |
60 | # Setting an EVAL scope, savestack=140 |
61 | # 0 <> <XY> | 1: EXACT <X> |
62 | # 1 <X> <Y> | 3: OPEN1 |
63 | # 1 <X> <Y> | 5: TRIE-EXACT |
64 | # matched empty string... |
65 | # 1 <X> <Y> | 21: CLOSE1 |
66 | # 1 <X> <Y> | 23: EXACT <Y> |
67 | # 2 <XY> <> | 25: END |
68 | #Match successful! |
69 | #%MATCHED% |
70 | #Freeing REx: "X(A|[B]Q||C|D)Y" |
71 | Compiling REx "X(A|[B]Q||C|D)Y" |
72 | Start-Class:A-D] |
73 | TRIE-EXACT |
74 | <BQ> |
75 | matched empty string |
76 | Match successful! |
77 | Found floating substr "Y" at offset 1... |
78 | Found anchored substr "X" at offset 0... |
79 | Guessed: match at offset 0 |
80 | checking floating |
81 | minlen 2 |
82 | Words:5 |
83 | Unique:5 |
84 | States:6 |
85 | %MATCHED% |
86 | --- |
87 | #Compiling REx "[f][o][o][b][a][r]" |
88 | #size 67 |
89 | #first at 1 |
90 | # 1: EXACT <foobar>(13) |
91 | # 13: END(0) |
92 | #anchored "foobar" at 0 (checking anchored isall) minlen 6 |
93 | #Guessing start of match, REx "[f][o][o][b][a][r]" against "foobar"... |
94 | #Found anchored substr "foobar" at offset 0... |
95 | #Guessed: match at offset 0 |
96 | #Freeing REx: "[f][o][o][b][a][r]" |
97 | foobar |
98 | checking anchored isall |
99 | minlen 6 |
100 | anchored "foobar" at 0 |
101 | Guessed: match at offset 0 |
102 | Compiling REx "[f][o][o][b][a][r]" |
103 | Freeing REx: "[f][o][o][b][a][r]" |
104 | %MATCHED% |
105 | --- |
106 | #Compiling REx ".[XY]." |
107 | #size 14 |
108 | #first at 1 |
109 | # 1: REG_ANY(2) |
110 | # 2: ANYOF[XY](13) |
111 | # 13: REG_ANY(14) |
112 | # 14: END(0) |
113 | #minlen 3 |
114 | #%FAILED% |
115 | #Freeing REx: ".[XY]." |
116 | %FAILED% |
117 | minlen 3 |
118 | --- |
119 | #Compiling REx "(?:ABCP|ABCG|ABCE|ABCB|ABCA|ABCD)" |
120 | #size 20 nodes |
121 | # 1: EXACT <ABC>(3) |
122 | # 3: TRIE-EXACT(20) |
123 | # [Start:4 Words:6 Chars:24 Unique:7 States:10 Minlen:1 Maxlen:1 Start-Class:A-EGP] |
124 | # <ABCP> |
125 | # <ABCG> |
126 | # <ABCE> |
127 | # <ABCB> |
128 | # <ABCA> |
129 | # <ABCD> |
130 | # 19: TAIL(20) |
131 | # 20: END(0) |
132 | #minlen 4 |
133 | #Matching REx "(?:ABCP|ABCG|ABCE|ABCB|ABCA|ABCD)" against "ABCD" |
134 | # Setting an EVAL scope, savestack=140 |
135 | # 0 <> <ABCD> | 1: EXACT <ABC> |
136 | # 3 <ABC> <D> | 3: TRIE-EXACT |
137 | # only one match : #6 <ABCD> |
138 | # 4 <ABCD> <> | 20: END |
139 | #Match successful! |
140 | #POP STATE(1) |
141 | #%MATCHED% |
142 | #Freeing REx: "(?:ABCP|ABCG|ABCE|ABCB|ABCA|ABCD)" |
143 | %MATCHED% |
144 | EXACT <ABC> |
145 | Start-Class:A-EGP |
146 | only one match : #6 <ABCD> |
147 | Start:4 |
148 | minlen 4 |