9 Test::More::plan(skip_all => $msg);
12 use Config qw/%Config/;
15 my $force = $ENV{PERL_AUTOVIVIFICATION_TEST_THREADS} ? 1 : !1;
16 skipall 'This perl wasn\'t built to support threads'
17 unless $Config{useithreads};
18 skipall 'perl 5.13.4 required to test thread safety'
19 unless $force or $] >= 5.013004;
27 require autovivification;
28 skipall 'This autovivification isn\'t thread safe'
29 unless autovivification::A_THREADSAFE();
30 plan tests => 10 * 2 * 3 * (1 + 2);
31 defined and diag "Using threads $_" for $threads::VERSION;
38 my $tid = threads->tid();
40 for my $run (1 .. 2) {
44 is $x, undef, "fetch does not autovivify at thread $tid run $run";
48 my $y = exists $x->{foo};
49 is $x, undef, "exists does not autovivify at thread $tid run $run";
53 my $y = delete $x->{foo};
54 is $x, undef, "delete does not autovivify at thread $tid run $run";
59 skip 'Hints aren\'t propagated into eval STRING below perl 5.10' => 3 * 2
63 eval 'my $y = $x->{foo}';
64 is $@, '', "fetch in eval does not croak at thread $tid run $run";
65 is $x, undef, "fetch in eval does not autovivify at thread $tid run $run";
69 eval 'my $y = exists $x->{foo}';
70 is $@, '', "exists in eval does not croak at thread $tid run $run";
71 is $x, undef, "exists in eval does not autovivify at thread $tid run $run";
75 eval 'my $y = delete $x->{foo}';
76 is $@, '', "delete in eval does not croak at thread $tid run $run";
77 is $x, undef, "delete in eval does not autovivify at thread $tid run $run";
84 my @t = map threads->create(\&try), 1 .. 10;