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