This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Regen headers following change 28325. Also, make it compile
[perl5.git] / ext / re / t / regop.t
CommitLineData
3dab1dad
YO
1#!./perl
2
3BEGIN {
8e11feef
RGS
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
YO
11}
12
13use strict;
8e11feef 14require "./test.pl";
3dab1dad
YO
15
16chomp(my @strs=grep { !/^\s*\#/ } <DATA>);
8e11feef
RGS
17my $out = runperl(progfile => "../ext/re/t/regop.pl", stderr => 1);
18my @tests = grep { /\S/ && !/EXECUTING/ } split /(?=Compiling REx)/,$out;
3dab1dad 19
8e11feef 20plan(2 + (@strs - grep { !$_ or /^---/ } @strs) + @tests);
3dab1dad
YO
21
22my $numtests=4;
8e11feef 23is(scalar @tests, $numtests, "Expecting output for $numtests patterns");
3dab1dad
YO
24ok(defined $out,'regop.pl');
25$out||="";
26my $test=1;
27foreach my $testout (@tests) {
28 my ($pattern)=$testout=~/Compiling REx "([^"]+)"/;
8e11feef
RGS
29 ok($pattern, "Pattern found for test ".($test++));
30 while (@strs) {
3dab1dad
YO
31 my $str=shift @strs;
32 last if !$str or $str=~/^---/;
33 next if $str=~/^\s*#/;
8e11feef
RGS
34 ok($testout=~/\Q$str\E/,"$str: /$pattern/");
35 }
36}
3dab1dad
YO
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"
71Compiling REx "X(A|[B]Q||C|D)Y"
72Start-Class:A-D]
73TRIE-EXACT
74<BQ>
75matched empty string
76Match successful!
77Found floating substr "Y" at offset 1...
78Found anchored substr "X" at offset 0...
79Guessed: match at offset 0
80checking floating
81minlen 2
82Words:5
83Unique:5
84States: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]"
97foobar
98checking anchored isall
99minlen 6
100anchored "foobar" at 0
101Guessed: match at offset 0
102Compiling REx "[f][o][o][b][a][r]"
103Freeing 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%
117minlen 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%
144EXACT <ABC>
145Start-Class:A-EGP
146only one match : #6 <ABCD>
147Start:4
148minlen 4