]> git.vpit.fr Git - perl/modules/autovivification.git/blobdiff - t/40-scope.t
Remove trailing whitespace
[perl/modules/autovivification.git] / t / 40-scope.t
index 857a7809ce1bf7480ecd627f62624e4a94476e72..6b8361a33114e07d7f11717ef8efc6cd47981ab7 100644 (file)
@@ -1,9 +1,9 @@
-#!perl -T
+#!perl
 
 use strict;
 use warnings;
 
-use Test::More tests => 8;
+use Test::More tests => 12;
 
 use lib 't/lib';
 
@@ -12,7 +12,7 @@ use lib 't/lib';
  my $x;
  my $res = eval {
   local $SIG{__WARN__} = sub { push @w, join '', 'warn:', @_ };
-  no autovivification qw/warn fetch/;
+  no autovivification qw<warn fetch>;
   $x->{a};
  };
  is   @w,    1,     'warned only once';
@@ -34,10 +34,38 @@ our $blurp;
 
 {
  local $blurp;
- eval 'no autovivification; use autovivification::TestRequired2; $blurp->{a}'; 
+ eval 'no autovivification; use autovivification::TestRequired2; $blurp->{a}';
  is        $@,     '',      'second require test doesn\'t croak prematurely';
  my $expect;
  $expect = { r1_main => { }, r1_eval => { } };
- $expect->{r2_eval} = { } if $] <  5.009005;
+ $expect->{r2_eval} = { } if "$]" <  5.009005;
  is_deeply $blurp, $expect, 'second require test didn\'t vivify';
 }
+
+# This test may not fail for the old version when ran in taint mode
+{
+ my $err = eval <<' SNIP';
+  use autovivification::TestRequired4::a0;
+  autovivification::TestRequired4::a0::error();
+ SNIP
+ is $err, '', 'RT #50570';
+}
+
+# This test must be in the topmost scope
+BEGIN { eval 'use autovivification::TestRequired5::a0' }
+my $err = autovivification::TestRequired5::a0::error();
+is $err, '', 'identifying requires by their eval context pointer is not enough';
+
+{
+ local $blurp;
+
+ no autovivification;
+ use autovivification::TestRequired6;
+
+ autovivification::TestRequired6::bar();
+ is_deeply $blurp, { }, 'vivified without eval';
+
+ $blurp = undef;
+ autovivification::TestRequired6::baz();
+ is_deeply $blurp, { }, 'vivified with eval';
+}