5 unless ($Config{useithreads} && eval { require threads } ) {
6 plan skip_all => "your perl does not support ithreads";
12 my $one = quote_sub my $one_code = q{
13 BEGIN { $::EVALED{'one'} = 1 }
17 my $two = quote_sub q{
18 BEGIN { $::EVALED{'two'} = 1 }
20 } => { '$x' => \do { my $x = 0 } };
22 ok(threads->create(sub {
23 my $quoted = quoted_from_sub($one);
24 $quoted && $quoted->[1] eq $one_code;
25 })->join, 'able to retrieve quoted sub in thread');
27 my $u_one = unquote_sub $one;
29 is(threads->create(sub { $one->() })->join, 42, 'One (quoted version)');
31 is(threads->create(sub { $u_one->() })->join, 42, 'One (unquoted version)');
33 my $r = threads->create(sub {
36 push @r, unquote_sub($two)->();
41 is($r->[0], 3, 'Two in thread (quoted version)');
42 is($r->[1], 4, 'Two in thread (unquoted version)');
43 is($r->[2], 5, 'Two in thread (quoted version again)');