X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F001_cmop%2F047_rebless_with_extra_params.t;fp=t%2F001_cmop%2F047_rebless_with_extra_params.t;h=0000000000000000000000000000000000000000;hb=829433c47061dd70a608bfcd940113c4172b6950;hp=ee29aa349aa691a63267a214a20bfda63d8f7899;hpb=51c788414482c813eb48fb417b08ba03134ff1a6;p=gitmo%2FMoose.git diff --git a/t/001_cmop/047_rebless_with_extra_params.t b/t/001_cmop/047_rebless_with_extra_params.t deleted file mode 100644 index ee29aa3..0000000 --- a/t/001_cmop/047_rebless_with_extra_params.t +++ /dev/null @@ -1,95 +0,0 @@ -use strict; -use warnings; - -use Test::More; -use Test::Fatal; - -use Class::MOP; - -{ - package Foo; - use metaclass; - Foo->meta->add_attribute('bar' => (reader => 'bar')); - - sub new { (shift)->meta->new_object(@_) } - - package Bar; - use metaclass; - use base 'Foo'; - Bar->meta->add_attribute('baz' => (reader => 'baz', default => 'BAZ')); -} - -# normal ... -{ - my $foo = Foo->new(bar => 'BAR'); - isa_ok($foo, 'Foo'); - - is($foo->bar, 'BAR', '... got the expect value'); - ok(!$foo->can('baz'), '... no baz method though'); - - is( exception { - Bar->meta->rebless_instance($foo) - }, undef, '... this works' ); - - is($foo->bar, 'BAR', '... got the expect value'); - ok($foo->can('baz'), '... we have baz method now'); - is($foo->baz, 'BAZ', '... got the expect value'); - - is( exception { - Foo->meta->rebless_instance_back($foo) - }, undef, '... this works' ); - is($foo->bar, 'BAR', '... got the expect value'); - ok(!$foo->can('baz'), '... no baz method though'); -} - -# with extra params ... -{ - my $foo = Foo->new(bar => 'BAR'); - isa_ok($foo, 'Foo'); - - is($foo->bar, 'BAR', '... got the expect value'); - ok(!$foo->can('baz'), '... no baz method though'); - - is( exception { - Bar->meta->rebless_instance($foo, (baz => 'FOO-BAZ')) - }, undef, '... this works' ); - - is($foo->bar, 'BAR', '... got the expect value'); - ok($foo->can('baz'), '... we have baz method now'); - is($foo->baz, 'FOO-BAZ', '... got the expect value'); - - is( exception { - Foo->meta->rebless_instance_back($foo) - }, undef, '... this works' ); - - is($foo->bar, 'BAR', '... got the expect value'); - ok(!$foo->can('baz'), '... no baz method though'); - ok(!exists($foo->{baz}), '... and the baz attribute was deinitialized'); -} - -# with extra params ... -{ - my $foo = Foo->new(bar => 'BAR'); - isa_ok($foo, 'Foo'); - - is($foo->bar, 'BAR', '... got the expect value'); - ok(!$foo->can('baz'), '... no baz method though'); - - is( exception { - Bar->meta->rebless_instance($foo, (bar => 'FOO-BAR', baz => 'FOO-BAZ')) - }, undef, '... this works' ); - - is($foo->bar, 'FOO-BAR', '... got the expect value'); - ok($foo->can('baz'), '... we have baz method now'); - is($foo->baz, 'FOO-BAZ', '... got the expect value'); - - is( exception { - Foo->meta->rebless_instance_back($foo) - }, undef, '... this works' ); - - is($foo->bar, 'FOO-BAR', '... got the expect value'); - ok(!$foo->can('baz'), '... no baz method though'); - ok(!exists($foo->{baz}), '... and the baz attribute was deinitialized'); -} - -done_testing;