From: Graham Knop Date: Thu, 11 Jul 2013 00:40:11 +0000 (-0400) Subject: test for overriding apply_single_role_to_package X-Git-Tag: v1.003000~14 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c49573def7bd40df2821fcef7ee7d862c4317fb0;p=gitmo%2FRole-Tiny.git test for overriding apply_single_role_to_package --- diff --git a/t/subclass.t b/t/subclass.t new file mode 100644 index 0000000..85cdacd --- /dev/null +++ b/t/subclass.t @@ -0,0 +1,40 @@ +use strict; +use warnings FATAL => 'all'; +use Test::More; +use Test::Fatal; + +my $backcompat_called; +{ + package RoleExtension; + use base 'Role::Tiny'; + + sub apply_single_role_to_package { + my $me = shift; + $me->SUPER::apply_single_role_to_package(@_); + $backcompat_called++; + } +} + +{ + package Role1; + $INC{'Role1.pm'} = __FILE__; + use Role::Tiny; + sub sub1 {} +} + +{ + package Role2; + $INC{'Role2.pm'} = __FILE__; + use Role::Tiny; + sub sub2 {} +} + +{ + package Class1; + RoleExtension->apply_roles_to_package(__PACKAGE__, 'Role1', 'Role2'); +} + +is $backcompat_called, 2, + 'overridden apply_single_role_to_package called for backcompat'; + +done_testing;