docs for CMOP::Instance
[gitmo/Class-MOP.git] / t / 061_instance_inline.t
index ec35302..62f0eec 100644 (file)
@@ -1,24 +1,20 @@
-#!/usr/bin/perl
-
 use strict;
 use warnings;
 
-use Test::More tests => 16;
+use Test::More tests => 6;
 use Test::Exception;
 
-BEGIN {
-    use_ok('Class::MOP::Instance');
-}
+use Class::MOP::Instance;
 
 my $C = 'Class::MOP::Instance';
 
 {
     my $instance  = '$self';
-    my $slot_name = '"foo"';
+    my $slot_name = 'foo';
     my $value     = '$value';
 
     is($C->inline_get_slot_value($instance, $slot_name),
-      'exists $self->{"foo"} ? $self->{"foo"} : undef',
+      '$self->{"foo"}',
       '... got the right code for get_slot_value');
 
     is($C->inline_set_slot_value($instance, $slot_name, $value),
@@ -26,11 +22,11 @@ my $C = 'Class::MOP::Instance';
       '... got the right code for set_slot_value');
 
     is($C->inline_initialize_slot($instance, $slot_name),
-      '$self->{"foo"} = undef',
+      '',
       '... got the right code for initialize_slot');
 
     is($C->inline_is_slot_initialized($instance, $slot_name),
-      'exists $self->{"foo"} ? 1 : 0',
+      'exists $self->{"foo"}',
       '... got the right code for get_slot_value');
 
     is($C->inline_weaken_slot_value($instance, $slot_name),
@@ -42,67 +38,4 @@ my $C = 'Class::MOP::Instance';
       '... 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),
-      'exists $_[0]->{$attr_name} ? $_[0]->{$attr_name} : undef',
-      '... got the right code for get_slot_value');
-
-    is($C->inline_set_slot_value($instance, $slot_name, $value),
-      '$_[0]->{$attr_name} = []',
-      '... got the right code for set_slot_value');
-
-    is($C->inline_initialize_slot($instance, $slot_name),
-      '$_[0]->{$attr_name} = undef',
-      '... got the right code for initialize_slot');
-
-    is($C->inline_is_slot_initialized($instance, $slot_name),
-      'exists $_[0]->{$attr_name} ? 1 : 0',
-      '... got the right code for get_slot_value');
-
-    is($C->inline_weaken_slot_value($instance, $slot_name),
-      'Scalar::Util::weaken( $_[0]->{$attr_name} )',
-      '... got the right code for weaken_slot_value');
-
-    is($C->inline_strengthen_slot_value($instance, $slot_name),
-      '$_[0]->{$attr_name} = $_[0]->{$attr_name}',
-      '... got the right code for strengthen_slot_value');
-}
-
-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;
-exists $_[0]->{$attr_name} ? $_[0]->{$attr_name} : undef;
-}|,
-    '... 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 {
-exists $_[0]->{$attr_name} ? $_[0]->{$attr_name} : undef;
-}|,
-    '... 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');
-