From: Jesse Luehrs Date: Tue, 6 Apr 2010 23:06:37 +0000 (-0500) Subject: todo test for replacing superclass versions of override methods (ether) X-Git-Tag: 1.02~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d963b98766ad941a9ee1a17da547982f166cf77e;p=gitmo%2FMoose.git todo test for replacing superclass versions of override methods (ether) --- diff --git a/t/600_todo_tests/008_replacing_super_methods.t b/t/600_todo_tests/008_replacing_super_methods.t new file mode 100755 index 0000000..a7f3d2c --- /dev/null +++ b/t/600_todo_tests/008_replacing_super_methods.t @@ -0,0 +1,43 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; + +my ($super_called, $sub_called, $new_super_called) = (0, 0, 0); +{ + package Foo; + use Moose; + + sub foo { $super_called++ } +} + +{ + package Foo::Sub; + use Moose; + extends 'Foo'; + + override foo => sub { + $sub_called++; + super(); + }; +} + +Foo::Sub->new->foo; +is($super_called, 1, "super called"); +is($new_super_called, 0, "new super not called"); +is($sub_called, 1, "sub called"); + +($super_called, $sub_called, $new_super_called) = (0, 0, 0); + +Foo->meta->add_method(foo => sub { + $new_super_called++; +}); + +Foo::Sub->new->foo; +{ local $TODO = "super doesn't get replaced"; +is($super_called, 0, "super not called"); +is($new_super_called, 1, "new super called"); +} +is($sub_called, 1, "sub called"); + +done_testing;