Added latest bugfix to Changes.
[gitmo/Mouse.git] / t / 042-override.t
CommitLineData
e6007308 1#!/usr/bin/env perl
2use strict;
3use warnings;
4use Test::More tests => 3;
5use Test::Exception;
6
7my @parent_calls;
8my @child_calls;
9
10do {
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
25Child->foo(10, 11);
26is_deeply([splice @parent_calls], [[Child => 10, 11]]);
27is_deeply([splice @child_calls], [[10, 11]]);
28
29throws_ok {
30 package Orphan; # :(
31 use Mouse;
32 override foo => sub { };
33} qr/^You cannot override 'foo' because it has no super method/;
34