Merge branch 'stable'
[gitmo/Class-MOP.git] / t / 061_instance_inline.t
index 9689bba..7100c80 100644 (file)
@@ -1,10 +1,8 @@
-#!/usr/bin/perl
-
 use strict;
 use warnings;
 
-use Test::More tests => 15;
-use Test::Exception;
+use Test::More;
+use Test::Fatal;
 
 use Class::MOP::Instance;
 
@@ -12,45 +10,19 @@ my $C = 'Class::MOP::Instance';
 
 {
     my $instance  = '$self';
-    my $slot_name = '"foo"';
+    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),
-      '$self->{"foo"}',
-      '... got the right code for get_slot_value');
-
-    is($C->inline_set_slot_value($instance, $slot_name, $value),
-      '$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),
-      'exists $self->{"foo"}',
-      '... got the right code for get_slot_value');
-
-    is($C->inline_weaken_slot_value($instance, $slot_name),
-      'Scalar::Util::weaken( $self->{"foo"} )',
-      '... got the right code for weaken_slot_value');
-
-    is($C->inline_strengthen_slot_value($instance, $slot_name),
-      '$self->{"foo"} = $self->{"foo"}',
-      '... got the right code for strengthen_slot_value');
-}
-
-{
-    my $instance  = '$_[0]';
-    my $slot_name = '$attr_name';
-    my $value     = '[]';
-
-    is($C->inline_get_slot_value($instance, $slot_name),
-      '$_[0]->{$attr_name}',
+      q[$self->{"foo"}],
       '... got the right code for get_slot_value');
 
     is($C->inline_set_slot_value($instance, $slot_name, $value),
-      '$_[0]->{$attr_name} = []',
+      q[$self->{"foo"} = $value],
       '... got the right code for set_slot_value');
 
     is($C->inline_initialize_slot($instance, $slot_name),
@@ -58,49 +30,19 @@ my $C = 'Class::MOP::Instance';
       '... got the right code for initialize_slot');
 
     is($C->inline_is_slot_initialized($instance, $slot_name),
-      'exists $_[0]->{$attr_name}',
+      q[exists $self->{"foo"}],
       '... got the right code for get_slot_value');
 
     is($C->inline_weaken_slot_value($instance, $slot_name),
-      'Scalar::Util::weaken( $_[0]->{$attr_name} )',
+      q[Scalar::Util::weaken( $self->{"foo"} )],
       '... got the right code for weaken_slot_value');
 
     is($C->inline_strengthen_slot_value($instance, $slot_name),
-      '$_[0]->{$attr_name} = $_[0]->{$attr_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');
 }
 
-my $accessor_string = "sub {\n"
-. $C->inline_set_slot_value('$_[0]', '$attr_name', '$_[1]')
-. " if scalar \@_ == 2;\n"
-. $C->inline_get_slot_value('$_[0]', '$attr_name')
-. ";\n}";
-
-is($accessor_string,
-   q|sub {
-$_[0]->{$attr_name} = $_[1] if scalar @_ == 2;
-$_[0]->{$attr_name};
-}|,
-    '... got the right code string for accessor');
-
-my $reader_string = "sub {\n"
-. $C->inline_get_slot_value('$_[0]', '$attr_name')
-. ";\n}";
-
-is($reader_string,
-   q|sub {
-$_[0]->{$attr_name};
-}|,
-    '... got the right code string for reader');
-
-my $writer_string = "sub {\n"
-. $C->inline_set_slot_value('$_[0]', '$attr_name', '$_[1]')
-. ";\n}";
-
-is($writer_string,
-   q|sub {
-$_[0]->{$attr_name} = $_[1];
-}|,
-    '... got the right code string for writer');
-
-
+done_testing;