]> git.vpit.fr Git - perl/modules/autovivification.git/blob - t/30-scope.t
Initial import
[perl/modules/autovivification.git] / t / 30-scope.t
1 #!perl -T
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 4;
7
8 use lib 't/lib';
9
10 our $blurp;
11
12 {
13  local $blurp;
14  eval 'no autovivification; use autovivification::TestRequired1; $blurp->{x}';
15  is        $@,     '',          'first require test doesn\'t croak prematurely';
16  is_deeply $blurp, { r1_main => { }, r1_eval => { } },
17                                 'first require vivified correctly';
18 }
19
20 {
21  local $blurp;
22  eval 'no autovivification; use autovivification::TestRequired2; $blurp->{a}'; 
23  is        $@,     '',      'second require test doesn\'t croak prematurely';
24  my $expect;
25  $expect = { r1_main => { }, r1_eval => { } };
26  $expect->{r2_eval} = { } if $] <  5.009005;
27  is_deeply $blurp, $expect, 'second require test didn\'t vivify';
28 }
29