Subject: | attribute bug in XS version |
The attached test file shows some code where the XS version of Mouse and the pure perl version give different behaviours. The pure perl behaviour is what I expect is the right behaviour, and is the behaviour that Mouse 0.40 and below have. The test fails for me using the XS version but not the pure perl version.
This is Perl 5.10.1 on Debian. I believe this affects all XS versions of Mouse, which I guess is everything after 0.40, but I've only tested with 0.45 and 0.4501.
This is Perl 5.10.1 on Debian. I believe this affects all XS versions of Mouse, which I guess is everything after 0.40, but I've only tested with 0.45 and 0.4501.
Subject: | bug.t |
package Foo;
use Mouse;
has app_handle => (
is => 'rw',
isa => 'Baz',
required => 1,
);
has handle => (
is => 'rw',
isa => 'Int',
# app_handle should not be undef here!
default => sub { shift->app_handle->handle() },
);
no Mouse;
1;
package Bar;
use Mouse;
has app_handle => (
is => 'rw',
isa => 'Baz',
required => 1,
);
sub do_something {
my $self = shift;
my $foo = Foo->new( app_handle => $self->app_handle );
return $foo->handle;
}
no Mouse;
1;
package Baz;
use Mouse;
sub handle {
# print "This works correctly.\n";
return 1;
}
no Mouse;
1;
package main;
use strict;
use warnings;
use Test::More tests => 2;
use Test::Exception;
my $bar = Bar->new( app_handle => Baz->new() );
ok($bar, "Test class Bar instantiated w/attribute app_handle Baz");
# Trigger the default sub of baz's handle attribute, which tries to call
# a method on an attribute which was set to an object passed in via the
# constructor.
lives_and { is($bar->do_something(), 1, "attribute was passed in okay") };