Fixed Rect extension test but still not statisfied
[sdlgit/SDL_perl.git] / t / extendingrect.t
CommitLineData
98ce5b8c 1package MyRect;
2use base 'SDL::Rect';
3
4sub 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
20sub foo {
bdd52efa 21 my $self = shift;
22 return $self->x;
98ce5b8c 23}
24
25package main;
26use Test::More tests => 6;
27
28my $rect = MyRect->new;
29
30isa_ok($rect, 'SDL::Rect');
31isa_ok($rect, 'MyRect');
32can_ok($rect, qw(x y top left w h width height));
33can_ok($rect, qw(new foo));
34
35$rect->x(10);
36is($rect->x, 10);
37is($rect->foo, 10);