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();
39 plan tests => $threads * $runs * 3 * (1 + 2);
40 defined and diag "Using threads $_" for $threads::VERSION;
47 my $tid = threads->tid();
49 for my $run (1 .. $runs) {
53 is $x, undef, "fetch does not autovivify at thread $tid run $run";
57 my $y = exists $x->{foo};
58 is $x, undef, "exists does not autovivify at thread $tid run $run";
62 my $y = delete $x->{foo};
63 is $x, undef, "delete does not autovivify at thread $tid run $run";
68 skip 'Hints aren\'t propagated into eval STRING below perl 5.10' => 3 * 2
72 eval 'my $y = $x->{foo}';
73 is $@, '', "fetch in eval does not croak at thread $tid run $run";
74 is $x, undef, "fetch in eval does not autovivify at thread $tid run $run";
78 eval 'my $y = exists $x->{foo}';
79 is $@, '', "exists in eval does not croak at thread $tid run $run";
80 is $x, undef, "exists in eval does not autovivify at thread $tid run $run";
84 eval 'my $y = delete $x->{foo}';
85 is $@, '', "delete in eval does not croak at thread $tid run $run";
86 is $x, undef, "delete in eval does not autovivify at thread $tid run $run";
93 my @t = map threads->create(\&try), 1 .. $threads;