| 1 | #!/usr/bin/perl -w | ||
| 2 | # vim: ts=2 sw=2 expandtab | ||
| 3 | |||
| 4 | # Tests alarms. | ||
| 5 | |||
| 6 | use strict; | ||
| 7 | |||
| 8 | use lib qw(./mylib ../mylib); | ||
| 9 | |||
| 10 | use Test::More tests => 37; | ||
| 11 | |||
| 12 | sub POE::Kernel::ASSERT_DEFAULT () { 1 } | ||
| 13 | |||
| 14 | BEGIN { | ||
| 15 | package | ||
| 16 | POE::Kernel; | ||
| 17 | use constant TRACE_DEFAULT => exists($INC{'Devel/Cover.pm'}); | ||
| 18 | } | ||
| 19 | |||
| 20 | use constant WAIT => 0.5; | ||
| 21 | |||
| 22 | BEGIN { use_ok("POE") } | ||
| 23 | |||
| 24 | # Test the ID-based alarm API. Start several test paths. Each path | ||
| 25 | # exercises | ||
| 26 | |||
| 27 | # We need this because queue_peek_alarms was deprecated | ||
| 28 | BEGIN { | ||
| 29 | package # split to avoid CPAN indexer | ||
| 30 | POE::Kernel; | ||
| 31 | |||
| 32 | sub queue_peek_alarms { | ||
| 33 | my $self = shift; | ||
| 34 | my $session = $self->get_active_session; | ||
| 35 | |||
| 36 | my $alarm_count = $self->_data_ev_get_count_to($session); | ||
| 37 | |||
| 38 | my $my_alarm = sub { | ||
| 39 | return 0 unless $_[0]->[EV_TYPE] & ET_ALARM; | ||
| 40 | return 0 unless $_[0]->[EV_SESSION] == $session; | ||
| 41 | return 1; | ||
| 42 | }; | ||
| 43 | |||
| 44 | return( map { $_->[ITEM_PAYLOAD]->[EV_NAME] } | ||
| 45 | $self->[KR_QUEUE]->peek_items($my_alarm, $alarm_count) | ||
| 46 | ); | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | sub test_start { | ||
| 51 | my ($kernel, $heap) = @_[KERNEL, HEAP]; | ||
| 52 | |||
| 53 | # Path #1: single alarm; make sure it rings. | ||
| 54 | $heap->{test}->{path_one} = 0; | ||
| 55 | $kernel->alarm( path_one => time() + WAIT, 1.1 ); | ||
| 56 | |||
| 57 | # Path #2: two alarms; make sure only the second one rings. | ||
| 58 | $heap->{test}->{path_two} = 0; | ||
| 59 | $kernel->alarm( path_two => time() + WAIT, 2.1 ); | ||
| 60 | $kernel->alarm( path_two => time() + WAIT, 2.2 ); | ||
| 61 | |||
| 62 | # Path #3: two alarms; make sure they both ring in order. | ||
| 63 | $heap->{test}->{path_three} = 0; | ||
| 64 | $kernel->alarm_add( path_three => time() + WAIT, 3.1 ); | ||
| 65 | $kernel->alarm_add( path_three => time() + WAIT, 3.2 ); | ||
| 66 | |||
| 67 | # Path #4: interleaved alarm and alarm_add; only the last two should | ||
| 68 | # ring, in order. | ||
| 69 | $heap->{test}->{path_four} = 0; | ||
| 70 | $kernel->alarm( path_four => time() + WAIT, 4.1 ); | ||
| 71 | $kernel->alarm_add( path_four => time() + WAIT, 4.2 ); | ||
| 72 | $kernel->alarm( path_four => time() + WAIT, 4.3 ); | ||
| 73 | $kernel->alarm_add( path_four => time() + WAIT, 4.4 ); | ||
| 74 | |||
| 75 | # Path #5: an alarm that is squelched; nothing should ring. | ||
| 76 | $heap->{test}->{path_five} = 1; | ||
| 77 | $kernel->alarm( path_five => time() + WAIT, 5.1 ); | ||
| 78 | $kernel->alarm( 'path_five' ); | ||
| 79 | |||
| 80 | # Path #6: single delay; make sure it rings. | ||
| 81 | $heap->{test}->{path_six} = 0; | ||
| 82 | $kernel->delay( path_six => WAIT, 6.1 ); | ||
| 83 | |||
| 84 | # Path #7: two delays; make sure only the second one rings. | ||
| 85 | $heap->{test}->{path_seven} = 0; | ||
| 86 | $kernel->delay( path_seven => WAIT, 7.1 ); | ||
| 87 | $kernel->delay( path_seven => WAIT, 7.2 ); | ||
| 88 | |||
| 89 | # Path #8: two delays; make sure they both ring in order. | ||
| 90 | $heap->{test}->{path_eight} = 0; | ||
| 91 | $kernel->delay_add( path_eight => WAIT, 8.1 ); | ||
| 92 | $kernel->delay_add( path_eight => WAIT, 8.2 ); | ||
| 93 | |||
| 94 | # Path #9: interleaved delay and delay_add; only the last two should | ||
| 95 | # ring, in order. | ||
| 96 | $heap->{test}->{path_nine} = 0; | ||
| 97 | $kernel->alarm( path_nine => WAIT, 9.1 ); | ||
| 98 | $kernel->alarm_add( path_nine => WAIT, 9.2 ); | ||
| 99 | $kernel->alarm( path_nine => WAIT, 9.3 ); | ||
| 100 | $kernel->alarm_add( path_nine => WAIT, 9.4 ); | ||
| 101 | |||
| 102 | # Path #10: a delay that is squelched; nothing should ring. | ||
| 103 | $heap->{test}->{path_ten} = 1; | ||
| 104 | $kernel->delay( path_ten => WAIT, 10.1 ); | ||
| 105 | $kernel->alarm( 'path_ten' ); | ||
| 106 | |||
| 107 | # Path #11: ensure alarms are enqueued in time order. | ||
| 108 | |||
| 109 | # To test duplicates on a small queue. | ||
| 110 | my $id_25_3 = $kernel->alarm_set( path_eleven_025_3 => 25 ); | ||
| 111 | my $id_25_2 = $kernel->alarm_set( path_eleven_025_2 => 25 ); | ||
| 112 | my $id_25_1 = $kernel->alarm_set( path_eleven_025_1 => 25 ); | ||
| 113 | |||
| 114 | # To test micro-updates on a small queue. | ||
| 115 | $kernel->alarm_adjust( $id_25_1 => -0.01 ); # negative | ||
| 116 | $kernel->alarm_adjust( $id_25_3 => 0.01 ); # positive | ||
| 117 | |||
| 118 | # Fill the alarm queue to engage the "big queue" binary insert. | ||
| 119 | my @eleven_fill; | ||
| 120 | for (my $count=0; $count<600; $count++) { | ||
| 121 | my $time = int(rand(300)); | ||
| 122 | redo unless $time; # Event doesn't like setting alarms for 0 time. | ||
| 123 | push @eleven_fill, $time; | ||
| 124 | $kernel->alarm( "path_eleven_fill_$count", $eleven_fill[-1] ); | ||
| 125 | } | ||
| 126 | |||
| 127 | # Now to really test the insertion code. | ||
| 128 | $kernel->alarm( path_eleven_100 => 100 ); | ||
| 129 | $kernel->alarm( path_eleven_200 => 200 ); | ||
| 130 | $kernel->alarm( path_eleven_300 => 300 ); | ||
| 131 | |||
| 132 | $kernel->alarm( path_eleven_050 => 50 ); | ||
| 133 | $kernel->alarm( path_eleven_150 => 150 ); | ||
| 134 | $kernel->alarm( path_eleven_250 => 250 ); | ||
| 135 | $kernel->alarm( path_eleven_350 => 350 ); | ||
| 136 | |||
| 137 | $kernel->alarm( path_eleven_075 => 75 ); | ||
| 138 | $kernel->alarm( path_eleven_175 => 175 ); | ||
| 139 | $kernel->alarm( path_eleven_275 => 275 ); | ||
| 140 | |||
| 141 | $kernel->alarm( path_eleven_325 => 325 ); | ||
| 142 | $kernel->alarm( path_eleven_225 => 225 ); | ||
| 143 | $kernel->alarm( path_eleven_125 => 125 ); | ||
| 144 | |||
| 145 | # To test duplicates. | ||
| 146 | my $id_206 = $kernel->alarm_set( path_eleven_206 => 205 ); | ||
| 147 | my $id_205 = $kernel->alarm_set( path_eleven_205 => 205 ); | ||
| 148 | my $id_204 = $kernel->alarm_set( path_eleven_204 => 205 ); | ||
| 149 | |||
| 150 | # To test micro-updates on a big queue. | ||
| 151 | $kernel->alarm_adjust( $id_204 => -0.01 ); # negative | ||
| 152 | $kernel->alarm_adjust( $id_206 => 0.01 ); # positive | ||
| 153 | |||
| 154 | # Now clear the filler states. | ||
| 155 | for (my $count=0; $count<600; $count++) { | ||
| 156 | if ($count & 1) { | ||
| 157 | $kernel->alarm( "path_eleven_fill_$count" ); | ||
| 158 | } | ||
| 159 | else { | ||
| 160 | $kernel->alarm( "path_eleven_fill_$count" ); | ||
| 161 | } | ||
| 162 | } | ||
| 163 | |||
| 164 | # Now acquire the test alarms. | ||
| 165 | my @alarms_eleven = grep /^path_eleven_[0-9_]+$/, | ||
| 166 | $kernel->queue_peek_alarms(); | ||
| 167 | $heap->{alarms_eleven} = \@alarms_eleven; | ||
| 168 | |||
| 169 | # Now clear the test alarms since we're just testing the queue | ||
| 170 | # order. | ||
| 171 | foreach (@alarms_eleven) { | ||
| 172 | $kernel->alarm( $_ ); | ||
| 173 | } | ||
| 174 | |||
| 175 | # All the paths are occurring in parallel so they should complete in | ||
| 176 | # about 2 seconds. Start a timer to make sure. | ||
| 177 | $heap->{start_time} = time(); | ||
| 178 | } | ||
| 179 | |||
| 180 | sub test_stop { | ||
| 181 | my $heap = $_[HEAP]; | ||
| 182 | |||
| 183 | is($heap->{test}->{path_one}, 1, "single alarm rang ok"); | ||
| 184 | is($heap->{test}->{path_two}, 1, "second alarm superseded first"); | ||
| 185 | is($heap->{test}->{path_three}, 11, "two alarms rang in proper order"); | ||
| 186 | is($heap->{test}->{path_four}, 11, "mixed alarm APIs rang properly"); | ||
| 187 | is($heap->{test}->{path_five}, 1, "stopped alarm should not ring"); | ||
| 188 | is($heap->{test}->{path_six}, 1, "single delay rang ok"); | ||
| 189 | is($heap->{test}->{path_seven}, 1, "second delay superseded first"); | ||
| 190 | is($heap->{test}->{path_eight}, 11, "two delays rang in proper order"); | ||
| 191 | is($heap->{test}->{path_nine}, 11, "mixed delay APIs rang properly"); | ||
| 192 | is($heap->{test}->{path_ten}, 1, "stopped delay should not ring"); | ||
| 193 | |||
| 194 | # Here's where we check the overall run time. Increased to 15s for | ||
| 195 | # extremely slow, overtaxed machines like my XP system running under | ||
| 196 | # Virtual PC. | ||
| 197 | cmp_ok(time() - $heap->{start_time}, '<=', 15, "tests ran reasonably fast"); | ||
| 198 | |||
| 199 | # And test alarm order. | ||
| 200 | is_deeply( | ||
| 201 | $heap->{alarms_eleven}, | ||
| 202 | [ | ||
| 203 | qw( | ||
| 204 | path_eleven_025_1 | ||
| 205 | path_eleven_025_2 | ||
| 206 | path_eleven_025_3 | ||
| 207 | path_eleven_050 | ||
| 208 | path_eleven_075 | ||
| 209 | path_eleven_100 | ||
| 210 | path_eleven_125 | ||
| 211 | path_eleven_150 | ||
| 212 | path_eleven_175 | ||
| 213 | path_eleven_200 | ||
| 214 | path_eleven_204 | ||
| 215 | path_eleven_205 | ||
| 216 | path_eleven_206 | ||
| 217 | path_eleven_225 | ||
| 218 | path_eleven_250 | ||
| 219 | path_eleven_275 | ||
| 220 | path_eleven_300 | ||
| 221 | path_eleven_325 | ||
| 222 | path_eleven_350 | ||
| 223 | ) | ||
| 224 | ], | ||
| 225 | "alarms rang in order" | ||
| 226 | ); | ||
| 227 | } | ||
| 228 | |||
| 229 | sub test_path_one { | ||
| 230 | my ($heap, $test_id) = @_[HEAP, ARG0]; | ||
| 231 | |||
| 232 | if ($test_id == 1.1) { | ||
| 233 | $heap->{test}->{path_one} += 1; | ||
| 234 | } | ||
| 235 | else { | ||
| 236 | $heap->{test}->{path_one} += 1000; | ||
| 237 | } | ||
| 238 | } | ||
| 239 | |||
| 240 | sub test_path_two { | ||
| 241 | my ($heap, $test_id) = @_[HEAP, ARG0]; | ||
| 242 | |||
| 243 | if ($test_id == 2.2) { | ||
| 244 | $heap->{test}->{path_two} += 1; | ||
| 245 | } | ||
| 246 | else { | ||
| 247 | $heap->{test}->{path_two} += 1000; | ||
| 248 | } | ||
| 249 | } | ||
| 250 | |||
| 251 | sub test_path_three { | ||
| 252 | my ($heap, $test_id) = @_[HEAP, ARG0]; | ||
| 253 | |||
| 254 | if (($test_id == 3.1) and ($heap->{test}->{path_three} == 0)) { | ||
| 255 | $heap->{test}->{path_three} += 1; | ||
| 256 | } | ||
| 257 | elsif (($test_id == 3.2) and ($heap->{test}->{path_three} == 1)) { | ||
| 258 | $heap->{test}->{path_three} += 10; | ||
| 259 | } | ||
| 260 | else { | ||
| 261 | $heap->{test}->{path_three} += 1000; | ||
| 262 | } | ||
| 263 | } | ||
| 264 | |||
| 265 | sub test_path_four { | ||
| 266 | my ($heap, $test_id) = @_[HEAP, ARG0]; | ||
| 267 | |||
| 268 | if (($test_id == 4.3) and ($heap->{test}->{path_four} == 0)) { | ||
| 269 | $heap->{test}->{path_four} += 1; | ||
| 270 | } | ||
| 271 | elsif (($test_id == 4.4) and ($heap->{test}->{path_four} == 1)) { | ||
| 272 | $heap->{test}->{path_four} += 10; | ||
| 273 | } | ||
| 274 | else { | ||
| 275 | $heap->{test}->{path_four} += 1000; | ||
| 276 | } | ||
| 277 | } | ||
| 278 | |||
| 279 | sub test_path_five { | ||
| 280 | my ($heap, $test_id) = @_[HEAP, ARG0]; | ||
| 281 | |||
| 282 | $heap->{test}->{path_five} += 1; | ||
| 283 | } | ||
| 284 | |||
| 285 | sub test_path_six { | ||
| 286 | my ($heap, $test_id) = @_[HEAP, ARG0]; | ||
| 287 | |||
| 288 | if ($test_id == 6.1) { | ||
| 289 | $heap->{test}->{path_six} += 1; | ||
| 290 | } | ||
| 291 | else { | ||
| 292 | $heap->{test}->{path_six} += 1000; | ||
| 293 | } | ||
| 294 | } | ||
| 295 | |||
| 296 | sub test_path_seven { | ||
| 297 | my ($heap, $test_id) = @_[HEAP, ARG0]; | ||
| 298 | |||
| 299 | if ($test_id == 7.2) { | ||
| 300 | $heap->{test}->{path_seven} += 1; | ||
| 301 | } | ||
| 302 | else { | ||
| 303 | $heap->{test}->{path_seven} += 1000; | ||
| 304 | } | ||
| 305 | } | ||
| 306 | |||
| 307 | sub test_path_eight { | ||
| 308 | my ($heap, $test_id) = @_[HEAP, ARG0]; | ||
| 309 | |||
| 310 | if (($test_id == 8.1) and ($heap->{test}->{path_eight} == 0)) { | ||
| 311 | $heap->{test}->{path_eight} += 1; | ||
| 312 | } | ||
| 313 | elsif (($test_id == 8.2) and ($heap->{test}->{path_eight} == 1)) { | ||
| 314 | $heap->{test}->{path_eight} += 10; | ||
| 315 | } | ||
| 316 | else { | ||
| 317 | $heap->{test}->{path_eight} += 1000; | ||
| 318 | } | ||
| 319 | } | ||
| 320 | |||
| 321 | sub test_path_nine { | ||
| 322 | my ($heap, $test_id) = @_[HEAP, ARG0]; | ||
| 323 | |||
| 324 | if (($test_id == 9.3) and ($heap->{test}->{path_nine} == 0)) { | ||
| 325 | $heap->{test}->{path_nine} += 1; | ||
| 326 | } | ||
| 327 | elsif (($test_id == 9.4) and ($heap->{test}->{path_nine} == 1)) { | ||
| 328 | $heap->{test}->{path_nine} += 10; | ||
| 329 | } | ||
| 330 | else { | ||
| 331 | $heap->{test}->{path_nine} += 1000; | ||
| 332 | } | ||
| 333 | } | ||
| 334 | |||
| 335 | sub test_path_ten { | ||
| 336 | my ($heap, $test_id) = @_[HEAP, ARG0]; | ||
| 337 | |||
| 338 | $heap->{test}->{path_ten} += 1; | ||
| 339 | } | ||
| 340 | |||
| 341 | ### Spawn a session to test the ID-based alarm API added in June 2001. | ||
| 342 | |||
| 343 | POE::Session->create( | ||
| 344 | inline_states => { | ||
| 345 | _start => sub { | ||
| 346 | my ($kernel, $heap) = @_[KERNEL, HEAP]; | ||
| 347 | |||
| 348 | $heap->{test_13} = $kernel->alarm_set( test_13 => 1 => 13 ); | ||
| 349 | |||
| 350 | my $test_14 = $kernel->alarm_set( test_14 => 1 => 14 ); | ||
| 351 | my @test_array = $kernel->alarm_remove( $test_14 ); | ||
| 352 | is($test_array[0], 'test_14', "alarm 14 remove: name is correct"); | ||
| 353 | is($test_array[1], 1, "alarm 14 remove: time is correct"); | ||
| 354 | is_deeply($test_array[2], [ 14 ], "alarm 14 remove: data is correct"); | ||
| 355 | |||
| 356 | # Have time stand still so we can test against it. | ||
| 357 | # Heisenberg strikes again! | ||
| 358 | my $now = time; | ||
| 359 | |||
| 360 | my $test_15 = $kernel->delay_set( test_15 => WAIT, 15 ); | ||
| 361 | |||
| 362 | my $test_scalar = $kernel->alarm_remove( $test_15 ); | ||
| 363 | is($test_scalar->[0], 'test_15', "alarm 15 remove: name is correct"); | ||
| 364 | ok( | ||
| 365 | ( $test_scalar->[1] <= $now + 3 and | ||
| 366 | $test_scalar->[1] >= $now | ||
| 367 | ), "alarm 15 remove: time is correct" | ||
| 368 | ); | ||
| 369 | is_deeply($test_scalar->[2], [ 15 ], "alarm 15 remove: data is correct"); | ||
| 370 | }, | ||
| 371 | |||
| 372 | # This one is dispatched. | ||
| 373 | test_13 => sub { | ||
| 374 | my $kernel = $_[KERNEL]; | ||
| 375 | |||
| 376 | is($_[ARG0], 13, "alarm 13: received proper data"); | ||
| 377 | |||
| 378 | # Set a couple alarms, then clear them all. | ||
| 379 | $kernel->delay( test_16 => WAIT ); | ||
| 380 | $kernel->delay( test_17 => WAIT ); | ||
| 381 | $kernel->alarm_remove_all(); | ||
| 382 | |||
| 383 | # Test alarm adjusting on little queues. | ||
| 384 | my $alarm_id = $kernel->alarm_set( test_18 => 50 => 18 ); | ||
| 385 | |||
| 386 | # One alarm. | ||
| 387 | my $new_time = $kernel->alarm_adjust( $alarm_id => -1 ); | ||
| 388 | is($new_time, 49, "alarm 18: adjusted backward correctly"); | ||
| 389 | |||
| 390 | $new_time = $kernel->alarm_adjust( $alarm_id => 1 ); | ||
| 391 | is($new_time, 50, "alarm 18: adjusted forward correctly"); | ||
| 392 | |||
| 393 | # Two alarms. | ||
| 394 | $alarm_id = $kernel->alarm_set( test_19 => 52 => 19 ); | ||
| 395 | $new_time = $kernel->alarm_adjust( $alarm_id => -4 ); | ||
| 396 | is($new_time, 48, "alarm 19: adjusted backward correctly"); | ||
| 397 | |||
| 398 | $new_time = $kernel->alarm_adjust( $alarm_id => 4 ); | ||
| 399 | is($new_time, 52, "alarm 19: adjusted forward correctly"); | ||
| 400 | |||
| 401 | # Three alarms. | ||
| 402 | $alarm_id = $kernel->alarm_set( test_20 => 49 => 20 ); | ||
| 403 | $new_time = $kernel->alarm_adjust( $alarm_id => 2 ); | ||
| 404 | is($new_time, 51, "alarm 20: adjusted forward once correctly"); | ||
| 405 | |||
| 406 | $new_time = $kernel->alarm_adjust( $alarm_id => 2 ); | ||
| 407 | is($new_time, 53, "alarm 20: adjusted forward twice correctly"); | ||
| 408 | |||
| 409 | $new_time = $kernel->alarm_adjust( $alarm_id => -2 ); | ||
| 410 | is($new_time, 51, "alarm 20: adjusted backward correctly"); | ||
| 411 | |||
| 412 | # Test alarm adjusting on big queues. | ||
| 413 | my @alarm_filler; | ||
| 414 | for (1..100) { | ||
| 415 | push( @alarm_filler, $kernel->alarm_set( filler => $_) ); | ||
| 416 | } | ||
| 417 | |||
| 418 | # Moving inside the alarm range. | ||
| 419 | $alarm_id = $kernel->alarm_set( test_21 => 50 => 21 ); | ||
| 420 | $new_time = $kernel->alarm_adjust( $alarm_id => -10 ); | ||
| 421 | is($new_time, 40, "alarm 21: adjusted backward correctly"); | ||
| 422 | |||
| 423 | $new_time = $kernel->alarm_adjust( $alarm_id => 20 ); | ||
| 424 | is($new_time, 60, "alarm 21: adjusted forward correctly"); | ||
| 425 | |||
| 426 | # Moving outside (to the beginning) of the alarm range. | ||
| 427 | $new_time = $kernel->alarm_adjust( $alarm_id => -100 ); | ||
| 428 | is($new_time, -40, "alarm 21: adjusted first correctly"); | ||
| 429 | |||
| 430 | # Moving outside (to the end) of the alarm range. | ||
| 431 | $alarm_id = $kernel->alarm_set( test_22 => 50 => 22 ); | ||
| 432 | $new_time = $kernel->alarm_adjust( $alarm_id => 100 ); | ||
| 433 | is($new_time, 150, "alarm 22: adjusted last correctly"); | ||
| 434 | |||
| 435 | # Remove the filler events. | ||
| 436 | foreach (@alarm_filler) { | ||
| 437 | $kernel->alarm_remove( $_ ); | ||
| 438 | } | ||
| 439 | }, | ||
| 440 | |||
| 441 | # These have been removed. They should not be dispatched. | ||
| 442 | test_14 => sub { fail("alarm 14 should have been removed"); }, | ||
| 443 | test_15 => sub { fail("alarm 15 should have been removed"); }, | ||
| 444 | test_16 => sub { fail("alarm 16 should have been removed"); }, | ||
| 445 | test_17 => sub { fail("alarm 17 should have been removed"); }, | ||
| 446 | |||
| 447 | # These should be dispatched in a certain order. | ||
| 448 | _default => sub { | ||
| 449 | my ($kernel, $heap) = @_[KERNEL, HEAP]; | ||
| 450 | |||
| 451 | # Save the test's argument on the heap. Check during _stop. | ||
| 452 | push( @{$heap->{tests}}, $_[ARG1]->[0] ) if $_[ARG0] =~ /test_\d+/; | ||
| 453 | |||
| 454 | # Handle the signal. | ||
| 455 | $kernel->sig_handled(); | ||
| 456 | }, | ||
| 457 | |||
| 458 | _stop => sub { | ||
| 459 | my $heap = $_[HEAP]; | ||
| 460 | |||
| 461 | is(@{$heap->{tests}}, 5, "the right number of alarms were dispatched"); | ||
| 462 | is($heap->{tests}->[0], 21, "alarm 21 was dispatched first"); | ||
| 463 | is($heap->{tests}->[1], 18, "alarm 18 was dispatched second"); | ||
| 464 | is($heap->{tests}->[2], 20, "alarm 20 was dispatched third"); | ||
| 465 | is($heap->{tests}->[3], 19, "alarm 19 was dispatched fourth"); | ||
| 466 | is($heap->{tests}->[4], 22, "alarm 22 was dispatched fifth"); | ||
| 467 | }, | ||
| 468 | } | ||
| 469 | ); | ||
| 470 | |||
| 471 | # Run the old tests here. | ||
| 472 | |||
| 473 | POE::Session->create( | ||
| 474 | inline_states => { | ||
| 475 | _start => \&test_start, | ||
| 476 | _stop => \&test_stop, | ||
| 477 | path_one => \&test_path_one, | ||
| 478 | path_two => \&test_path_two, | ||
| 479 | path_three => \&test_path_three, | ||
| 480 | path_four => \&test_path_four, | ||
| 481 | path_five => \&test_path_five, | ||
| 482 | path_six => \&test_path_six, | ||
| 483 | path_seven => \&test_path_seven, | ||
| 484 | path_eight => \&test_path_eight, | ||
| 485 | path_nine => \&test_path_nine, | ||
| 486 | path_ten => \&test_path_ten, | ||
| 487 | } | ||
| 488 | ); | ||
| 489 | |||
| 490 | # Ye olde main loop and exit. | ||
| 491 | |||
| 492 | POE::Kernel->run(); | ||
| 493 | |||
| 494 | 1; |