summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorToby Inkster <mail@tobyinkster.co.uk>2013-12-12 12:20:06 +0000
committerToby Inkster <mail@tobyinkster.co.uk>2013-12-12 12:20:06 +0000
commitf8a0b32bbd836d4ac83df21f3ffab9b8f969919b (patch)
tree525d8e533b83119d75433875838fc37eb7fa5e69 /t
parent62d4e41a10d185a3c72633d5f26d14b634474078 (diff)
support for "does" in attribute spec
Diffstat (limited to 't')
-rw-r--r--t/08doesrole.t60
1 files changed, 60 insertions, 0 deletions
diff --git a/t/08doesrole.t b/t/08doesrole.t
new file mode 100644
index 0000000..a880531
--- /dev/null
+++ b/t/08doesrole.t
@@ -0,0 +1,60 @@
+=pod
+
+=encoding utf-8
+
+=head1 PURPOSE
+
+See if C<< does => $rolename >> works.
+
+=head1 AUTHOR
+
+Toby Inkster E<lt>tobyink@cpan.orgE<gt>.
+
+=head1 COPYRIGHT AND LICENCE
+
+This software is copyright (c) 2013 by Toby Inkster.
+
+This is free software; you can redistribute it and/or modify it under
+the same terms as the Perl 5 programming language system itself.
+
+=cut
+
+use strict;
+use warnings;
+use Test::More;
+use Test::Fatal;
+
+{
+ package Bar;
+ use Moo::Role;
+}
+
+{
+ package Foo::Bar;
+ use Moo;
+ with 'Bar';
+}
+
+{
+ package Foo::Baz;
+ use Moo;
+}
+
+{
+ package Quux;
+ use Moo;
+ use MooX::late;
+ has xxx => (is => 'ro', does => 'Bar');
+}
+
+is(
+ exception { Quux->new(xxx => Foo::Bar->new) },
+ undef,
+);
+
+like(
+ exception { Quux->new(xxx => Foo::Baz->new) },
+ qr/did not pass type constraint/,
+);
+
+done_testing;