summaryrefslogtreecommitdiff
path: root/t/moose_util/with_traits.t
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2015-06-06 17:50:16 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2015-06-06 17:50:16 +0000
commit5ac2026f7eed78958d69d051e7a8e993dcf51205 (patch)
tree298c3d2f08bdfe5689998b11892d72a897985be1 /t/moose_util/with_traits.t
downloadMoose-tarball-5ac2026f7eed78958d69d051e7a8e993dcf51205.tar.gz
Diffstat (limited to 't/moose_util/with_traits.t')
-rw-r--r--t/moose_util/with_traits.t50
1 files changed, 50 insertions, 0 deletions
diff --git a/t/moose_util/with_traits.t b/t/moose_util/with_traits.t
new file mode 100644
index 0000000..6388eeb
--- /dev/null
+++ b/t/moose_util/with_traits.t
@@ -0,0 +1,50 @@
+use strict;
+use warnings;
+use Test::More;
+use Test::Moose;
+
+use Moose ();
+use Moose::Util qw(with_traits);
+
+{
+ package Foo;
+ use Moose;
+}
+
+{
+ package Foo::Role;
+ use Moose::Role;
+}
+
+{
+ package Foo::Role2;
+ use Moose::Role;
+}
+
+{
+ my $traited_class = with_traits('Foo', 'Foo::Role');
+ ok($traited_class->meta->is_anon_class, "we get an anon class");
+ isa_ok($traited_class, 'Foo');
+ does_ok($traited_class, 'Foo::Role');
+}
+
+{
+ my $traited_class = with_traits('Foo', 'Foo::Role', 'Foo::Role2');
+ ok($traited_class->meta->is_anon_class, "we get an anon class");
+ isa_ok($traited_class, 'Foo');
+ does_ok($traited_class, 'Foo::Role');
+ does_ok($traited_class, 'Foo::Role2');
+}
+
+{
+ my $traited_class = with_traits('Foo');
+ is($traited_class, 'Foo', "don't apply anything if we don't get any traits");
+}
+
+{
+ my $traited_class = with_traits('Foo', 'Foo::Role');
+ my $traited_class2 = with_traits('Foo', 'Foo::Role');
+ is($traited_class, $traited_class2, "get the same class back when passing the same roles");
+}
+
+done_testing;