X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F104_AttributesWithHistory_test.t;h=5b74faa2a558b37a67cd1feb664f482f64b1033e;hb=9b71b643464868f1f6515f435ef3457b29c8bdcd;hp=ada9d6786e0cf3b9ac19711252c4f680aff4f453;hpb=d6fbcd05c5a7e4bb8a947a603878f3a08b2f5bee;p=gitmo%2FClass-MOP.git diff --git a/t/104_AttributesWithHistory_test.t b/t/104_AttributesWithHistory_test.t index ada9d67..5b74faa 100644 --- a/t/104_AttributesWithHistory_test.t +++ b/t/104_AttributesWithHistory_test.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 19; +use Test::More tests => 28; use File::Spec; BEGIN { @@ -13,8 +13,7 @@ BEGIN { { package Foo; - - use Class::MOP 'meta'; + use metaclass; Foo->meta->add_attribute(AttributesWithHistory->new('foo' => ( accessor => 'foo', @@ -29,8 +28,8 @@ BEGIN { sub new { my $class = shift; - bless $class->meta->construct_instance(@_) => $class; - } + $class->meta->new_object(@_); + } } my $foo = Foo->new(); @@ -42,11 +41,20 @@ can_ok($foo, 'set_bar'); can_ok($foo, 'get_bar'); can_ok($foo, 'get_bar_history'); +my $foo2 = Foo->new(); +isa_ok($foo2, 'Foo'); + is($foo->foo, undef, '... foo is not yet defined'); is_deeply( [ $foo->get_foo_history() ], [ ], '... got correct empty history for foo'); + +is($foo2->foo, undef, '... foo2 is not yet defined'); +is_deeply( + [ $foo2->get_foo_history() ], + [ ], + '... got correct empty history for foo2'); $foo->foo(42); is($foo->foo, 42, '... foo == 42'); @@ -55,6 +63,25 @@ is_deeply( [ 42 ], '... got correct history for foo'); +is($foo2->foo, undef, '... foo2 is still not yet defined'); +is_deeply( + [ $foo2->get_foo_history() ], + [ ], + '... still got correct empty history for foo2'); + +$foo2->foo(100); +is($foo->foo, 42, '... foo is still == 42'); +is_deeply( + [ $foo->get_foo_history() ], + [ 42 ], + '... still got correct history for foo'); + +is($foo2->foo, 100, '... foo2 == 100'); +is_deeply( + [ $foo2->get_foo_history() ], + [ 100 ], + '... got correct empty history for foo2'); + $foo->foo(43); $foo->foo(44); $foo->foo(45);