4 # avoiding this prologue would be nice, but it seems to be unavoidable,
5 # see "It is also important to note ..." in perldoc threads
9 if ($Config{useithreads} && $] > 5.008007) {
21 or plan skip_all => "can't test Imager's threads support with no threads";
23 or plan skip_all => "require a perl with CLONE_SKIP to test Imager's threads support";
25 or plan skip_all => "couldn't load threads";
27 $INC{"Devel/Cover.pm"}
28 and plan skip_all => "threads and Devel::Cover don't get along";
32 # test that the error contexts are separate under threads
36 Imager->open_log(log => "testout/t081error.log");
38 Imager::i_clear_error();
39 Imager::i_push_error(0, "main thread a");
43 my $t1 = threads->create
47 Imager::i_push_error(0, "$id: child thread a");
49 Imager::i_push_error(1, "$id: child thread b");
51 is_deeply([ Imager::i_errors() ],
53 [ "$id: child thread b", 1 ],
54 [ "$id: child thread a", 0 ],
55 ], "$id: check errors in child");
60 push @threads, [ $tid, $t1 ];
63 Imager::i_push_error(1, "main thread b");
65 for my $thread (@threads) {
66 my ($id, $t1) = @$thread;
67 ok($t1->join, "join child $id");
70 Imager::i_push_error(2, "main thread c");
72 is_deeply([ Imager::i_errors() ],
74 [ "main thread c", 2 ],
75 [ "main thread b", 1 ],
76 [ "main thread a", 0 ],
77 ], "check errors in parent");