0.006 release
[poe-xs-queue-array.git] / t / 05_pfork.t
CommitLineData
c6c9fd23
TC
1#!perl -w
2use strict;
c6c9fd23
TC
3use POE::XS::Queue::Array;
4use Config;
5
6$^O eq 'MSWin32'
29c3b237 7 or skip_all("You probably have a sane fork(), not testing");
c6c9fd23
TC
8
9$Config{useithreads} && $Config{useithreads} eq 'define'
29c3b237 10 or skip_all("No ithreads to support pseudo-fork");
c6c9fd23 11
29c3b237
TC
12sub nok($$$);
13
14print "1..2\n";
c6c9fd23
TC
15
16{
17 my $q1 = POE::XS::Queue::Array->new;
18 $q1->enqueue(100, 101);
29c3b237
TC
19 my $pid = fork;
20 if (!$pid) {
c6c9fd23 21 # child
29c3b237
TC
22 nok(1, !eval { $q1->isa("POE::XS::Queue::Array") },
23 "queue object should be magically unblessed");
c6c9fd23
TC
24 exit;
25 }
29c3b237
TC
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
32sub 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
44sub skip_all {
45 print "1..0 # $_[0]\n";
46 exit;
c6c9fd23 47}