diff options
author | James E Keenan <jkeenan@cpan.org> | 2021-11-02 23:13:39 +0000 |
---|---|---|
committer | Vincent Pit <vpit@cpan.org> | 2021-12-20 19:14:14 +0100 |
commit | 0f9ea972f35aa9749419b792f2a673288d9a63ca (patch) | |
tree | 6050da2c9055498ac18ed47a1419f34325919297 | |
parent | b9276d0a822f0597b3a4514eda3095c41596e219 (diff) |
Make the expected() utility more closely match context_info()
context_info() returns $warnings::Bits{all} when the warnings for
a context is pWARN_ALL, while caller() returns WARN_ALLstring.
The test tried to avoid loading any modules that registered
warning categories to avoid this making a difference, but
DynaLoader is needed to load Scope::Upper, and DynaLoader uses
vars.pm which registers a warnings category.
This wasn't a problem when the default warning mask wasn't used up to a
byte boundary, but adding the experimental category in Perl 5 commit
3b54923c did align the warning mask on a byte boundary, leading to this
test failing.
Specifically, handle case where warnings mask contains only "\x55"
bytes. Return $warnings::Bits{all} in that case. As suggested by Tony
Cook in: https://rt.cpan.org/Ticket/Display.html?id=139823
BBC ticket: https://github.com/Perl/perl5/issues/19212
Most of commit message suggested by Tony Cook in:
https://github.com/jkeenan/p5-Scope-Upper/pull/1#issuecomment-968375955
-rw-r--r-- | t/07-context_info.t | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/t/07-context_info.t b/t/07-context_info.t index 5dbfa45..657285f 100644 --- a/t/07-context_info.t +++ b/t/07-context_info.t @@ -51,6 +51,9 @@ sub expected { $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, @@ -156,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"; } } |