Regenerate test files
[gitmo/Mouse.git] / t / 010_basics / 006_override_and_foreign_classes.t
CommitLineData
60ad2cb7 1#!/usr/bin/perl
fde8e43f 2# This is automatically generated by author/import-moose-test.pl.
3# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4use t::lib::MooseCompat;
60ad2cb7 5
6use strict;
7use warnings;
8
fde8e43f 9use Test::More;
60ad2cb7 10
11
12=pod
13
14This just tests the interaction of override/super
15with non-Mouse superclasses. It really should not
16cause issues, the only thing it does is to create
17a metaclass for Foo so that it can find the right
18super method.
19
20This may end up being a sensitive issue for some
21non-Mouse classes, but in 99% of the cases it
22should be just fine.
23
24=cut
25
26{
27 package Foo;
28 use strict;
29 use warnings;
30
31 sub new { bless {} => shift() }
32
33 sub foo { 'Foo::foo' }
34 sub bar { 'Foo::bar' }
35 sub baz { 'Foo::baz' }
36
37 package Bar;
38 use Mouse;
39
40 extends 'Foo';
41
42 override bar => sub { 'Bar::bar -> ' . super() };
43
44 package Baz;
45 use Mouse;
46
47 extends 'Bar';
48
49 override bar => sub { 'Baz::bar -> ' . super() };
50 override baz => sub { 'Baz::baz -> ' . super() };
51}
52
53my $baz = Baz->new();
54isa_ok($baz, 'Baz');
55isa_ok($baz, 'Bar');
56isa_ok($baz, 'Foo');
57
58is($baz->foo(), 'Foo::foo', '... got the right value from &foo');
59is($baz->bar(), 'Baz::bar -> Bar::bar -> Foo::bar', '... got the right value from &bar');
60is($baz->baz(), 'Baz::baz -> Foo::baz', '... got the right value from &baz');
61
62my $bar = Bar->new();
63isa_ok($bar, 'Bar');
64isa_ok($bar, 'Foo');
65
66is($bar->foo(), 'Foo::foo', '... got the right value from &foo');
67is($bar->bar(), 'Bar::bar -> Foo::bar', '... got the right value from &bar');
68is($bar->baz(), 'Foo::baz', '... got the right value from &baz');
69
70my $foo = Foo->new();
71isa_ok($foo, 'Foo');
72
73is($foo->foo(), 'Foo::foo', '... got the right value from &foo');
74is($foo->bar(), 'Foo::bar', '... got the right value from &bar');
fde8e43f 75is($foo->baz(), 'Foo::baz', '... got the right value from &baz');
76
77done_testing;