]> git.imager.perl.org - poe-xs-queue-array.git/blob - t/05_pfork.t
update MANIFEST
[poe-xs-queue-array.git] / t / 05_pfork.t
1 #!perl -w
2 use strict;
3 use POE::XS::Queue::Array;
4 use Config;
5
6 $^O eq 'MSWin32'
7   or skip_all("You probably have a sane fork(), not testing");
8
9 $Config{useithreads} && $Config{useithreads} eq 'define'
10   or skip_all("No ithreads to support pseudo-fork");
11
12 sub nok($$$);
13
14 print "1..2\n";
15
16 {
17   my $q1 = POE::XS::Queue::Array->new;
18   $q1->enqueue(100, 101);
19   my $pid = fork;
20   if (!$pid) {
21     # child
22     nok(1, !eval { $q1->isa("POE::XS::Queue::Array") },
23         "queue object should be magically unblessed");
24     exit;
25   }
26   wait();
27   nok(2, eval {$q1->isa("POE::XS::Queue::Array") },
28       "parent should still have an object");
29 }
30
31 # since we use fork, Test::More can't track test numbers, so we set them manually
32 sub nok ($$$) {
33   my ($num, $ok, $msg) = @_;
34
35   if ($ok) {
36     print "ok $num # $msg\n";
37   }
38   else {
39     print "not ok $num # $msg\n";
40   }
41   $ok;
42 }
43
44 sub skip_all {
45   print "1..0 # $_[0]\n";
46   exit;
47 }