6 use Test::More tests => 25;
10 use_ok('Class::MOP::Instance');
13 can_ok( "Class::MOP::Instance", $_ ) for qw/
17 bless_instance_structure
32 Foo->meta->add_attribute('moosen');
38 Bar->meta->add_attribute('elken');
41 my $mi_foo = Foo->meta->get_meta_instance;
42 isa_ok($mi_foo, "Class::MOP::Instance");
45 [ $mi_foo->get_all_slots ],
47 '... get all slots for Foo');
49 my $mi_bar = Bar->meta->get_meta_instance;
50 isa_ok($mi_bar, "Class::MOP::Instance");
52 isnt($mi_foo, $mi_bar, '... they are not the same instance');
55 [ sort $mi_bar->get_all_slots ],
56 [ "elken", "moosen" ],
57 '... get all slots for Bar');
59 my $i_foo = $mi_foo->create_instance;
60 isa_ok($i_foo, "Foo");
63 my $i_foo_2 = $mi_foo->create_instance;
64 isa_ok($i_foo_2, "Foo");
65 isnt($i_foo_2, $i_foo, '... not the same instance');
66 is_deeply($i_foo, $i_foo_2, '... but the same structure');
69 ok(!defined($mi_foo->get_slot_value( $i_foo, "moosen" )), "... no value for slot");
71 $mi_foo->set_slot_value( $i_foo, "moosen", "the value" );
73 is($mi_foo->get_slot_value( $i_foo, "moosen" ), "the value", "... get slot value");
75 ok(!$i_foo->can('moosen'), '... Foo cant moosen');
77 eval 'sub Foo::moosen { ' . $mi_foo->inline_get_slot_value( '$_[0]', 'moosen' ) . ' }';
78 ok(!$@, "compilation of inline get value had no error");
80 can_ok($i_foo, 'moosen');
82 is($i_foo->moosen, "the value", "... inline get value worked");
84 $mi_foo->set_slot_value( $i_foo, "moosen", "the other value" );
86 is($i_foo->moosen, "the other value", "... inline get value worked (even after value is changed)");