| | 57 | |
| | 58 | my $sub_mmc = Perl::Meta::Class::new('SubClass'); |
| | 59 | $sub_mmc.superclass($mmc); |
| | 60 | |
| | 61 | $sub_mmc.addMethod('method2', $method2); |
| | 62 | |
| | 63 | ok($sub_mmc.isMethodSupported('method1'), '... did find the method in parent class'); |
| | 64 | ok($sub_mmc.findMethod('method1') =:= $method1, '... found the right method (in parent class)'); |
| | 65 | |
| | 66 | ok(!$mmc.isMethodSupported('method2'), '... did not find the method (as expected) in parent class'); |
| | 67 | ok($sub_mmc.isMethodSupported('method2'), '... did find the method (as expected) in class'); |
| | 68 | |
| | 69 | my $sub_sub_mmc = Perl::Meta::Class::new('SubSubClass'); |
| | 70 | $sub_sub_mmc.superclass($sub_mmc); |
| | 71 | |
| | 72 | ok($sub_sub_mmc.isMethodSupported('method1'), '... did find the method in parents parent class'); |
| | 73 | ok($sub_sub_mmc.findMethod('method1') =:= $method1, '... found the right method (in parents parent class)'); |
| | 74 | ok($sub_sub_mmc.findMethod('method2'), '... did find the method (as expected) in parents class'); |
| | 75 | |
| | 76 | # check some errors |
| | 77 | |
| | 78 | $!= undef; |
| | 79 | dies_ok { |
| | 80 | $mmc.invokeMethod('method2'); |
| | 81 | }, '... this dies as expected'; |
| | 82 | like($!, rx:perl5/^Method not found/, '... got the right error'); |
| | 83 | |
| | 84 | $!= undef; |
| | 85 | dies_ok { |
| | 86 | $sub_sub_mmc.invokeMethod('method1'); |
| | 87 | }, '... this dies as expected'; |
| | 88 | like($!, rx:perl5/^Method has no code/, '... got the right error'); |
| | 89 | |
| | 90 | is($sub_mmc.invokeMethod('method2'), 'Hello World', '... the method returned what we expected'); |