From: Jesse Luehrs Date: Sun, 3 May 2009 00:12:47 +0000 (-0500) Subject: test that "use Moose::Exporter" imports strict and warnings X-Git-Tag: 0.78~56 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6fde788b2d3167a6bf733ce2c95c1acc3da8f5b4;p=gitmo%2FMoose.git test that "use Moose::Exporter" imports strict and warnings --- diff --git a/t/010_basics/007_always_strict_warnings.t b/t/010_basics/007_always_strict_warnings.t index bcac522..8112ed4 100644 --- a/t/010_basics/007_always_strict_warnings.t +++ b/t/010_basics/007_always_strict_warnings.t @@ -1,6 +1,6 @@ #!/usr/bin/perl -use Test::More tests => 10; +use Test::More tests => 15; # for classes ... { @@ -44,4 +44,26 @@ use Test::More tests => 10; ::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 +} + +# 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'); + } +}