load class in addition to roles when using create_class_from_roles
Arthur Axel 'fREW' Schmidt [Mon, 3 Sep 2012 15:31:32 +0000 (10:31 -0500)]
Changes
lib/Role/Tiny.pm
t/lib/Bar.pm [new file with mode: 0644]
t/lib/Baz.pm [new file with mode: 0644]
t/role-basic-bugs.t

diff --git a/Changes b/Changes
index c451a61..713988d 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,3 +1,4 @@
+  - load class in addition to roles when using create_class_from_roles
   - fix module name in Makefile.PL (RT#78591)
 
 1.001005 - 2012-07-18
index 6620964..609f4a6 100644 (file)
@@ -108,6 +108,7 @@ sub create_class_with_roles {
 
   die "No roles supplied!" unless @roles;
 
+  _load_module($superclass);
   {
     my %seen;
     $seen{$_}++ for @roles;
diff --git a/t/lib/Bar.pm b/t/lib/Bar.pm
new file mode 100644 (file)
index 0000000..9958b27
--- /dev/null
@@ -0,0 +1,6 @@
+package Bar;
+
+sub new { bless {} => shift }
+sub bar { 1 }
+
+1;
diff --git a/t/lib/Baz.pm b/t/lib/Baz.pm
new file mode 100644 (file)
index 0000000..bd52b93
--- /dev/null
@@ -0,0 +1,7 @@
+package Baz;
+
+use Role::Tiny;
+
+sub baz { 1 }
+
+1;
index f43a308..94443de 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/env perl
 
-use lib 'lib', 't/role-basic/lib';
+use lib 'lib', 't/role-basic/lib', 't/lib';
 use MyTests;
 
 # multiple roles with the same role
@@ -77,4 +77,6 @@ use MyTests;
     ::ok(Role::Tiny::does_role($object, "Role1"), 'Role1 consumed');
     ::ok(Role::Tiny::does_role($object, 'Role2'), 'Role2 consumed');
 }
+
+can_ok(Role::Tiny->create_class_with_roles(qw(Bar Baz))->new, qw(bar baz));
 done_testing;