-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |