File: start.t

package info (click to toggle)
libclass-std-perl 0.011-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 352 kB
  • ctags: 122
  • sloc: perl: 871; makefile: 2
file content (43 lines) | stat: -rw-r--r-- 858 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
print "1..4\n";

package MyBase;
use Class::Std;
{
    my %attr : ATTR( :default(42) );

    sub BUILD {
        my ($self, $id) = @_;
        print 'not ' if defined $attr{$id};
        print "ok 1 - Default not available in BUILD\n";
    }

    sub START {
        my ($self, $id) = @_;
        print 'not ' if !defined $attr{$id};
        print "ok 3 - Default set before START\n";
    }
}

package Der;
use Class::Std;
use base qw( MyBase );
{
    my %attr : ATTR( :init_arg<attr> );

    sub BUILD {
        my ($self, $id) = @_;
        print 'not ' if defined $attr{$id};
        print "ok 2 - Init arg not available in BUILD\n";
    }

    sub START {
        my ($self, $id) = @_;
        print 'not ' if !defined $attr{$id} || $attr{$id} ne '86';
        print "ok 4 - Init arg set before START\n";
    }
}

package main;

Der->new({ attr=>86 });