1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#!./perl
# Most of the strict effects are tested for in t/re/reg_mesgs.t
BEGIN {
require Config;
if (($Config::Config{'extensions'} !~ /\bre\b/) ){
print "1..0 # Skip -- Perl configured without re module\n";
exit 0;
}
}
use strict;
use Test::More tests => 10;
BEGIN { require_ok( 're' ); }
{
my @w;
no warnings;
local $SIG{__WARN__};
BEGIN { $SIG{__WARN__} = sub { push @w, @_ } };
qr/\b*/;
BEGIN { is(scalar @w, 0, 'No default-on warnings for qr/\b*/'); }
BEGIN {undef @w; }
{
use re 'strict';
qr/\b*/;
BEGIN { is(scalar @w, 1, 'use re "strict" turns on warnings'); }
BEGIN { undef @w; }
no re 'strict';
qr/\b*/;
BEGIN { is(scalar @w, 0, 'no re "strict" restores warnings state'); }
}
BEGIN {undef @w; }
qr/\b*/;
BEGIN { is(scalar @w, 0, 'dropping out of "strict" scope reverts warnings default'); }
{
use re 'strict';
qr/\b*/;
BEGIN { is(scalar @w, 1, 'use re "strict" turns on warnings'); }
no re 'strict';
BEGIN {undef @w; }
qr/\b*/;
BEGIN { is(scalar @w, 0, 'turning off "strict" scope reverts warnings default'); }
}
{
use warnings 'regexp';
BEGIN {undef @w; }
qr/\b*/;
BEGIN { is(scalar @w, 1, 'use warnings "regexp" works'); }
use re 'strict';
BEGIN {undef @w; }
qr/\b*/;
BEGIN { is(scalar @w, 1, 'use re "strict" keeps warnings on'); }
no re 'strict';
BEGIN {undef @w; }
qr/\b*/;
BEGIN { is(scalar @w, 1, 'turning off "strict" scope doesn\'t affect warnings that were already on'); }
}
}
|