X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fsub-defer.t;h=ba7f042b879f2aa0fd1ee5297855990a07ccf21f;hb=9dc13bea0bcd6910d704df85dd8287c53200915b;hp=a5309b041cffc90d84b52033ecc7541f6d84bddb;hpb=a165a07fdceff024146c494a3e3923492a9b3d8d;p=gitmo%2FMoo.git diff --git a/t/sub-defer.t b/t/sub-defer.t index a5309b0..ba7f042 100644 --- a/t/sub-defer.t +++ b/t/sub-defer.t @@ -39,4 +39,19 @@ my $three = sub { 'three' }; is(undefer_sub($three), $three, 'undefer non-deferred is a no-op'); +my $four_defer = defer_sub 'Foo::four' => sub { + sub { 'four' } +}; +is($four_defer, \&Foo::four, 'four defer installed'); + +# somebody somewhere wraps up around the deferred installer +no warnings qw/redefine/; +my $orig = Foo->can('four'); +*Foo::four = sub { + $orig->() . ' with a twist'; +}; + +is(Foo->four, 'four with a twist', 'around works'); +is(Foo->four, 'four with a twist', 'around has not been destroyed by first invocation'); + done_testing;