Applied patch from Goro Fuji to fix leaks in creating an anonymous
[gitmo/Class-MOP.git] / t / 061_instance_inline.t
CommitLineData
ee7c0467 1use strict;
2use warnings;
3
10e9f05d 4use Test::More tests => 8;
ee7c0467 5use Test::Exception;
6
efd3d14c 7use Class::MOP::Instance;
ee7c0467 8
9my $C = 'Class::MOP::Instance';
10
11{
12 my $instance = '$self';
e9a19694 13 my $slot_name = 'foo';
ee7c0467 14 my $value = '$value';
10e9f05d 15 my $class = '$class';
ee7c0467 16
10e9f05d 17 is($C->inline_create_instance($class),
18 'bless {} => $class',
19 '... got the right code for create_instance');
8d2d4c67 20 is($C->inline_get_slot_value($instance, $slot_name),
5fb4edd5 21 "\$self->{'foo'}",
ee7c0467 22 '... got the right code for get_slot_value');
8d2d4c67 23
24 is($C->inline_set_slot_value($instance, $slot_name, $value),
5fb4edd5 25 "\$self->{'foo'} = \$value",
8d2d4c67 26 '... got the right code for set_slot_value');
ee7c0467 27
8d2d4c67 28 is($C->inline_initialize_slot($instance, $slot_name),
a007159d 29 '',
ee7c0467 30 '... got the right code for initialize_slot');
8d2d4c67 31
32 is($C->inline_is_slot_initialized($instance, $slot_name),
5fb4edd5 33 "exists \$self->{'foo'}",
8d2d4c67 34 '... got the right code for get_slot_value');
35
36 is($C->inline_weaken_slot_value($instance, $slot_name),
5fb4edd5 37 "Scalar::Util::weaken( \$self->{'foo'} )",
8d2d4c67 38 '... got the right code for weaken_slot_value');
39
40 is($C->inline_strengthen_slot_value($instance, $slot_name),
5fb4edd5 41 "\$self->{'foo'} = \$self->{'foo'}",
8d2d4c67 42 '... got the right code for strengthen_slot_value');
10e9f05d 43 is($C->inline_rebless_instance_structure($instance, $class),
5fb4edd5 44 "bless \$self => \$class",
10e9f05d 45 '... got the right code for rebless_instance_structure');
8d2d4c67 46}
47
8d2d4c67 48