File: 020_super_recursion.t

package info (click to toggle)
libmouse-perl 2.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,156 kB
  • sloc: perl: 14,569; ansic: 218; makefile: 8
file content (73 lines) | stat: -rw-r--r-- 1,465 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
use strict;
# This is automatically generated by author/import-moose-test.pl.
# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
use lib "t/lib";
use MooseCompat;
use warnings;

use Test::More;

{
    package A;
    use Mouse;

    sub foo {
        ::BAIL_OUT('A::foo called twice') if $main::seen{'A::foo'}++;
        return 'a';
    }

    sub bar {
        ::BAIL_OUT('A::bar called twice') if $main::seen{'A::bar'}++;
        return 'a';
    }

    sub baz {
        ::BAIL_OUT('A::baz called twice') if $main::seen{'A::baz'}++;
        return 'a';
    }
}

{
    package B;
    use Mouse;
    extends qw(A);

    sub foo {
        ::BAIL_OUT('B::foo called twice') if $main::seen{'B::foo'}++;
        return 'b' . super();
    }

    sub bar {
        ::BAIL_OUT('B::bar called twice') if $main::seen{'B::bar'}++;
        return 'b' . ( super() || '' );
    }

    override baz => sub {
        ::BAIL_OUT('B::baz called twice') if $main::seen{'B::baz'}++;
        return 'b' . super();
    };
}

{
    package C;
    use Mouse;
    extends qw(B);

    sub foo { return 'c' . ( super() || '' ) }

    override bar => sub {
        ::BAIL_OUT('C::bar called twice') if $main::seen{'C::bar'}++;
        return 'c' . super();
    };

    override baz => sub {
        ::BAIL_OUT('C::baz called twice') if $main::seen{'C::baz'}++;
        return 'c' . super();
    };
}

is( C->new->foo, 'c' );
is( C->new->bar, 'cb' );
is( C->new->baz, 'cba' );

done_testing;