Commit | Line | Data |
e6007308 |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings; |
4 | use Test::More tests => 3; |
5 | use Test::Exception; |
6 | |
7 | my @parent_calls; |
8 | my @child_calls; |
9 | |
10 | do { |
11 | package Parent; |
12 | sub foo { push @parent_calls, [@_] } |
13 | |
14 | package Child; |
15 | use Mouse; |
16 | extends 'Parent'; |
17 | |
18 | override foo => sub { |
19 | my $self = shift; |
20 | push @child_calls, [splice @_]; |
21 | super; |
22 | }; |
23 | }; |
24 | |
25 | Child->foo(10, 11); |
26 | is_deeply([splice @parent_calls], [[Child => 10, 11]]); |
27 | is_deeply([splice @child_calls], [[10, 11]]); |
28 | |
29 | throws_ok { |
30 | package Orphan; # :( |
31 | use Mouse; |
32 | override foo => sub { }; |
33 | } qr/^You cannot override 'foo' because it has no super method/; |
34 | |