X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F010_basics%2F007_always_strict_warnings.t;h=a10d94a05fc92f7e5e36710525f6cd51e5ea2b90;hb=dcc8dc06beda4bdd071af770d3ee130619bcce9d;hp=b81588cf99b2faeca98cef7ca398a9ac506b3eae;hpb=e59a5c292a333cac504b65ebd4bba20b5e98d796;p=gitmo%2FMoose.git diff --git a/t/010_basics/007_always_strict_warnings.t b/t/010_basics/007_always_strict_warnings.t index b81588c..a10d94a 100644 --- a/t/010_basics/007_always_strict_warnings.t +++ b/t/010_basics/007_always_strict_warnings.t @@ -1,24 +1,24 @@ #!/usr/bin/perl -use Test::More tests => 10; +use Test::More; # for classes ... { package Foo; use Moose; - + eval '$foo = 5;'; ::ok($@, '... got an error because strict is on'); ::like($@, qr/Global symbol \"\$foo\" requires explicit package name at/, '... got the right error'); - + { my $warn; local $SIG{__WARN__} = sub { $warn = $_[0] }; ::ok(!$warn, '... no warning yet'); - + eval 'my $bar = 1 + "hello"'; - + ::ok($warn, '... got a warning'); ::like($warn, qr/Argument \"hello\" isn\'t numeric in addition \(\+\)/, '.. and it is the right warning'); } @@ -28,20 +28,44 @@ use Test::More tests => 10; { package Bar; use Moose::Role; - + + eval '$foo = 5;'; + ::ok($@, '... got an error because strict is on'); + ::like($@, qr/Global symbol \"\$foo\" requires explicit package name at/, '... got the right error'); + + { + my $warn; + local $SIG{__WARN__} = sub { $warn = $_[0] }; + + ::ok(!$warn, '... no warning yet'); + + eval 'my $bar = 1 + "hello"'; + + ::ok($warn, '... got a warning'); + ::like($warn, qr/Argument \"hello\" isn\'t numeric in addition \(\+\)/, '.. and it is the right warning'); + } +} + +# and for exporters +{ + package Bar; + use Moose::Exporter; + eval '$foo = 5;'; ::ok($@, '... got an error because strict is on'); ::like($@, qr/Global symbol \"\$foo\" requires explicit package name at/, '... got the right error'); - + { my $warn; local $SIG{__WARN__} = sub { $warn = $_[0] }; ::ok(!$warn, '... no warning yet'); - + eval 'my $bar = 1 + "hello"'; - + ::ok($warn, '... got a warning'); ::like($warn, qr/Argument \"hello\" isn\'t numeric in addition \(\+\)/, '.. and it is the right warning'); } -} \ No newline at end of file +} + +done_testing;