X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F07-context_info.t;h=657285f7d7f7ac5d717b0e6124635a4acbaf09f3;hb=b8097cede97532068ee636c926a09939965720c0;hp=aab24fbb7a971f0e1f64485be5e6b4ab5cde5f77;hpb=aadd0157199345b7e2570fa1d45d998479691b5e;p=perl%2Fmodules%2FScope-Upper.git diff --git a/t/07-context_info.t b/t/07-context_info.t index aab24fb..657285f 100644 --- a/t/07-context_info.t +++ b/t/07-context_info.t @@ -5,15 +5,19 @@ my $exp0 = ::expected('block', 0, undef); use strict; use warnings; +use Config qw<%Config>; + # We're using Test::Leaner here because Test::More loads overload, which itself # uses warning::register, which may cause the "all warnings on" bitmask to # change ; and that doesn't fit well with how we're testing things. use lib 't/lib'; -use Test::Leaner tests => 19 + 6; +use Test::Leaner tests => 18 + 6; use Scope::Upper qw; +sub HINT_BLOCK_SCOPE () { 0x100 } + sub expected { my ($type, $line, $want) = @_; @@ -40,7 +44,16 @@ sub expected { $want = '' if defined $want and not $want; } - $want = "$]" < 5.015_001 ? '' : undef if $top; + if ($top) { + $want = "$]" < 5.015_001 ? '' : undef; + $hints &= ~HINT_BLOCK_SCOPE if $Config{usesitecustomize}; + $hints |= HINT_BLOCK_SCOPE if "$]" >= 5.019003; + $warnings = sub { use warnings; (caller 0)[9] }->() if "$]" < 5.007 + and not $^W; + } + if (defined $warnings and $warnings =~ m/^\x55*$/) { + $warnings = $warnings::Bits{all}; + } my @exp = ( $pkg, @@ -70,7 +83,6 @@ sub setup () { is_deeply [ context_info ], $exp0, 'main : context_info'; is_deeply [ context_info(HERE) ], $exp0, 'main : context_info HERE'; -is_deeply [ context_info(UP) ], $exp0, 'main : context_info UP'; is_deeply [ context_info(-1) ], $exp0, 'main : context_info -1'; package Scope::Upper::TestPkg::A; BEGIN { ::setup } @@ -147,6 +159,9 @@ sub call { my @got = context_info(CALLER $depth); my @exp = caller $depth; defined and not $_ and $_ = '' for $exp[5]; + if (defined $exp[9] and $exp[9] =~ m/^\x55*$/) { + $exp[9] = $warnings::Bits{all}; + } is_deeply \@got, \@exp, "context_info vs caller $depth"; } }