Warn about false ranges like \d-\w (see the change #4355).
[p5sagit/p5-mst-13.2.git] / t / pragma / warn / regcomp
1   regcomp.c     AOK
2
3   Strange *+?{} on zero-length expression       [S_study_chunk]
4         /(?=a)?/
5
6   %.*s matches null string many times           [S_regpiece]
7         $a = "ABC123" ; $a =~ /(?=a)*/'
8
9   /%.127s/: Unrecognized escape \\%c passed through"    [S_regatom] 
10         /\m/
11
12   Character class syntax [. .] is reserved for future extensions [S_regpposixcc]
13
14   Character class syntax [= =] is reserved for future extensions [S_checkposixcc]
15
16   Character class syntax [%c %c] belongs inside character classes [S_checkposixcc] 
17   
18   /%.127s/: false [] range \"%*.*s\" in regexp [S_regclass]
19
20   /%.127s/: false [] range \"%*.*s\" in regexp [S_regclassutf8]
21
22 __END__
23 # regcomp.c [S_regpiece]
24 use warnings 'unsafe' ;
25 my $a = "ABC123" ; 
26 $a =~ /(?=a)*/ ;
27 no warnings 'unsafe' ;
28 $a =~ /(?=a)*/ ;
29 EXPECT
30 (?=a)* matches null string many times at - line 4.
31 ########
32 # regcomp.c [S_study_chunk]
33 use warnings 'unsafe' ;
34 $_ = "" ;
35 /(?=a)?/;
36 no warnings 'unsafe' ;
37 /(?=a)?/;
38 EXPECT
39 Strange *+?{} on zero-length expression at - line 4.
40 ########
41 # regcomp.c [S_regatom]
42 use warnings 'unsafe' ;
43 $a =~ /\m/ ;
44 no warnings 'unsafe' ;
45 EXPECT
46 Unrecognized escape \m passed through at - line 3.
47 ########
48 # regcomp.c [S_regpposixcc S_checkposixcc]
49 use warnings 'unsafe' ;
50 $_ = "" ;
51 /[:alpha:]/;
52 /[.bar.]/;
53 /[=zog=]/;
54 /[[:alpha:]]/;
55 /[[.foo.]]/;
56 /[[=bar=]]/;
57 /[:zog:]/;
58 no warnings 'unsafe' ;
59 /[:alpha:]/;
60 /[.foo.]/;
61 /[=bar=]/;
62 /[[:alpha:]]/;
63 /[[.foo.]]/;
64 /[[=bar=]]/;
65 /[:zog:]/;
66 /[[:zog:]]/;
67 EXPECT
68 Character class syntax [: :] belongs inside character classes at - line 4.
69 Character class syntax [. .] belongs inside character classes at - line 5.
70 Character class syntax [. .] is reserved for future extensions at - line 5.
71 Character class syntax [= =] belongs inside character classes at - line 6.
72 Character class syntax [= =] is reserved for future extensions at - line 6.
73 Character class syntax [. .] is reserved for future extensions at - line 8.
74 Character class syntax [= =] is reserved for future extensions at - line 9.
75 Character class syntax [: :] belongs inside character classes at - line 10.
76 Character class [:zog:] unknown at - line 19.
77 ########
78 # regcomp.c [S_regclass]
79 $_ = "";
80 use warnings 'unsafe' ;
81 /[a-b]/;
82 /[a-\d]/;
83 /[\d-b]/;
84 /[\s-\d]/;
85 /[\d-\s]/;
86 /[a-[:digit:]]/;
87 /[[:digit:]-b]/;
88 /[[:alpha:]-[:digit:]]/;
89 /[[:digit:]-[:alpha:]]/;
90 no warnings 'unsafe' ;
91 /[a-b]/;
92 /[a-\d]/;
93 /[\d-b]/;
94 /[\s-\d]/;
95 /[\d-\s]/;
96 /[a-[:digit:]]/;
97 /[[:digit:]-b]/;
98 /[[:alpha:]-[:digit:]]/;
99 /[[:digit:]-[:alpha:]]/;
100 EXPECT
101 /[a-\d]/: false [] range "a-\d" in regexp at - line 5.
102 /[\d-b]/: false [] range "\d-" in regexp at - line 6.
103 /[\s-\d]/: false [] range "\s-" in regexp at - line 7.
104 /[\d-\s]/: false [] range "\d-" in regexp at - line 8.
105 /[a-[:digit:]]/: false [] range "a-[:digit:]" in regexp at - line 9.
106 /[[:digit:]-b]/: false [] range "[:digit:]-" in regexp at - line 10.
107 /[[:alpha:]-[:digit:]]/: false [] range "[:alpha:]-" in regexp at - line 11.
108 /[[:digit:]-[:alpha:]]/: false [] range "[:digit:]-" in regexp at - line 12.
109 ########
110 # regcomp.c [S_regclassutf8]
111 use utf8;
112 $_ = "";
113 use warnings 'unsafe' ;
114 /[a-b]/;
115 /[a-\d]/;
116 /[\d-b]/;
117 /[\s-\d]/;
118 /[\d-\s]/;
119 /[a-[:digit:]]/;
120 /[[:digit:]-b]/;
121 /[[:alpha:]-[:digit:]]/;
122 /[[:digit:]-[:alpha:]]/;
123 no warnings 'unsafe' ;
124 /[a-b]/;
125 /[a-\d]/;
126 /[\d-b]/;
127 /[\s-\d]/;
128 /[\d-\s]/;
129 /[a-[:digit:]]/;
130 /[[:digit:]-b]/;
131 /[[:alpha:]-[:digit:]]/;
132 /[[:digit:]-[:alpha:]]/;
133 EXPECT
134 /[a-\d]/: false [] range "a-\d" in regexp at - line 6.
135 /[\d-b]/: false [] range "\d-" in regexp at - line 7.
136 /[\s-\d]/: false [] range "\s-" in regexp at - line 8.
137 /[\d-\s]/: false [] range "\d-" in regexp at - line 9.
138 /[a-[:digit:]]/: false [] range "a-[:digit:]" in regexp at - line 10.
139 /[[:digit:]-b]/: false [] range "[:digit:]-" in regexp at - line 11.
140 /[[:alpha:]-[:digit:]]/: false [] range "[:alpha:]-" in regexp at - line 12.
141 /[[:digit:]-[:alpha:]]/: false [] range "[:digit:]-" in regexp at - line 13.