Commit | Line | Data |
c235cd98 |
1 | #!/usr/bin/perl |
2 | |
3 | use Test::More tests => 10; |
4 | |
5 | # for classes ... |
6 | { |
7 | package Foo; |
8 | use Moose; |
d03bd989 |
9 | |
c235cd98 |
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'); |
d03bd989 |
13 | |
c235cd98 |
14 | { |
15 | my $warn; |
16 | local $SIG{__WARN__} = sub { $warn = $_[0] }; |
17 | |
18 | ::ok(!$warn, '... no warning yet'); |
d03bd989 |
19 | |
c235cd98 |
20 | eval 'my $bar = 1 + "hello"'; |
d03bd989 |
21 | |
c235cd98 |
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 Moose::Role; |
d03bd989 |
31 | |
c235cd98 |
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'); |
d03bd989 |
35 | |
c235cd98 |
36 | { |
37 | my $warn; |
38 | local $SIG{__WARN__} = sub { $warn = $_[0] }; |
39 | |
40 | ::ok(!$warn, '... no warning yet'); |
d03bd989 |
41 | |
c235cd98 |
42 | eval 'my $bar = 1 + "hello"'; |
d03bd989 |
43 | |
c235cd98 |
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 | } |