Commit | Line | Data |
60ad2cb7 |
1 | #!/usr/bin/perl |
2 | |
9864f0e4 |
3 | use Test::More tests => 15; |
60ad2cb7 |
4 | |
5 | # for classes ... |
6 | { |
7 | package Foo; |
8 | use Mouse; |
9 | |
10 | eval '$foo = 5;'; |
11 | ::ok($@, '... got an error because strict is on'); |
12 | ::like($@, qr/Global symbol \"\$foo\" requires explicit package name at/, '... got the right error'); |
13 | |
14 | { |
15 | my $warn; |
16 | local $SIG{__WARN__} = sub { $warn = $_[0] }; |
17 | |
18 | ::ok(!$warn, '... no warning yet'); |
19 | |
20 | eval 'my $bar = 1 + "hello"'; |
21 | |
22 | ::ok($warn, '... got a warning'); |
23 | ::like($warn, qr/Argument \"hello\" isn\'t numeric in addition \(\+\)/, '.. and it is the right warning'); |
24 | } |
25 | } |
26 | |
27 | # and for roles ... |
28 | { |
29 | package Bar; |
30 | use Mouse::Role; |
31 | |
32 | eval '$foo = 5;'; |
33 | ::ok($@, '... got an error because strict is on'); |
34 | ::like($@, qr/Global symbol \"\$foo\" requires explicit package name at/, '... got the right error'); |
35 | |
36 | { |
37 | my $warn; |
38 | local $SIG{__WARN__} = sub { $warn = $_[0] }; |
39 | |
40 | ::ok(!$warn, '... no warning yet'); |
41 | |
42 | eval 'my $bar = 1 + "hello"'; |
43 | |
44 | ::ok($warn, '... got a warning'); |
45 | ::like($warn, qr/Argument \"hello\" isn\'t numeric in addition \(\+\)/, '.. and it is the right warning'); |
46 | } |
47 | } |
60ad2cb7 |
48 | |
49 | # and for exporters |
50 | { |
51 | package Bar; |
52 | use Mouse::Exporter; |
53 | |
54 | eval '$foo = 5;'; |
55 | ::ok($@, '... got an error because strict is on'); |
56 | ::like($@, qr/Global symbol \"\$foo\" requires explicit package name at/, '... got the right error'); |
57 | |
58 | { |
59 | my $warn; |
60 | local $SIG{__WARN__} = sub { $warn = $_[0] }; |
61 | |
62 | ::ok(!$warn, '... no warning yet'); |
63 | |
64 | eval 'my $bar = 1 + "hello"'; |
65 | |
66 | ::ok($warn, '... got a warning'); |
67 | ::like($warn, qr/Argument \"hello\" isn\'t numeric in addition \(\+\)/, '.. and it is the right warning'); |
68 | } |
69 | } |