Hello community, here is the log from the commit of package perl-Role-Tiny for openSUSE:Factory checked in at 2016-05-12 09:33:20 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Role-Tiny (Old) and /work/SRC/openSUSE:Factory/.perl-Role-Tiny.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Role-Tiny" Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Role-Tiny/perl-Role-Tiny.changes 2015-04-27 13:04:28.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.perl-Role-Tiny.new/perl-Role-Tiny.changes 2016-05-12 09:33:22.000000000 +0200 @@ -1,0 +2,17 @@ +Thu May 5 10:03:54 UTC 2016 - co...@suse.com + +- updated to 2.000003 + see /usr/share/doc/packages/perl-Role-Tiny/Changes + + 2.000003 - 2016-04-21 + - don't install subs if importing into a package that is already a role. This + can happen if the module previously imported Moo::Role. + + 2.000002 - 2016-04-19 + - restore compatibility with Moo versions pre 1.004_003 + - delay loading Class::Method::Modifiers until applying modifiers to a package + - use croak rather than die for reporting errors + - apply method modifiers only once, even if they are applied via multiple + composition paths (RT#106668) + +------------------------------------------------------------------- Old: ---- Role-Tiny-2.000001.tar.gz New: ---- Role-Tiny-2.000003.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Role-Tiny.spec ++++++ --- /var/tmp/diff_new_pack.3vpAnM/_old 2016-05-12 09:33:22.000000000 +0200 +++ /var/tmp/diff_new_pack.3vpAnM/_new 2016-05-12 09:33:22.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package perl-Role-Tiny # -# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: perl-Role-Tiny -Version: 2.000001 +Version: 2.000003 Release: 0 %define cpan_name Role-Tiny Summary: Roles. Like a nouvelle cuisine portion size slice of Moose @@ -30,8 +30,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: perl BuildRequires: perl-macros -BuildRequires: perl(Test::Fatal) >= 0.003 -BuildRequires: perl(Test::More) >= 0.96 +BuildRequires: perl(Test::More) >= 0.88 Recommends: perl(Class::Method::Modifiers) >= 1.05 %{perl_requires} ++++++ Role-Tiny-2.000001.tar.gz -> Role-Tiny-2.000003.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Role-Tiny-2.000001/Changes new/Role-Tiny-2.000003/Changes --- old/Role-Tiny-2.000001/Changes 2015-04-25 01:04:08.000000000 +0200 +++ new/Role-Tiny-2.000003/Changes 2016-04-22 00:03:16.000000000 +0200 @@ -1,5 +1,16 @@ Revision history for Role-Tiny +2.000003 - 2016-04-21 + - don't install subs if importing into a package that is already a role. This + can happen if the module previously imported Moo::Role. + +2.000002 - 2016-04-19 + - restore compatibility with Moo versions pre 1.004_003 + - delay loading Class::Method::Modifiers until applying modifiers to a package + - use croak rather than die for reporting errors + - apply method modifiers only once, even if they are applied via multiple + composition paths (RT#106668) + 2.000001 - 2015-04-24 - fix generating invalid package names with single colons when abbreviating long package names (RT#103310) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Role-Tiny-2.000001/MANIFEST new/Role-Tiny-2.000003/MANIFEST --- old/Role-Tiny-2.000001/MANIFEST 2015-04-25 01:04:36.000000000 +0200 +++ new/Role-Tiny-2.000003/MANIFEST 2016-04-22 00:03:50.000000000 +0200 @@ -31,10 +31,11 @@ t/subclass.t xt/around-does.t xt/compose-modifiers.t +xt/dependents.t xt/does-Moo.t xt/modifiers.t -xt/Moo.t xt/namespace-clean.t +xt/recompose-modifier.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) README README file (added by Distar) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Role-Tiny-2.000001/META.json new/Role-Tiny-2.000003/META.json --- old/Role-Tiny-2.000001/META.json 2015-04-25 01:04:36.000000000 +0200 +++ new/Role-Tiny-2.000003/META.json 2016-04-22 00:03:49.000000000 +0200 @@ -4,7 +4,7 @@ "mst - Matt S. Trout (cpan:MSTROUT) <m...@shadowcat.co.uk>" ], "dynamic_config" : 1, - "generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.143240", + "generated_by" : "ExtUtils::MakeMaker version 7.1, CPAN::Meta::Converter version 2.150001", "license" : [ "perl_5" ], @@ -40,8 +40,7 @@ }, "test" : { "requires" : { - "Test::Fatal" : "0.003", - "Test::More" : "0.96" + "Test::More" : "0.88" } } }, @@ -61,5 +60,5 @@ }, "x_IRC" : "irc://irc.perl.org/#moose" }, - "version" : "2.000001" + "version" : "2.000003" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Role-Tiny-2.000001/META.yml new/Role-Tiny-2.000003/META.yml --- old/Role-Tiny-2.000001/META.yml 2015-04-25 01:04:36.000000000 +0200 +++ new/Role-Tiny-2.000003/META.yml 2016-04-22 00:03:49.000000000 +0200 @@ -3,10 +3,9 @@ author: - 'mst - Matt S. Trout (cpan:MSTROUT) <m...@shadowcat.co.uk>' build_requires: - Test::Fatal: '0.003' - Test::More: '0.96' + Test::More: '0.88' dynamic_config: 1 -generated_by: 'ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.143240' +generated_by: 'ExtUtils::MakeMaker version 7.1, CPAN::Meta::Converter version 2.150001' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -26,4 +25,4 @@ bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Role-Tiny license: http://dev.perl.org/licenses/ repository: git://github.com/moose/Role-Tiny.git -version: '2.000001' +version: '2.000003' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Role-Tiny-2.000001/Makefile.PL new/Role-Tiny-2.000003/Makefile.PL --- old/Role-Tiny-2.000001/Makefile.PL 2015-04-16 16:59:49.000000000 +0200 +++ new/Role-Tiny-2.000003/Makefile.PL 2015-11-17 12:07:34.000000000 +0100 @@ -6,8 +6,7 @@ name => 'Role-Tiny', prereqs => { test => { requires => { - 'Test::More' => '0.96', - 'Test::Fatal' => '0.003', + 'Test::More' => '0.88', } }, runtime => { requires => { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Role-Tiny-2.000001/README new/Role-Tiny-2.000003/README --- old/Role-Tiny-2.000001/README 2015-04-25 01:04:36.000000000 +0200 +++ new/Role-Tiny-2.000003/README 2016-04-22 00:03:49.000000000 +0200 @@ -10,11 +10,11 @@ sub bar { ... } - around baz => sub { ... } + around baz => sub { ... }; 1; - else where + elsewhere package Some::Class; @@ -40,7 +40,8 @@ multiple inheritance. The basics of this implementation of roles is: * If a method is already defined on a class, that method will not be - composed in from the role. + composed in from the role. A method inherited by a class gets + overridden by the role's method of the same name, though. * If a method that the role "requires" to be implemented is not implemented, role application will fail loudly. @@ -145,7 +146,8 @@ Role::Tiny->apply_roles_to_object($foo, qw(Some::Role1 Some::Role2)); Composes roles in order into object directly. Object is reblessed into - the resulting class. + the resulting class. Note that the object's methods get overridden by + the role's ones with the same names. create_class_with_roles Role::Tiny->create_class_with_roles('Some::Base', qw(Some::Role1 Some::Role2)); @@ -160,7 +162,10 @@ CAVEATS * On perl 5.8.8 and earlier, applying a role to an object won't apply - any overloads from the role to all copies of the object. + any overloads from the role to other copies of the object. + + * On perl 5.16 and earlier, applying a role to a class won't apply any + overloads from the role to any existing instances of the class. SEE ALSO Role::Tiny is the attribute-less subset of Moo::Role; Moo::Role is a diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Role-Tiny-2.000001/lib/Role/Tiny/With.pm new/Role-Tiny-2.000003/lib/Role/Tiny/With.pm --- old/Role-Tiny-2.000001/lib/Role/Tiny/With.pm 2015-04-25 01:04:01.000000000 +0200 +++ new/Role-Tiny-2.000003/lib/Role/Tiny/With.pm 2016-04-22 00:03:11.000000000 +0200 @@ -3,7 +3,7 @@ use strict; use warnings; -our $VERSION = '2.000001'; +our $VERSION = '2.000003'; $VERSION = eval $VERSION; use Role::Tiny (); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Role-Tiny-2.000001/lib/Role/Tiny.pm new/Role-Tiny-2.000003/lib/Role/Tiny.pm --- old/Role-Tiny-2.000001/lib/Role/Tiny.pm 2015-04-25 01:04:01.000000000 +0200 +++ new/Role-Tiny-2.000003/lib/Role/Tiny.pm 2016-04-22 00:03:11.000000000 +0200 @@ -6,7 +6,7 @@ use strict; use warnings; -our $VERSION = '2.000001'; +our $VERSION = '2.000003'; $VERSION = eval $VERSION; our %INFO; @@ -22,6 +22,13 @@ *_MRO_MODULE = "$]" < 5.010 ? sub(){"MRO/Compat.pm"} : sub(){"mro.pm"}; } +sub croak { + require Carp; + no warnings 'redefine'; + *croak = \&Carp::croak; + goto &Carp::croak; +} + sub Role::Tiny::__GUARD__::DESTROY { delete $INC{$_[0]->[0]} if @{$_[0]}; } @@ -45,14 +52,30 @@ my $me = shift; strict->import; warnings->import; + $me->_install_subs($target); return if $me->is_role($target); # already exported into this package $INFO{$target}{is_role} = 1; # get symbol table reference my $stash = _getstash($target); + # grab all *non-constant* (stash slot is not a scalarref) subs present + # in the symbol table and store their refaddrs (no need to forcibly + # inflate constant subs into real subs) with a map to the coderefs in + # case of copying or re-use + my @not_methods = (map { *$_{CODE}||() } grep !ref($_), values %$stash); + @{$INFO{$target}{not_methods}={}}{@not_methods} = @not_methods; + # a role does itself + $APPLIED_TO{$target} = { $target => undef }; + foreach my $hook (@ON_ROLE_CREATE) { + $hook->($target); + } +} + +sub _install_subs { + my ($me, $target) = @_; + return if $me->is_role($target); # install before/after/around subs foreach my $type (qw(before after around)) { *{_getglob "${target}::${type}"} = sub { - require Class::Method::Modifiers; push @{$INFO{$target}{modifiers}||=[]}, [ $type => @_ ]; return; }; @@ -65,15 +88,6 @@ $me->apply_roles_to_package($target, @_); return; }; - # grab all *non-constant* (stash slot is not a scalarref) subs present - # in the symbol table and store their refaddrs (no need to forcibly - # inflate constant subs into real subs) with a map to the coderefs in - # case of copying or re-use - my @not_methods = (map { *$_{CODE}||() } grep !ref($_), values %$stash); - @{$INFO{$target}{not_methods}={}}{@not_methods} = @not_methods; - # a role does itself - $APPLIED_TO{$target} = { $target => undef }; - $_->($target) for @ON_ROLE_CREATE; } sub role_application_steps { @@ -85,8 +99,8 @@ _load_module($role); - die "This is apply_role_to_package" if ref($to); - die "${role} is not a Role::Tiny" unless $me->is_role($role); + croak "This is apply_role_to_package" if ref($to); + croak "${role} is not a Role::Tiny" unless $me->is_role($role); foreach my $step ($me->role_application_steps) { $me->$step($to, $role); @@ -101,7 +115,7 @@ sub apply_roles_to_object { my ($me, $object, @roles) = @_; - die "No roles supplied!" unless @roles; + croak "No roles supplied!" unless @roles; my $class = ref($object); # on perl < 5.8.9, magic isn't copied to all ref copies. bless the parameter # directly, so at least the variable passed to us will get any magic applied @@ -129,14 +143,13 @@ sub create_class_with_roles { my ($me, $superclass, @roles) = @_; - die "No roles supplied!" unless @roles; + croak "No roles supplied!" unless @roles; _load_module($superclass); { my %seen; - $seen{$_}++ for @roles; - if (my @dupes = grep $seen{$_} > 1, @roles) { - die "Duplicated roles: ".join(', ', @dupes); + if (my @dupes = grep 1 == $seen{$_}++, @roles) { + croak "Duplicated roles: ".join(', ', @dupes); } } @@ -146,7 +159,7 @@ foreach my $role (@roles) { _load_module($role); - die "${role} is not a Role::Tiny" unless $me->is_role($role); + croak "${role} is not a Role::Tiny" unless $me->is_role($role); } require(_MRO_MODULE); @@ -161,7 +174,7 @@ ."'".join(' and ', sort values %{$conflicts{$_}})."'" .", cannot apply these simultaneously to an object." } keys %conflicts; - die $fail; + croak $fail; } my @composable = map $me->_composable_package_for($_), reverse @roles; @@ -212,7 +225,7 @@ ."'".join(' and ', sort values %{$conflicts{$_}})."'" .", the method '$_' must be implemented by '${to}'" } keys %conflicts; - die $fail; + croak $fail; } # conflicting methods are supposed to be treated as required by the @@ -317,7 +330,7 @@ if (my $to_info = $INFO{$to}) { push @{$to_info->{requires}||=[]}, @requires_fail; } else { - die "Can't apply ${name} to ${to} - missing ".join(', ', @requires_fail); + croak "Can't apply ${name} to ${to} - missing ".join(', ', @requires_fail); } } } @@ -341,7 +354,7 @@ sub methods_provided_by { my ($me, $role) = @_; - die "${role} is not a Role::Tiny" unless $me->is_role($role); + croak "${role} is not a Role::Tiny" unless $me->is_role($role); (keys %{$me->_concrete_methods_of($role)}, @{$INFO{$role}->{requires}||[]}); } @@ -387,10 +400,16 @@ sub _install_modifiers { my ($me, $to, $name) = @_; return unless my $modifiers = $INFO{$name}{modifiers}; - if (my $info = $INFO{$to}) { - push @{$info->{modifiers}}, @{$modifiers||[]}; - } else { - foreach my $modifier (@{$modifiers||[]}) { + my $info = $INFO{$to}; + my $existing = ($info ? $info->{modifiers} : $COMPOSED{modifiers}{$to}) ||= []; + my @modifiers = grep { + my $modifier = $_; + !grep $_ == $modifier, @$existing; + } @{$modifiers||[]}; + push @$existing, @modifiers; + + if (!$info) { + foreach my $modifier (@modifiers) { $me->_install_single_modifier($to, @$modifier); } } @@ -402,9 +421,11 @@ my ($me, @args) = @_; defined($vcheck_error) or $vcheck_error = do { local $@; - eval { Class::Method::Modifiers->VERSION(1.05); 1 } - ? 0 - : $@ + eval { + require Class::Method::Modifiers; + Class::Method::Modifiers->VERSION(1.05); + 1; + } ? 0 : $@; }; $vcheck_error and die $vcheck_error; Class::Method::Modifiers::install_modifier(@args); @@ -444,7 +465,7 @@ sub is_role { my ($me, $role) = @_; - return !!($INFO{$role} && $INFO{$role}{is_role}); + return !!($INFO{$role} && ($INFO{$role}{is_role} || $INFO{$role}{not_methods})); } 1; @@ -466,11 +487,11 @@ sub bar { ... } - around baz => sub { ... } + around baz => sub { ... }; 1; -else where +elsewhere package Some::Class; @@ -502,7 +523,8 @@ =item * If a method is already defined on a class, that method will not be composed in -from the role. +from the role. A method inherited by a class gets overridden by the role's +method of the same name, though. =item * @@ -620,8 +642,9 @@ Role::Tiny->apply_roles_to_object($foo, qw(Some::Role1 Some::Role2)); -Composes roles in order into object directly. Object is reblessed into the -resulting class. +Composes roles in order into object directly. Object is reblessed into the +resulting class. Note that the object's methods get overridden by the role's +ones with the same names. =head2 create_class_with_roles @@ -641,7 +664,10 @@ =over 4 =item * On perl 5.8.8 and earlier, applying a role to an object won't apply any -overloads from the role to all copies of the object. +overloads from the role to other copies of the object. + +=item * On perl 5.16 and earlier, applying a role to a class won't apply any +overloads from the role to any existing instances of the class. =back diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Role-Tiny-2.000001/t/concrete-methods.t new/Role-Tiny-2.000003/t/concrete-methods.t --- old/Role-Tiny-2.000001/t/concrete-methods.t 2015-02-23 21:29:22.000000000 +0100 +++ new/Role-Tiny-2.000003/t/concrete-methods.t 2015-11-14 08:12:27.000000000 +0100 @@ -1,7 +1,6 @@ use strict; use warnings; use Test::More; -use Test::Fatal; { package MyRole1; @@ -35,7 +34,8 @@ is_deeply([sort keys %$class_methods], ['method'], 'only subs from non-Role::Tiny packages are methods' ); -like exception { Role::Tiny->methods_provided_by('MyClass1') }, +eval { Role::Tiny->methods_provided_by('MyClass1') }; +like $@, qr/is not a Role::Tiny/, 'methods_provided_by refuses to work on classes'; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Role-Tiny-2.000001/t/load-module.t new/Role-Tiny-2.000003/t/load-module.t --- old/Role-Tiny-2.000001/t/load-module.t 2015-02-23 21:29:22.000000000 +0100 +++ new/Role-Tiny-2.000003/t/load-module.t 2015-11-04 21:24:30.000000000 +0100 @@ -1,8 +1,6 @@ use strict; use warnings; use Test::More; -use Test::Fatal; - use Role::Tiny (); use lib 't/lib'; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Role-Tiny-2.000001/t/method-conflicts.t new/Role-Tiny-2.000003/t/method-conflicts.t --- old/Role-Tiny-2.000001/t/method-conflicts.t 2015-02-23 21:29:22.000000000 +0100 +++ new/Role-Tiny-2.000003/t/method-conflicts.t 2015-11-14 08:15:21.000000000 +0100 @@ -15,15 +15,13 @@ sub method { 2 }; } -# Need to use stringy eval, so not Test::Fatal -$@ = undef; ok( - !eval(q{ + !eval { package Local::C1; use Role::Tiny::With; with qw(Local::R1 Local::R2); 1; - }), + }, 'method conflict dies', ); @@ -33,15 +31,14 @@ '... with correct error message', ); -$@ = undef; ok( - eval(q{ + eval { package Local::C2; use Role::Tiny::With; with qw(Local::R1 Local::R2); sub method { 3 }; 1; - }), + }, '... but can be resolved', ); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Role-Tiny-2.000001/t/overload.t new/Role-Tiny-2.000003/t/overload.t --- old/Role-Tiny-2.000001/t/overload.t 2015-02-23 21:29:22.000000000 +0100 +++ new/Role-Tiny-2.000003/t/overload.t 2015-11-14 08:11:01.000000000 +0100 @@ -56,18 +56,27 @@ } { - my @o = (MyClass3->new) x 2; - my $copy = ''; - for my $o (@o) { - Role::Tiny->apply_roles_to_object($o, 'MyRole') - unless $copy; + my $orig = MyClass3->new; + my $copy = $orig; + Role::Tiny->apply_roles_to_object($orig, 'MyRole'); + for my $o ($orig, $copy) { + my $copied = \$o == \$copy ? ' copy' : ''; local $TODO = 'magic not applied to all ref copies on perl < 5.8.9' - if $copy && $] < 5.008009; - is "$o", 'welp', 'subref overload applied to instance'.$copy; - is sprintf('%d', $o), 219, 'method name overload applied to instance'.$copy; - ok !$o, 'anon subref overload applied to instance'.$copy; - $copy ||= ' copy'; + if $copied && $] < 5.008009; + is "$o", 'welp', 'subref overload applied to instance'.$copied; + is sprintf('%d', $o), 219, 'method name overload applied to instance'.$copied; + ok !$o, 'anon subref overload applied to instance'.$copied; } } +{ + my $o = MyClass3->new; + Role::Tiny->apply_roles_to_package('MyClass3', 'MyRole'); + local $TODO = 'magic not applied to existing objects on perl < 5.18' + if $] < 5.018; + is "$o", 'welp', 'subref overload applied to class with instance'; + is sprintf('%d', $o), 219, 'method name overload applied to class with instance'; + ok !$o, 'anon subref overload applied to class with instance'; +} + done_testing; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Role-Tiny-2.000001/t/role-basic-bugs.t new/Role-Tiny-2.000003/t/role-basic-bugs.t --- old/Role-Tiny-2.000001/t/role-basic-bugs.t 2015-02-23 21:29:22.000000000 +0100 +++ new/Role-Tiny-2.000003/t/role-basic-bugs.t 2015-11-16 02:34:32.000000000 +0100 @@ -2,7 +2,6 @@ use warnings; use lib 't/role-basic/lib', 't/lib'; use Test::More; -use Test::Fatal; # multiple roles with the same role { @@ -24,9 +23,12 @@ use strict; use warnings; use Role::Tiny 'with'; - ::is( ::exception { + eval { with 'RoleA', 'RoleB'; - }, undef, 'Composing multiple roles which use the same role should not have conflicts' ); + 1; + } or $@ ||= 'unknown error'; + ::is $@, '', + 'Composing multiple roles which use the same role should not have conflicts'; sub new { bless {} => shift } my $object = Foo->new; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Role-Tiny-2.000001/t/role-duplication.t new/Role-Tiny-2.000003/t/role-duplication.t --- old/Role-Tiny-2.000001/t/role-duplication.t 2015-02-23 21:29:22.000000000 +0100 +++ new/Role-Tiny-2.000003/t/role-duplication.t 2016-02-12 13:04:26.000000000 +0100 @@ -3,13 +3,26 @@ use Test::More; { - package Role; use Role::Tiny; - sub foo { my $orig = shift; 1 + $orig->(@_) }; - package BaseClass; sub foo { 1 } + package Role1; use Role::Tiny; + sub foo1 { 1 } +} +{ + package Role2; use Role::Tiny; + sub foo2 { 2 } +} +{ + package BaseClass; + sub foo { 0 } } -eval { Role::Tiny->create_class_with_roles('BaseClass', qw(Role Role)); }; +eval { + Role::Tiny->create_class_with_roles( + 'BaseClass', + qw(Role2 Role1 Role1 Role2 Role2), + ); +}; -like $@, qr/Duplicated/, 'duplicate role detected'; +like $@, qr/\ADuplicated roles: Role1, Role2 /, + 'duplicate roles detected'; done_testing; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Role-Tiny-2.000001/t/role-tiny-composition.t new/Role-Tiny-2.000003/t/role-tiny-composition.t --- old/Role-Tiny-2.000001/t/role-tiny-composition.t 2015-02-23 21:29:22.000000000 +0100 +++ new/Role-Tiny-2.000003/t/role-tiny-composition.t 2015-11-14 08:19:52.000000000 +0100 @@ -1,7 +1,6 @@ use strict; use warnings; use Test::More; -use Test::Fatal; { package R1; @@ -28,6 +27,9 @@ } } -ok(exception { Role::Tiny->apply_roles_to_object(X->new, "R1", "R2") }, 'apply conflicting roles to object'); +eval { Role::Tiny->apply_roles_to_object(X->new, "R1", "R2") }; +like $@, + qr/^Method name conflict for 'foo' between roles 'R. and R2., cannot apply these simultaneously to an object/, + 'apply conflicting roles to object'; done_testing; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Role-Tiny-2.000001/t/role-tiny.t new/Role-Tiny-2.000003/t/role-tiny.t --- old/Role-Tiny-2.000001/t/role-tiny.t 2015-02-23 21:29:22.000000000 +0100 +++ new/Role-Tiny-2.000003/t/role-tiny.t 2015-11-14 08:26:45.000000000 +0100 @@ -1,7 +1,6 @@ use strict; use warnings; use Test::More; -use Test::Fatal; BEGIN { package MyRole; @@ -61,7 +60,10 @@ sub try_apply_to { my $to = shift; - exception { Role::Tiny->apply_role_to_package($to, 'MyRole') } + eval { Role::Tiny->apply_role_to_package($to, 'MyRole'); 1 } + and return undef; + return $@ if $@; + die "false exception caught!"; } is(try_apply_to('MyClass'), undef, 'role applies cleanly'); @@ -74,10 +76,12 @@ like(try_apply_to('NoMethods'), qr/req1, req2/, 'error for both methods'); like(try_apply_to('OneMethod'), qr/req2/, 'error for one method'); -is exception { +eval { Role::Tiny->apply_role_to_package('IntermediaryRole', 'MyRole'); Role::Tiny->apply_role_to_package('ExtraClass', 'IntermediaryRole'); -}, undef, 'No errors applying roles'; + 1; +} or $@ ||= "false exception!"; +is $@, '', 'No errors applying roles'; ok(ExtraClass->does('MyRole'), 'ExtraClass does MyRole'); ok(ExtraClass->does('IntermediaryRole'), 'ExtraClass does IntermediaryRole'); @@ -85,9 +89,10 @@ is(ExtraClass->baz, 'class baz', 'method from class'); my $new_class; -is exception { +eval { $new_class = Role::Tiny->create_class_with_roles('MyClass', 'ExtraRole'); -}, undef, 'No errors creating class with roles'; +} or $@ ||= "false exception!"; +is $@, '', 'No errors creating class with roles'; isa_ok($new_class, 'MyClass'); is($new_class->extra1, 'role extra', 'method from role'); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Role-Tiny-2.000001/t/subclass.t new/Role-Tiny-2.000003/t/subclass.t --- old/Role-Tiny-2.000001/t/subclass.t 2015-02-23 21:29:22.000000000 +0100 +++ new/Role-Tiny-2.000003/t/subclass.t 2015-11-04 21:24:30.000000000 +0100 @@ -1,7 +1,6 @@ use strict; use warnings; use Test::More; -use Test::Fatal; my $backcompat_called; { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Role-Tiny-2.000001/xt/Moo.t new/Role-Tiny-2.000003/xt/Moo.t --- old/Role-Tiny-2.000001/xt/Moo.t 2015-04-05 06:27:00.000000000 +0200 +++ new/Role-Tiny-2.000003/xt/Moo.t 1970-01-01 01:00:00.000000000 +0100 @@ -1,24 +0,0 @@ -use strict; -use warnings; -use Test::More $ENV{EXTENDED_TESTING} ? () - : (skip_all => 'Set EXTENDED_TESTING to enable Moo testing'); - -use IPC::Open3; -use File::Spec; -use Config; - -$ENV{PERL5LIB} = join $Config{path_sep}, @INC; - -open my $in, '<', File::Spec->devnull - or die "can't open devnull: $!"; - -my $pid = open3 $in, my $out, undef, $^X, '-MCPAN', '-e', 'test @ARGV', 'Moo'; -my $output = do { local $/; <$out> }; -close $out; -waitpid $pid, 0; - -my $status = $?; -like $output, qr/--\s*OK\s*\z/, - 'Moo passed tests'; - -done_testing; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Role-Tiny-2.000001/xt/dependents.t new/Role-Tiny-2.000003/xt/dependents.t --- old/Role-Tiny-2.000001/xt/dependents.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Role-Tiny-2.000003/xt/dependents.t 2016-04-19 22:10:38.000000000 +0200 @@ -0,0 +1,52 @@ +use strict; +use warnings; +use Test::More + !($ENV{EXTENDED_TESTING} || grep $_ eq '--doit', @ARGV) + ? (skip_all => 'Set EXTENDED_TESTING to enable dependents testing') + : (); +use IPC::Open3; +use File::Spec; +use Cwd qw(abs_path); +use Config; + +my @extra_libs = do { + my @libs = `"$^X" -le"print for \@INC"`; + chomp @libs; + my %libs; @libs{@libs} = (); + map { Cwd::abs_path($_) } grep { !exists $libs{$_} } @INC; +}; +$ENV{PERL5LIB} = join($Config{path_sep}, @extra_libs, $ENV{PERL5LIB}||()); + +open my $in, '<', File::Spec->devnull + or die "can't open devnull: $!"; + +my $ext = qr{\.(?:t(?:ar\.)?(?:bz2|xz|gz)|tar|zip)}; +for my $dist ( + 'MSTROUT/Moo-0.009002.tar.gz', # earliest working version + 'MSTROUT/Moo-1.000000.tar.gz', + 'MSTROUT/Moo-1.000008.tar.gz', + 'HAARG/Moo-1.007000.tar.gz', + 'HAARG/Moo-2.000000.tar.gz', + 'HAARG/Moo-2.001000.tar.gz', + 'Moo', +) { + my $name = $dist; + $name =~ s{$ext$}{} + if $name =~ m{/}; + my $pid = open3 $in, my $out, undef, $^X, '-MCPAN', '-e', 'test @ARGV', $dist; + my $output = do { local $/; <$out> }; + close $out; + waitpid $pid, 0; + + my $status = $?; + + if ($dist !~ m{/}) { + $output =~ m{^Configuring (.)/(\1.)/(\2.*)$ext\s}m + and $name = "$3 (latest)"; + } + + like $output, qr/--\s*OK\s*\z/, + "$name passed tests"; +} + +done_testing; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Role-Tiny-2.000001/xt/modifiers.t new/Role-Tiny-2.000003/xt/modifiers.t --- old/Role-Tiny-2.000001/xt/modifiers.t 2015-04-05 06:21:58.000000000 +0200 +++ new/Role-Tiny-2.000003/xt/modifiers.t 2016-02-12 13:04:25.000000000 +0100 @@ -1,7 +1,6 @@ use strict; use warnings; use Test::More; -use Test::Fatal; use Class::Method::Modifiers 1.05 (); @@ -57,7 +56,10 @@ sub try_apply_to { my $to = shift; - exception { Role::Tiny->apply_role_to_package($to, 'MyRole') } + eval { Role::Tiny->apply_role_to_package($to, 'MyRole'); 1 } + and return undef; + return $@ if $@; + die "false exception caught!"; } is(try_apply_to('MyClass'), undef, 'role applies cleanly'); @@ -67,8 +69,11 @@ is(ExtraClass2->foo, 'role foo class foo', 'method modifier with role composed into role'); -ok(exception { - my $new_class = Role::Tiny->create_class_with_roles('MyClass', 'BrokenRole'); -}, 'exception caught creating class with broken modifier in a role'); +eval { + Role::Tiny->create_class_with_roles('MyClass', 'BrokenRole'); + 1; +} or $@ ||= 'false exception!'; +like $@, qr/Evaling failed:/, + 'exception caught creating class with broken modifier in a role'; done_testing; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Role-Tiny-2.000001/xt/recompose-modifier.t new/Role-Tiny-2.000003/xt/recompose-modifier.t --- old/Role-Tiny-2.000001/xt/recompose-modifier.t 1970-01-01 01:00:00.000000000 +0100 +++ new/Role-Tiny-2.000003/xt/recompose-modifier.t 2016-04-18 19:07:14.000000000 +0200 @@ -0,0 +1,82 @@ +use strict; +use warnings; +use Test::More; +{ + package ModifierRole; + use Role::Tiny; + + sub method { 0 } + around method => sub { + my $orig = shift; + my $self = shift; + $self->$orig(@_) + 1; + }; +} + +{ + package Role1; + use Role::Tiny; + + with 'ModifierRole'; +} + +{ + package Role2; + use Role::Tiny; + + with 'ModifierRole'; +} + +{ + package ComposingClass1; + use Role::Tiny::With; + + with qw(Role1 Role2); +} + +is +ComposingClass1->method, 1, 'recomposed modifier called once'; + +{ + package ComposingClass2; + use Role::Tiny::With; + + with 'Role1'; + with 'Role2'; +} + +is +ComposingClass2->method, 1, 'recomposed modifier called once (separately composed)'; + +{ + package DoubleRole; + + use Role::Tiny; + with qw(Role1 Role2); +} + +{ + package ComposingClass3; + use Role::Tiny::With; + + with 'DoubleRole'; +} + +is +ComposingClass3->method, 1, 'recomposed modifier called once (via composing role)'; + +{ + package DoubleRoleSeparate; + + use Role::Tiny; + with 'Role1'; + with 'Role2'; +} + +{ + package ComposingClass4; + use Role::Tiny::With; + + with qw(DoubleRoleSeparate); +} + +is +ComposingClass4->method, 1, 'recomposed modifier called once (via separately composing role)'; + +done_testing;