File: super.t

package info (click to toggle)
libspiffy-perl 0.21-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 256 kB
  • ctags: 99
  • sloc: perl: 1,067; makefile: 50
file content (55 lines) | stat: -rw-r--r-- 787 bytes parent folder | download | duplicates (5)
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
use lib 'lib';

package Foo;
use strict;
use Spiffy -base;
field 'xxx';
field 'dog';
field 'bog';

sub new {
    my $self = super;
    $self->xxx('XXX');
    return $self;
}

sub poodle {
    my $self = shift;
    my $count = shift;
    $self->dog("$count poodle");
}

sub doodle {
    my $self = shift;
    my $count = shift;
    $self->bog("$count doodle");
}

package Bar;
use strict;
BEGIN { Foo->base }

sub poodle {
    my $self = shift;
    super;
    $self->dog($self->dog . ' dogs');
}

sub doodle {
    my $self = shift;
    eval 'eval "super"';
    $self->bog($self->bog . ' bogs');
}

package main;
use strict;
use Test::More tests => 3;

my $f = Bar->new;
is($f->{xxx}, 'XXX');

$f->poodle(3);
is($f->{dog}, '3 poodle dogs');

$f->doodle(4);
is($f->{bog}, '4 doodle bogs');