X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F010_basics%2F007_always_strict_warnings.t;h=454891e864a3215481d6fc5e55e42205af78a88f;hb=06d16be025b59d5bb71c237c6ab27c6053c2b615;hp=bcac52284503e0cd23b62bd3cbb3784929881345;hpb=d03bd989b97597428b460d7f9a021e2931893fa0;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 bcac522..454891e 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; # for classes ... { @@ -22,6 +22,22 @@ 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 Moose; + undef $@; + eval '$foo = 5;'; + ::ok(!$@, "... no error after no Moose"); + + { + my $warn; + local $SIG{__WARN__} = sub { $warn = $_[0] }; + + ::ok(!$warn, '... no warning yet'); + + eval 'my $bar = 1 + "hello"'; + + ::ok(!$warn, '... still no warning'); + } } # and for roles ... @@ -44,4 +60,60 @@ 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 + + no Moose::Role; + undef $@; + eval '$foo = 5;'; + ::ok(!$@, "... no error after no Moose::Role"); + + { + my $warn; + local $SIG{__WARN__} = sub { $warn = $_[0] }; + + ::ok(!$warn, '... no warning yet'); + + eval 'my $bar = 1 + "hello"'; + + ::ok(!$warn, '... still no warning'); + } +} + +# and for exporters +{ + package Bar; + use Moose::Exporter; + + eval '$foo2 = 5;'; + ::ok($@, '... got an error because strict is on'); + ::like($@, qr/Global symbol \"\$foo2\" 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 Moose::Exporter; + undef $@; + eval '$foo = 5;'; + ::ok(!$@, "... no error after no Moose::Exporter"); + + { + my $warn; + local $SIG{__WARN__} = sub { $warn = $_[0] }; + + ::ok(!$warn, '... no warning yet'); + + eval 'my $bar = 1 + "hello"'; + + ::ok(!$warn, '... still no warning'); + } +} + +done_testing;