From: Uri Guttman Date: Tue, 15 Sep 2009 18:34:45 +0000 (-0400) Subject: merged and cleaned up event tests X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=907cbc6d770ea6bf36c1649d1952caaccf17d420;p=urisagit%2FStem.git merged and cleaned up event tests --- diff --git a/lib/Stem/Event.pm b/lib/Stem/Event.pm index 712ccc7..3d1f114 100644 --- a/lib/Stem/Event.pm +++ b/lib/Stem/Event.pm @@ -69,15 +69,7 @@ INIT{ init_loop() ; } sub init_loop { -Stem::Event::Queue::_init_queue() if defined &Stem::Event::Queue::_init_queue ; - $loop_class->_init_loop() ; - -<<<<<<< HEAD:lib/Stem/Event.pm -#Stem::Event::Queue::_init_queue() if defined &Stem::Event::Queue::_init_queue ; -======= ->>>>>>> master:lib/Stem/Event.pm - } sub start_loop { @@ -300,7 +292,7 @@ sub _get_loop_class { $loop_type = 'perl' unless $loop_to_class{ $loop_type } ; my $loop_class = "Stem::Event::$loop_to_class{ $loop_type }" ; -print "LOOP $loop_class\n" ; +#print "LOOP $loop_class\n" ; unless ( eval "require $loop_class" ) { die "can't load $loop_class: $@" if $@ && $@ !~ /locate/ ; @@ -326,10 +318,6 @@ print "not found\n" ; ############################################################################ package Stem::Event::Plain ; -<<<<<<< HEAD:lib/Stem/Event.pm - -======= ->>>>>>> master:lib/Stem/Event.pm our @ISA = qw( Stem::Event ) ; =head2 Stem::Event::Plain::new @@ -386,10 +374,6 @@ sub new { ############################################################################ package Stem::Event::Signal ; -<<<<<<< HEAD:lib/Stem/Event.pm - -======= ->>>>>>> master:lib/Stem/Event.pm our @ISA = qw( Stem::Event ) ; =head2 Stem::Event::Signal::new @@ -476,10 +460,6 @@ sub new { ############################################################################ package Stem::Event::Timer ; -<<<<<<< HEAD:lib/Stem/Event.pm - -======= ->>>>>>> master:lib/Stem/Event.pm our @ISA = qw( Stem::Event ) ; =head2 Stem::Event::Timer::new @@ -669,10 +649,6 @@ sub timer_triggered { # these override Stem::Event's methods and then call those via SUPER:: package Stem::Event::IO ; -<<<<<<< HEAD:lib/Stem/Event.pm - -======= ->>>>>>> master:lib/Stem/Event.pm our @ISA = qw( Stem::Event ) ; sub init_io_timeout { @@ -747,12 +723,6 @@ sub timed_out { package Stem::Event::Read ; our @ISA = qw( Stem::Event::IO ) ; -print "B @ISA\n" ; - -<<<<<<< HEAD:lib/Stem/Event.pm -our @ISA = qw( Stem::Event::IO ) ; -======= ->>>>>>> master:lib/Stem/Event.pm =head2 Stem::Event::Read::new @@ -830,7 +800,6 @@ HELP sub new { my( $class ) = shift ; -print "@ISA\n" ; my $self = Stem::Class::parse_args( $attr_spec_read, @_ ) ; return $self unless ref $self ; @@ -852,10 +821,6 @@ print "@ISA\n" ; ############################################################################ package Stem::Event::Write ; -<<<<<<< HEAD:lib/Stem/Event.pm - -======= ->>>>>>> master:lib/Stem/Event.pm our @ISA = qw( Stem::Event::IO ) ; =head2 Stem::Event::Write::new diff --git a/lib/Stem/Event/Queue.pm b/lib/Stem/Event/Queue.pm index c473237..1354ca8 100644 --- a/lib/Stem/Event/Queue.pm +++ b/lib/Stem/Event/Queue.pm @@ -49,12 +49,7 @@ use warnings ; use Socket; use IO::Handle ; -<<<<<<< HEAD:lib/Stem/Event/Queue.pm my( $self, $queue_read, $queue_write, $queue_read_event, $queue_has_event ) ; -======= -use base 'Exporter' ; -our @EXPORT = qw( mark_not_empty ) ; ->>>>>>> master:lib/Stem/Event/Queue.pm sub _init_event_queue { diff --git a/lib/Stem/Event/Signal.pm b/lib/Stem/Event/Signal.pm index 6523103..7d8b41f 100644 --- a/lib/Stem/Event/Signal.pm +++ b/lib/Stem/Event/Signal.pm @@ -32,14 +32,7 @@ sub _build { $SIG{ $signal } = $cached_handlers{$signal} ||= sub { -<<<<<<< HEAD:lib/Stem/Event/Signal.pm - Stem::Event::Queue::queue_has_event() ; - -#print "HIT $signal\n"; -======= -print "HIT $signal\n"; - Stem::Event::Queue::mark_not_empty() ; ->>>>>>> master:lib/Stem/Event/Signal.pm + Stem::Event::Queue::queue_has_event() ; push @signal_queue, $signal } ; diff --git a/t/event/event_test.pl b/t/event/event_test.pl index 1615ff8..a1d18c9 100644 --- a/t/event/event_test.pl +++ b/t/event/event_test.pl @@ -62,13 +62,7 @@ sub test_plain_events { sub triggered { my( $self ) = @_ ; - -<<<<<<< HEAD:t/event/event_test.pl ok( 1, 'plain - event triggered' ) ; -======= - ok( 1, 'plain event triggered' ) ; - Stem::Event::stop_loop() ; ->>>>>>> master:t/event/event_test.pl } sub test_signal_events { @@ -80,22 +74,6 @@ sub test_signal_events { return ; } - my $event2 = Stem::Event::Timer->new( - 'object' => $self, - 'method' => 'send_int_signal', - 'delay' => 3, - ) ; - - ok( ref $event2, 'signal delay timer created' ) ; - - Stem::Event::start_loop() ; - - ok( 1, 'signal - event loop exit' ) ; - } -} - -sub send_int_signal { - my $event = Stem::Event::Signal->new( 'object' => $self, 'signal' => 'INT', @@ -103,12 +81,14 @@ sub send_int_signal { ok( ref $event, 'signal - event created' ) ; - $self->{'sig_event'} = $event ; + kill 'INT', $$ ; + $self->{'sig_event'} = $event ; -print "kill INT\n" ; + Stem::Event::start_loop() ; - kill 'INT', $$ ; + ok( 1, 'signal - event loop exit' ) ; + } } # callback method for signal @@ -120,6 +100,7 @@ sub sig_int_handler { ok( 1, 'signal - event triggered' ) ; $self->{'sig_event'}->cancel() ; + Stem::Event::stop_loop() ; } @@ -158,13 +139,7 @@ sub hard_timeout { my( $self ) = @_ ; -<<<<<<< HEAD:t/event/event_test.pl ok( 1, 'hard timer - event triggered' ) ; -======= -send_int_signal() ; - - ok( 1, 'hard timer event triggered' ) ; ->>>>>>> master:t/event/event_test.pl if ( --$self->{'hard_timer_count'} > 0 ) {