Commit | Line | Data |
---|---|---|
98ce5b8c | 1 | package MyRect; |
2 | use base 'SDL::Rect'; | |
3 | ||
4 | sub new { | |
bdd52efa | 5 | my $class = shift; |
987e1542 | 6 | my $self = $class->SUPER::new(@_); |
7 | unless (ref $self) { | |
bdd52efa | 8 | require Carp; |
9 | Carp::croak SDL::GetError(); | |
10 | } | |
987e1542 | 11 | return bless $self => $class;; |
bdd52efa | 12 | |
98ce5b8c | 13 | } |
14 | ||
15 | sub foo { | |
bdd52efa | 16 | my $self = shift; |
17 | return $self->x; | |
98ce5b8c | 18 | } |
19 | ||
20 | package main; | |
21 | use Test::More tests => 6; | |
22 | ||
987e1542 | 23 | my $rect = MyRect->new(0,0,0,0); |
98ce5b8c | 24 | |
25 | isa_ok($rect, 'SDL::Rect'); | |
26 | isa_ok($rect, 'MyRect'); | |
05eb21df | 27 | can_ok($rect, qw(x y w h)); |
98ce5b8c | 28 | can_ok($rect, qw(new foo)); |
29 | ||
30 | $rect->x(10); | |
31 | is($rect->x, 10); | |
32 | is($rect->foo, 10); |