;
can_ok($foo, 'get_foo');
is($foo->get_foo(), undef, '... got an undefined value');
isnt( exception {
$foo->get_foo(100);
}, undef, '... get_foo is a read-only' );
ok(!e
can_ok($foo, 'get_lazy_foo');
is($foo->get_lazy_foo(), 10, '... got an deferred value');
isnt( exception {
$foo->get_lazy_foo(100);
}, undef, '... get_lazy_foo is a read-only' );
oo method' );
ok( !$Foo->has_method('foo'),
'... !Foo->has_method(foo) we just removed it' );
isnt( exception { Foo->foo }, undef, '... cannot call Foo->foo because it is not there' );
is_deeply(
>meta->add_method( $method->name, $method );
my $new_method = Bar->meta->get_method('objecty');
isnt( $method, $new_method,
'add_method clones method objects as they are added' );
is( $new_metho
t correctly');
ok(!$th->check({foo1 => 1, bar2 => 0, baz3 => 1}), '... validated it correctly');
isnt( exception {
Moose::Meta::TypeConstraint::Parameterized->new(
name => 'Str[
ter => find_type_constraint('Int'),
);
}, undef, 'non-containers cannot be parameterized' );
isnt( exception {
Moose::Meta::TypeConstraint::Parameterized->new(
name => 'Nonc
Bling;
use Moose;
::isnt( ::exception {
has('bling' => (is => 'rw', trigger => 'Fail'));
}, undef, '... a trigger must be a CODE ref' );
::isnt( ::exception {
has('b
one = $obj->hash_clone;
isnt(refaddr($array), refaddr($array_clone), "array clone refers to new copy");
is_deeply($array_clone, $array, "...but contents are the same");
isnt(refaddr($hash), refaddr
or params' );
isnt( exception {
$obj->set_option( bar => {} );
}, undef, '... could not add a hash ref where an string is expected' );
isnt( exception {
';
with 'My::Role1';
}, undef, 'class consumes role4(provides attribute); consumes role1' );
isnt( exception { package My::Test12; use Moose; with 'My::Role1'; with 'My::Role4'; }, undef, 'class
le5';
with 'My::Role1';
}, undef, 'class consumes role5(provides method); consumes role1' );
isnt( exception { package My::Test14; use Moose; with 'My::Role1'; with 'My::Role5'; }, undef, 'class
;
{
my $clone = $foo->meta->clone_object($foo, foo => 'BAZ');
isa_ok($clone, 'Foo');
isnt($clone, $foo, '... and it is a clone');
is($clone->get_foo, 'BAZ', '... got the right cloned
}
{
my $clone = $foo->meta->clone_object($foo, foo => undef);
isa_ok($clone, 'Foo');
isnt($clone, $foo, '... and it is a clone');
ok(!defined($clone->get_foo), '... got the right clo
rent", 'Parent->whoami gives parent');
is($foo->parent, "parent", 'Parent->parent gives parent');
isnt( exception { $foo->child }, undef, "Parent->child method doesn't exist" );
Child->meta->rebless_
rent", 'Parent->whoami gives parent');
is($foo->parent, "parent", 'Parent->parent gives parent');
isnt( exception { $foo->child }, undef, "Parent->child method doesn't exist" );
like( exception { Lef
;
use Class::MOP::Package;
isnt( exception { Class::MOP::Package->get_all_package_symbols }, undef, q{... can't call get_all_package_symbols() as a class method} );
isnt( exception { Class::MOP::Pac
s.
no Moose;
__PACKAGE__->meta->make_immutable();
1;
}
my $meta;
use Data::Dumper;
isnt ( exception {
$meta = Moose::Meta::Class->create_anon_class(
superclasses => [ 't::bu
[ 'Role::BreakOnLoad', ],
)
}, undef, 'Class dies when attempting composition');
my $except;
isnt ( $except = exception {
$meta = Moose::Meta::Class->create_anon_class(
superclasses =
=> 'ArrayRef[Int]',
auto_deref => 1,
);
}
{
my $autoderef = AutoDeref->new;
isnt( exception {
$autoderef->bar(1, 2, 3);
}, undef, '... its auto-de-ref-ing, not auto-e
'Moose::Meta::Class',
error_class => 'Moose::Error::Croak',
);
use Moose;
::isnt( ::exception { extends 'Baz::Sub' }, undef, 'error_class is included in metaclass compatibility c
def, '... composed the role with override okay' );
package My::Test13;
use Moose;
::isnt( ::exception {
with 'Role::Plot';
}, undef, '... cannot compose it because we have no
for => $role1->name,
role_metaroles => { role => ['Role::Metarole'] },
);
isnt($role1, $role2, "anon role was reinitialized");
is($role1->name, $role2->name, "but it's the
"RootC::foo" }
package SubCA;
use Moose::Role;
with "RootC";
::isnt( ::exception {
override foo => sub { "overridden" };
}, undef, '... cannot co
t");
ok(!$obj->can( 'fur' ), 'ditto');
ok(!$obj->does('Dog'), '... we do not do any roles yet');
isnt( exception {
$obj->dog($obj)
}, undef, '... and setting the accessor fails (not a Dog yet)' )
iginal_fully_qualified_name, 'Role::Foo::foo',
'original fq name is Role::Foo::foo' );
}
isnt( ClassA->foo, "ClassB::foo", "ClassA::foo is not confused with ClassB::foo");
is( ClassB->foo, '
e Moose;
{
local our $TODO = "attrs and methods from a role should clash";
::isnt( ::exception { with qw(Tree Dog) }, undef );
}
}
# these fail because of the deferral logic
or');
is($point->x, 2, '... the x attribute was initialized correctly through the metaobject');
isnt( exception {
$point->x(42);
}, undef, '... cannot write to a read-only accessor' );
is($point