6 use Test::More tests => 8;
14 local $SIG{__WARN__} = sub { push @w, join '', 'warn:', @_ };
15 no autovivification qw/warn fetch/;
18 is @w, 1, 'warned only once';
19 like $w[0], qr/^warn:Reference was vivified at \Q$0\E line ${\(__LINE__-3)}/,
20 'warning looks correct';
21 is_deeply $x, undef, 'didn\'t vivified';
22 is $res, undef, 'returned undef';
29 eval 'no autovivification; use autovivification::TestRequired1; $blurp->{x}';
30 is $@, '', 'first require test doesn\'t croak prematurely';
31 is_deeply $blurp, { r1_main => { }, r1_eval => { } },
32 'first require vivified correctly';
37 eval 'no autovivification; use autovivification::TestRequired2; $blurp->{a}';
38 is $@, '', 'second require test doesn\'t croak prematurely';
40 $expect = { r1_main => { }, r1_eval => { } };
41 $expect->{r2_eval} = { } if $] < 5.009005;
42 is_deeply $blurp, $expect, 'second require test didn\'t vivify';