diff options
author | Jesse Luehrs <doy@tozt.net> | 2010-07-19 19:10:14 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2010-07-19 19:10:14 -0500 |
commit | 636f22f307ff0dc94a2c2ec23d49c872ecddbc02 (patch) | |
tree | dab6dc4bc564c61d6a1ace5727238574cfd5ce2b /t/moose/007_always_strict_warnings.t | |
parent | bdd9773b60d3cf2cceea43b4aa1dacd9ed5d492b (diff) | |
download | moosex-exporter-easy-636f22f307ff0dc94a2c2ec23d49c872ecddbc02.tar.gz moosex-exporter-easy-636f22f307ff0dc94a2c2ec23d49c872ecddbc02.zip |
initial implementation
Diffstat (limited to 't/moose/007_always_strict_warnings.t')
-rw-r--r-- | t/moose/007_always_strict_warnings.t | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/t/moose/007_always_strict_warnings.t b/t/moose/007_always_strict_warnings.t new file mode 100644 index 0000000..c09e9d7 --- /dev/null +++ b/t/moose/007_always_strict_warnings.t @@ -0,0 +1,71 @@ +#!/usr/bin/perl + +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'); + } +} + +# and for roles ... +{ + 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 MooseX::Exporter::Easy; + + 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'); + } +} + +done_testing; |