e6733c6c1a9728a9316cddf287790480043bc995
[sdlgit/SDL_perl.git] / t / extendingrect.t
1 package MyRect;
2 use base 'SDL::Rect';
3
4 sub new {
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
18 }
19
20 sub foo {
21         my $self = shift;
22         return $self->x;
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);