Added core test template
[sdlgit/SDL_perl.git] / t / timerpm.t
index b94b1ee..51d81d5 100644 (file)
 #
 # 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,11 +66,6 @@ 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;