5 if (($Config::Config{'extensions'} !~ /\bre\b/) ){
6 print "1..0 # Skip -- Perl configured without re module\n";
13 use Test::More tests => 62;
15 my @flags = qw( a d l u );
18 ok "Foo" =~ /foo/, 'use re "/i"';
19 ok "Foo" =~ /(??{'foo'})/, 'use re "/i" (??{})';
21 ok "Foo" !~ /foo/, 'no re "/i"';
22 ok "Foo" !~ /(??{'foo'})/, 'no re "/i" (??{})';
24 ok "foo" =~ / foo /, 'use re "/x"';
25 ok "foo" =~ / (??{' foo '}) /, 'use re "/x" (??{})';
27 ok "foo" !~ / foo /, 'no re "/x"';
28 ok "foo" !~ /(??{' foo '})/, 'no re "/x" (??{})';
29 ok "foo" !~ / (??{'foo'}) /, 'no re "/x" (??{})';
31 ok "\n" =~ /./, 'use re "/s"';
32 ok "\n" =~ /(??{'.'})/, 'use re "/s" (??{})';
34 ok "\n" !~ /./, 'no re "/s"';
35 ok "\n" !~ /(??{'.'})/, 'no re "/s" (??{})';
37 ok "\nfoo" =~ /^foo/, 'use re "/m"';
38 ok "\nfoo" =~ /(??{'^'})foo/, 'use re "/m" (??{})';
40 ok "\nfoo" !~ /^foo/, 'no re "/m"';
41 ok "\nfoo" !~ /(??{'^'})foo/, 'no re "/m" (??{})';
44 ok qr// =~ /(?=.*x)(?=.*i)(?=.*s)(?=.*m)/, 'use re "/multiple"';
46 ok qr// =~ /(?!.*x)(?!.*i)(?=.*s)(?=.*m)/, 'no re "/i" only turns off /ix';
51 ok 'frelp' =~ /f r e l p/, "use re '/x' in a lexical scope"
53 ok 'f r e l p' =~ /f r e l p/,
54 "use re '/x' turns off when it drops out of scope";
58 !$Config::Config{d_setlocale}
59 || $Config::Config{ccflags} =~ /\bD?NO_LOCALE\b/
61 skip "no locale support", 7
65 is qr//, '(?^u:)', 'use re "/u" with active locale';
67 is qr//, '(?^l:)', 'no re "/u" reverts to /l with locale in scope';
69 is qr//, '(?^l:)', 'no re "/l" is a no-op with locale in scope';
71 is qr//, '(?^:)', 'use re "/d" with locale in scope';
75 'no re "/l" and "/u" are no-ops when not on (locale scope)';
77 is qr//, '(?^l:)', 'no re "/d" reverts to /l with locale in scope';
80 is qr//, '(?^u:)', 'no re "/d" is a no-op when not on (locale scope)';
84 use feature "unicode_strings";
86 is qr//, '(?^:)', 'use re "/d" in Unicode scope';
88 is qr//, '(?^u:)', 'no re "/d" reverts to /u in Unicode scope';
90 is qr//, '(?^u:)', 'no re "/u" is a no-op in Unicode scope';
92 is qr//, '(?^u:)', 'no re "/d" is a no-op when not on';
94 no feature 'unicode_strings';
95 is qr//, '(?^u:)', 'use re "/u" is not tied to unicode_strings feature';
99 is qr//, '(?^u:)', 'use re "/u"';
101 is qr//, '(?^:)', 'no re "/u" reverts to /d';
103 is qr//, '(?^:)', 'no re "/u" is a no-op when not on';
105 is qr//, '(?^:)', 'no re "/d" is a no-op when not on';
108 local $SIG{__WARN__} = sub {
109 ok $_[0] =~ /Unknown regular expression flag "\x{100}"/,
110 "warning with unknown regexp flags in use re '/flags'"
115 # use re '/flags' in combination with explicit flags
117 ok "A\n\n" =~ / a.$/sm, 'use re "/xi" in combination with explicit /sm';
120 is qr//d, '(?^ix:)', 'explicit /d in re "/u" scope';
122 is qr//u, '(?^uix:)', 'explicit /u in re "/d" scope';
126 # Verify one and two a's work
128 is qr//, '(?^ai:)', 'use re "/ia"';
130 is qr//, '(?^:)', 'no re "/ia"';
132 is qr//, '(?^aai:)', 'use re "/aai"';
134 is qr//, '(?^:)', 'no re "/aai"';
136 # use re "/adul" combinations
139 local $SIG{__WARN__} = sub { $w = shift };
143 eval "use re '/$i$j'";
146 is ($w, "", "no warning with use re \"/aa\", $w");
149 like $w, qr/The \"$i\" flag may not appear twice/,
150 "warning with use re \"/$i$i\"";
155 # If one is a subset of the other, re.pm uses the longest one.
156 like $w, qr/The "$j" and "$i" flags are exclusive/,
157 "warning with eval \"use re \"/$j$i\"";
160 like $w, qr/The "$i" and "$j" flags are exclusive/,
161 "warning with eval \"use re \"/$i$j\"";
168 eval "use re '/axaa'";
169 like $w, qr/The "a" flag may only appear a maximum of twice/,
170 "warning with eval \"use re \"/axaa\"";