Skip to content

Commit

Permalink
check that BUILDARGS aren't overwritten by role, just in case
Browse files Browse the repository at this point in the history
  • Loading branch information
xsawyerx committed Dec 5, 2012
1 parent f98d9e2 commit 3ab60c8
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions t/buildargs.t
@@ -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;

0 comments on commit 3ab60c8

Please sign in to comment.