Skip to content

Commit

Permalink
Add some more overloading tests
Browse files Browse the repository at this point in the history
  • Loading branch information
autarch committed Oct 20, 2014
1 parent 34e12ce commit 79b1981
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions t/bugs/overloading_edge_cases.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
use strict;
use warnings;

use Test::More;

{
package Role::Overloads;
use Moose::Role;
use overload q{""} => 'as_string';
requires 'as_string';
}

{
package Class::Overloads;
use Moose;
with 'Role::Overloads';
sub as_string { 'foo' }
}

is(
Class::Overloads->new() . q{}, 'foo',
'Class::Overloads overloads stringification with overloading defined in role and method defined in class'
);

{
package Parent::NoOverloads;
use Moose;
sub name { ref $_[0] }
}

{
package Child::Overloads;
use Moose;
use overload q{""} => 'name';
extends 'Parent::NoOverloads';
}

is(
Child::Overloads->new() . q{}, 'Child::Overloads',
'Child::Overloads overloads stringification with method inherited from parent'
);

done_testing;

0 comments on commit 79b1981

Please sign in to comment.