- Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathextendingrect.t
35 lines (28 loc) · 560 Bytes
/
extendingrect.t
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
packageMyRect;
use strict;
use warnings;
use base 'SDL::Rect';
subnew {
my$class = shift;
my$self = $class->SUPER::new(@_);
unless ( ref$self ) {
require Carp;
Carp::confess SDL::GetError();
}
returnbless$self=>$class;
}
subfoo {
my$self = shift;
return$self->x;
}
packagemain;
use Test::More tests=> 6;
my$rect = MyRect->new( 0, 0, 0, 0 );
isa_ok( $rect, 'SDL::Rect' );
isa_ok( $rect, 'MyRect' );
can_ok( $rect, qw(x y w h) );
can_ok( $rect, qw(new foo) );
$rect->x(10);
is( $rect->x, 10 );
is( $rect->foo, 10 );
sleep(2);