6 use Scope::Upper qw/localize_elem/;
8 use Test::More tests => 6;
14 local $SIG{__WARN__} = sub { };
17 localize_elem '%SIG', '__WARN__' => sub { $x = join '', @_ }, 1;
18 is $x, undef, 'localize_elem $SIG{__WARN__} [not yet]';
21 is $x, "1\n", 'localize_elem $SIG{__WARN__} [ok]';
24 is $x, "1\n", 'localize_elem $SIG{__WARN__} [done]';
28 my ($val, $in, $desc) = @_;
29 system { $^X } $^X, '-e', "exit(\$ENV{SCOPE_UPPER_TEST} == $val ? 0 : 1)";
31 skip "system() failed: $!" => 1 if $? == -1;
44 local $ENV{SCOPE_UPPER_TEST};
47 localize_elem '%ENV', 'SCOPE_UPPER_TEST' => $time, 1;
48 runperl $time, 0, 'localize_elem $ENV{SCOPE_UPPER_TEST} [not yet]';
50 runperl $time, 1, 'localize_elem $ENV{SCOPE_UPPER_TEST} [ok]';
52 runperl $time, 0, 'localize_elem $ENV{SCOPE_UPPER_TEST} [done]';