Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

t/op/caller.t: One test failing once warnings on by default #339

Open
jkeenan opened this issue Dec 5, 2020 · 0 comments
Open

t/op/caller.t: One test failing once warnings on by default #339

jkeenan opened this issue Dec 5, 2020 · 0 comments
Labels
bug Something isn't working warnings-by-default

Comments

@jkeenan
Copy link
Collaborator

jkeenan commented Dec 5, 2020

In the t-op-caller-bitmask-problem-20201204 branch, which is forked from alpha-dev-03-warnings, I have created a new file, t/op/xcaller.t, which contains a single unit test extracted from t/op/caller.t.

$ cat t/op/xcaller.t 
#!./perl
# Tests for caller()

#use warnings;
BEGIN {
    chdir 't' if -d 't';
    require './test.pl';
    set_up_inc('../lib');
    plan( tests =>  1 ); # some tests are run in a BEGIN block
}

# The bitmask should be assignable to ${^WARNING_BITS} without resulting in
# different warnings settings.
{
 my $bits = sub { (caller 0)[9] }->();
 my $w;
 local $SIG{__WARN__} = sub { $w++ };
 eval '
   use warnings;
   BEGIN { ${^WARNING_BITS} = $bits }
   local $^W = 1;
   () = 1 + undef;
   $^W = 0;
   () = 1 + undef;
 ';
 is $w, 1, 'value from (caller 0)[9] (bitmask) works in ${^WARNING_BITS}';
}

Once warnings are on by default (as is the case in the branches cited), this test fails.

$ ./perl -Ilib t/op/xcaller.t 
1..1
not ok 1 - value from (caller 0)[9] (bitmask) works in ${^WARNING_BITS}
# Failed test 1 - value from (caller 0)[9] (bitmask) works in ${^WARNING_BITS} at t/op/xcaller.t line 26
#      got "2"
# expected "1"

If I were to put this file in a branch in the Perl 5 core distribution -- where warnings are not on by default -- the test would pass.

$ ./perl -Ilib t/op/xcaller.t 
1..1
ok 1 - value from (caller 0)[9] (bitmask) works in ${^WARNING_BITS}

However, if I were to edit the file there (in Perl 5) to activate the use warnings; statement, the test would fail.

 ./perl -Ilib t/op/ycaller.t 
1..1
not ok 1 - value from (caller 0)[9] (bitmask) works in ${^WARNING_BITS}
# Failed test 1 - value from (caller 0)[9] (bitmask) works in ${^WARNING_BITS} at t/op/ycaller.t line 26
#      got "2"
# expected "1"

So it is clear that turning on warnings by default, causes problems for this test.

@atoomic, can you take a look?

Thank you very much.
Jim Keenan

@jkeenan jkeenan added bug Something isn't working warnings-by-default labels Dec 5, 2020
jkeenan added a commit to jkeenan/perl that referenced this issue Dec 5, 2020
This file has mostly been adapted to work with warnings on by default.
However there is one unit test that now fails.  See:
atoomic#339
jkeenan added a commit that referenced this issue Dec 8, 2020
This file has mostly been adapted to work with warnings on by default.
However there is one unit test that now fails.  See:
#339
jkeenan added a commit that referenced this issue Dec 8, 2020
This file has mostly been adapted to work with warnings on by default.
However there is one unit test that now fails.  See:
#339
jkeenan added a commit that referenced this issue Dec 9, 2020
This file has mostly been adapted to work with warnings on by default.
However there is one unit test that now fails.  See:
#339
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working warnings-by-default
Projects
None yet
Development

No branches or pull requests

1 participant