X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Ftimerpm.t;h=8f0a3370710c0537a8c74b856ae84e2ddb97b187;hb=HEAD;hp=b94b1ee853cc773299709fa5c896cc9419ebe474;hpb=fe6d1297a5ad798f9935c4ee4771e907554c2299;p=sdlgit%2FSDL_perl.git diff --git a/t/timerpm.t b/t/timerpm.t index b94b1ee..8f0a337 100644 --- a/t/timerpm.t +++ b/t/timerpm.t @@ -31,15 +31,30 @@ # # basic testing of SDL::Timer +use strict; +use SDL; +use SDL::Config; +use Test::More; + BEGIN { unshift @INC, 'blib/lib','blib/arch'; } -use strict; -use SDL; -use SDL::Config; +sub check_fail_timer +{ + my $ret = 0; + eval + { + $ret = SDL::init(SDL_INIT_TIMER); + }; + return 1 if ($@ or $ret == -1); + return 0; +} -use Test::More; +if( check_fail_timer() ) +{ + plan( skip_all => "Cannot initialize timer!!" ); +} plan ( tests => 4 ); @@ -51,16 +66,11 @@ can_ok ('SDL::Timer', qw/ my $fired = 0; -if (SDL::Init(SDL_INIT_TIMER) < 0 ) -{ - plan( skip_all => "Cannot initialize timer!!" ); - -} my $timer = new SDL::Timer sub { $fired++ }, -delay => 30, -times => 1; isa_ok($timer, 'SDL::Timer'); -SDL::Delay(100); +SDL::delay(100); is ($fired, 1,'timer fired once');