File: instance_inline.t

package info (click to toggle)
libmoose-perl 2.2207-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,416 kB
  • sloc: perl: 21,345; ansic: 291; makefile: 10
file content (46 lines) | stat: -rw-r--r-- 1,410 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use strict;
use warnings;

use Test::More;
use Class::MOP::Instance;

my $C = 'Class::MOP::Instance';

{
    my $instance  = '$self';
    my $slot_name = 'foo';
    my $value     = '$value';
    my $class     = '$class';

    is($C->inline_create_instance($class),
      'bless {} => $class',
      '... got the right code for create_instance');
    is($C->inline_get_slot_value($instance, $slot_name),
      q[$self->{"foo"}],
      '... got the right code for get_slot_value');

    is($C->inline_set_slot_value($instance, $slot_name, $value),
      q[$self->{"foo"} = $value],
      '... got the right code for set_slot_value');

    is($C->inline_initialize_slot($instance, $slot_name),
      '',
      '... got the right code for initialize_slot');

    is($C->inline_is_slot_initialized($instance, $slot_name),
      q[exists $self->{"foo"}],
      '... got the right code for get_slot_value');

    is($C->inline_weaken_slot_value($instance, $slot_name),
      q[Scalar::Util::weaken( $self->{"foo"} )],
      '... got the right code for weaken_slot_value');

    is($C->inline_strengthen_slot_value($instance, $slot_name),
      q[$self->{"foo"} = $self->{"foo"}],
      '... got the right code for strengthen_slot_value');
    is($C->inline_rebless_instance_structure($instance, $class),
      q[bless $self => $class],
      '... got the right code for rebless_instance_structure');
}

done_testing;