X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F300_immutable%2F016_inline_fallbacks.t;fp=t%2F300_immutable%2F016_inline_fallbacks.t;h=8a5635b7ccc3b1e739363d02653db5846be89591;hb=16504b1548c2c3b2570a46b1864287f50d49faf2;hp=0000000000000000000000000000000000000000;hpb=ee5e6a034b6aeaed7819138193288eb249d9380b;p=gitmo%2FMouse.git diff --git a/t/300_immutable/016_inline_fallbacks.t b/t/300_immutable/016_inline_fallbacks.t new file mode 100644 index 0000000..8a5635b --- /dev/null +++ b/t/300_immutable/016_inline_fallbacks.t @@ -0,0 +1,73 @@ +use strict; +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; +use warnings; +use Test::More; + +{ + package Foo; + use Mouse; + has foo => (is => 'ro'); +} + +{ + package Foo::Sub; + use Mouse; + extends 'Foo'; + has bar => (is => 'ro'); +} + +{ + my $foo = Foo::Sub->new(foo => 12, bar => 25); + is($foo->foo, 12, 'got right value for foo'); + is($foo->bar, 25, 'got right value for bar'); +} + +Foo->meta->make_immutable; + +{ + package Foo::Sub2; + use Mouse; + extends 'Foo'; + has baz => (is => 'ro'); + # not making immutable, inheriting Foo's inlined constructor +} + +{ + my $foo = Foo::Sub2->new(foo => 42, baz => 27); + is($foo->foo, 42, 'got right value for foo'); + is($foo->baz, 27, 'got right value for baz'); +} + +my $BAR = 0; +{ + package Bar; + use Mouse; +} + +{ + package Bar::Sub; + use Mouse; + extends 'Bar'; + sub DEMOLISH { $BAR++ } +} + +Bar::Sub->new; +is($BAR, 1, 'DEMOLISH in subclass was called'); +$BAR = 0; + +Bar->meta->make_immutable; + +{ + package Bar::Sub2; + use Mouse; + extends 'Bar'; + sub DEMOLISH { $BAR++ } + # not making immutable, inheriting Bar's inlined destructor +} + +Bar::Sub2->new; +is($BAR, 1, 'DEMOLISH in subclass was called'); + +done_testing;