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