Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
check that BUILDARGS aren't overwritten by role, just in case
- Loading branch information
Showing
1 changed file
with
30 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,30 @@ | ||
#!/usr/bin/perl | ||
|
||
use strict; | ||
use warnings; | ||
use Test::More; | ||
|
||
# making sure BUILDARGS doesn't fuck up object's method as well | ||
|
||
{ | ||
package Object; | ||
use Moo; | ||
with 'MooseX::Role::Loggable'; | ||
has hello => ( is => 'ro' ); | ||
sub BUILDARGS { | ||
my $class = shift; | ||
my %args = @_; | ||
$args{'hello'} = 'What up!'; | ||
return {%args}; | ||
} | ||
} | ||
|
||
my $object = Object->new(); | ||
isa_ok( $object, 'Object' ); | ||
cmp_ok( $object->does('MooseX::Role::Loggable'), '==', 1, 'Role applied' ); | ||
can_ok( $object, 'hello' ); | ||
can_ok( $object, 'debug', 'log', 'log_debug' ); | ||
is( $object->hello, 'What up!', 'BUILDARGS not overwritten' ); | ||
|
||
done_testing; | ||
|