diff options
author | Toby Inkster <mail@tobyinkster.co.uk> | 2012-12-03 09:42:14 +0000 |
---|---|---|
committer | Toby Inkster <mail@tobyinkster.co.uk> | 2012-12-03 09:42:14 +0000 |
commit | 0fac1b40360f5e534a76b87fa3307715e718073f (patch) | |
tree | 2fedff3fdacb9c8f0ce0e99c3814cf6dbdc5618f /t | |
parent | 072fe20c998fecb3042099548ab20c5c759c93d0 (diff) |
output warnings about unknown type constraints
Diffstat (limited to 't')
-rw-r--r-- | t/03invalid_tc.t | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/t/03invalid_tc.t b/t/03invalid_tc.t new file mode 100644 index 0000000..d6dff14 --- /dev/null +++ b/t/03invalid_tc.t @@ -0,0 +1,28 @@ +use if !eval { require Test::Warn }, + 'Test::More', skip_all => 'requires Test::Warn'; +use Test::Warn; +use Test::More; + +{ + package Foo; + use Moo; + use MooX::late; + has foo => (is => 'ro', isa => 'X Y Z', required => 0); +} + +# type constraint should not be checked, so no warning expected +warnings_are { + my $foo = Foo->new(); +} []; + +# But this should warn +warnings_like { + my $foo = Foo->new(foo => 1); +} qr{Type constraint 'X Y Z' not fully enforced \(defined at .+/03invalid_tc\.t:10, package Foo\)}; + +# But we shouldn't get the same warning again. Too much noise! +warnings_are { + my $foo = Foo->new(foo => 1); +} []; + +done_testing; |