Fixed the pod path in archive
[sdlgit/SDL_perl.git] / t / timerpm.t
CommitLineData
8fde61e3 1#!/usr/bin/perl -w
2#
3# Copyright (C) 2003 Tels
4# Copyright (C) 2004 David J. Goehrig
5#
7b6a53a1 6# Copyright (C) 2005 David J. Goehrig <dgoehrig\@cpan.org>
7#
8# ------------------------------------------------------------------------------
9#
10# This library is free software; you can redistribute it and/or
11# modify it under the terms of the GNU Lesser General Public
12# License as published by the Free Software Foundation; either
13# version 2.1 of the License, or (at your option) any later version.
14#
15# This library is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18# Lesser General Public License for more details.
19#
20# You should have received a copy of the GNU Lesser General Public
21# License along with this library; if not, write to the Free Software
22# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23#
24# ------------------------------------------------------------------------------
25#
26# Please feel free to send questions, suggestions or improvements to:
27#
28# David J. Goehrig
29# dgoehrig\@cpan.org
30#
31#
8fde61e3 32# basic testing of SDL::Timer
33
8fde61e3 34use strict;
35use SDL;
36use SDL::Config;
8fde61e3 37use Test::More;
38
c2f3910b 39BEGIN {
40 unshift @INC, 'blib/lib','blib/arch';
41}
42
43sub check_fail_timer
44{
45 my $ret = 0;
46 eval
47 {
d5a2f5ac 48 $ret = SDL::init(SDL_INIT_TIMER);
c2f3910b 49 };
3493aca9 50 return 1 if ($@ or $ret == -1);
c2f3910b 51 return 0;
52}
53
54if( check_fail_timer() )
d69de417 55{
56 plan( skip_all => "Cannot initialize timer!!" );
d69de417 57}
c2f3910b 58
8fde61e3 59plan ( tests => 4 );
60
61use_ok( 'SDL::Timer' );
62
63can_ok ('SDL::Timer', qw/
64 new run stop
65 /);
66
67my $fired = 0;
68
8fde61e3 69
70my $timer = new SDL::Timer
71 sub { $fired++ }, -delay => 30, -times => 1;
72
73isa_ok($timer, 'SDL::Timer');
74
d5a2f5ac 75SDL::delay(100);
8fde61e3 76is ($fired, 1,'timer fired once');