;
my $bar_attr2 = Foo->meta->get_attribute('bar');
::isnt($bar_attr, $bar_attr2, '... this is a new bar attribute');
::isnt($bar_attr->associated_class, Foo->meta, '... and the old bar a
ribute *is* associated with Foo->meta');
::isnt($bar_attr2->reader, 'get_bar', '... the bar attribute no longer has the reader get_bar');
::isnt($bar_attr2->reader, 'set_bar', '... the bar at
oo' ],
'... got the right list of methods'
);
}
# test simple overrides w/ conflicts
isnt( exception {
Moose::Meta::Role::Application::RoleSummation->new->apply(
Moose::Meta::
)
);
}, undef, '... this fails as expected' );
# test simple overrides w/ conflicts
isnt( exception {
Moose::Meta::Role::Application::RoleSummation->new->apply(
Moose::Meta::
)
);
}, undef, '... this fails as expected' );
# test simple overrides w/ conflicts
isnt( exception {
Moose::Meta::Role::Application::RoleSummation->new->apply(
Moose::Meta::
ss->does('Bark'), '... the class does not do the Bark role');
isa_ok($obj, 'My::Class');
isnt(blessed($obj), 'My::Class', '... but it is no longer blessed into My::Class');
ok(!My::Class
eeper->meta->apply($obj2);
ok($obj2->does('Sleeper'), '... we now do the Sleeper role');
isnt(blessed($obj), blessed($obj2), '... they DO NOT share the same anon-class/role thing');
}
{
e too');
ok(!My::Class->does('Sleeper'), '... the class does not do the Sleeper role');
isnt(blessed($obj), blessed($obj2), '... they still don\'t share the same anon-class/role thing');
e');
ok(!isweak($foo->{foo}), '... it is not a weak reference');
# required writer
isnt( exception {
Foo->new;
}, undef, '... cannot create without the required attribute' )
oo_int wrote successfully' );
is($foo->foo_int(), 100, '... got the correct set value');
isnt( exception {
$foo->foo_int("Foo");
}, undef, '... foo_int died successfully' );
oo, 'foo_deref' );
is_deeply( [$foo->foo_deref_ro()], [], "... default default value" );
isnt( exception {
$foo->foo_deref_ro( [] );
}, undef, "... read only" );
$foo->{foo_d
Bar');
isnt($bar_meta, $foo_meta, '... Bar->meta != Foo->meta');
my $baz_meta = Baz->meta;
isa_ok($baz_meta, 'Class::MOP::Class');
is($baz_meta->name, 'Baz', '... baz_meta->name == Baz');
isnt($baz_
meta, $bar_meta, '... Baz->meta != Bar->meta');
isnt($baz_meta, $foo_meta, '... Baz->meta != Foo->meta');
done_testing;
one_object($foo);
isa_ok($cloned_foo, 'Foo');
isnt($cloned_foo, $foo, '... $cloned_foo is a new object different from $foo');
# check some errors
isnt( exception {
$foo_meta->clone_object($meta
OP::Attribute');
my $attr_clone = $attr->clone();
isa_ok($attr_clone, 'Class::MOP::Attribute');
isnt($attr, $attr_clone, '... we successfully cloned our attributes');
is($attr->associated_class,
:isnt( ::exception { with('Foo::Role') }, undef, '... no foo method implemented by Foo::Class' );
}
# class which does implement required method
{
package Bar::Class;
use Moose;
::isnt(
classes which does not implement required method
{
package Baz::Class;
use Moose;
::isnt( ::exception { with('Baz::Role') }, undef, '... no foo method implemented by Baz::Class2' );
}
#
Test::For::Lazy::TypeConstraint->new;
isa_ok($test, 'Test::For::Lazy::TypeConstraint');
isnt( exception {
$test->bad_lazy_attr;
}, undef, '... this does not work' );
is( exc
'ro',
isa => 'Str',
default => sub { return }
);
}
isnt( exception {
Test::UndefDefault::Attributes->new;
}, undef, '... default must return
se Moose;
has 'foo' => ( required => 1, builder => 'build_foo', is => 'ro');
}
isnt( exception {
Test::Builder::Attribute::Broken->new;
}, undef, '... no builder, wtf' )
Dog::Role;
use Moose::Role;
::isnt( ::exception {
before qr/bark.*/ => sub {};
}, undef, '... this is not currently supported' );
::isnt( ::exception {
around qr/bark
.*/ => sub {};
}, undef, '... this is not currently supported' );
::isnt( ::exception {
after qr/bark.*/ => sub {};
}, undef, '... this is not currently supported' );
}
done_te
Moose;
sub parent_method_1 { "parent_1" }
::can_ok('Parent', 'parent_method_1');
::isnt( ::exception {
has child_a => (
is => "ro",
default => sub {
handles => qr/_la$/,
);
}, undef, "can declare regex collector" );
::isnt( ::exception {
has child_d => (
is => "ro",
default => sub {
gate to object even without explicit reader" );
::can_ok('Parent', 'parent_method_1');
::isnt( ::exception {
has child_h => (
isa => "ChildH",
is => "
ride" };
::isnt( ::exception { extends() }, undef, '... extends() is not supported' );
::isnt( ::exception { augment() }, undef, '... augment() is not supported' );
::isnt( ::exception {
sFoo->meta->excludes_role('Role::Foo'), '... got the right exclusions');
# test simple exclusion
isnt( exception {
Moose::Meta::Role::Application::RoleSummation->new->apply(
Moose::Meta::
ist], ['Role::Foo'], '... has excluded roles');
}
# test conflict with an "inherited" exclusion
isnt( exception {
Moose::Meta::Role::Application::RoleSummation->new->apply(
Moose::Meta::
this fails as expected' );
# test conflict with an "inherited" exclusion of an "inherited" role
isnt( exception {
Moose::Meta::Role::Application::RoleSummation->new->apply(
Moose::Meta::
[ 'bar', 'foo' ],
'... got the right list of attributes'
);
}
# test simple conflict
isnt( exception {
Moose::Meta::Role::Application::RoleSummation->new->apply(
Moose::Meta::
]
)
);
}, undef, '... this fails as expected' );
# test complex conflict
isnt( exception {
Moose::Meta::Role::Application::RoleSummation->new->apply(
Moose::Meta::
]
)
);
}, undef, '... this fails as expected' );
# test simple conflict
isnt( exception {
Moose::Meta::Role::Application::RoleSummation->new->apply(
Moose::Meta::
h value of the header');
ok(!defined($engine->header->array), '... no array value set');
isnt( exception {
$engine->header("Foo");
}, undef, '... dies with the wrong type, even aft
>header->array), '... no array value set');
}
isnt( exception {
Engine->new(header => 'Foo');
}, undef, '... dies correctly with bad params' );
isnt( exception {
Engine->new(header => \(my $
e');
ok(!isweak($foo->{foo}), '... it is not a weak reference');
# required writer
isnt( exception {
Foo->new;
}, undef, '... cannot create without the required attribute' )
ote successfully' );
is($foo->get_foo_required(), 100, '... got the correct set value');
isnt( exception {
$foo->set_foo_required();
}, undef, '... set_foo_required died successfu
nt wrote successfully' );
is($foo->get_foo_int(), 100, '... got the correct set value');
isnt( exception {
$foo->set_foo_int("Foo");
}, undef, '... set_foo_int died successfully'
'method from role has correct name in caller()');
}
isnt(MyClass1->foo, "MyClass2::foo", "role method is not confused with other class" );
isnt(MyClass2->foo, "MyClass1::foo", "role method is not c
for Foo');
my $mi_bar = Bar->meta->get_meta_instance;
isa_ok($mi_bar, "Class::MOP::Instance");
isnt($mi_foo, $mi_bar, '... they are not the same instance');
is_deeply(
[ sort $mi_bar->get_all_
k($i_foo, "Foo");
{
my $i_foo_2 = $mi_foo->create_instance;
isa_ok($i_foo_2, "Foo");
isnt($i_foo_2, $i_foo, '... not the same instance');
is_deeply($i_foo, $i_foo_2, '... but the same
ent and child have the same last name ('
. $parent->last_name
. ')' );
}
isnt( $orphan->last_name, $parent->last_name,
'... the orphan child does not have the same l
ent and child have the same last name ('
. $parent->last_name
. ')' );
}
isnt( $orphan->last_name, $parent->last_name,
'... the orphan child is not affected by changes in
bar, $array_of_hashes, '... got our value correctly');
isnt( exception {
$foo->bar({});
}, undef, '... validation failed correctly' );
isnt( exception {
$foo->bar([{ foo => 3 }]);
}, undef,
reate_anon_class(
superclasses => ['Class'],
roles => ['Foo'],
);
isnt $class_and_foo_1->name, $class_and_foo_2->name,
'creating the same class twice without cach
uperclasses => ['Class'],
roles => ['Bar'],
cache => 1,
);
isnt $class_and_foo_1->name, $class_and_bar,
'class_and_foo and class_and_bar are different';