summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2022-03-06 11:42:48 -0700
committerKarl Williamson <khw@cpan.org>2022-03-06 13:59:09 -0700
commit4f1687891150ddeda14ad7b0716032145bc69801 (patch)
tree45dfc3025f133cdc8d7e4c7399cdde172c8f7a3d
parenteabfb4c695fff3ad62c2ac63f7f497b849a5e987 (diff)
downloadperl-4f1687891150ddeda14ad7b0716032145bc69801.tar.gz
reg_mesg.t: Wasn't testing what it purported to be
The experimental regex sets warnings messages being output were getting in the way, and causing tests to pass for the wrong reasons.
-rw-r--r--t/re/reg_mesg.t19
1 files changed, 15 insertions, 4 deletions
diff --git a/t/re/reg_mesg.t b/t/re/reg_mesg.t
index 6b1b79b2a9..e958614ec2 100644
--- a/t/re/reg_mesg.t
+++ b/t/re/reg_mesg.t
@@ -931,7 +931,9 @@ for my $strict ("", "no warnings 'experimental::re_strict'; use re 'strict';")
diag("GOT\n'$got[$i]'\nEXPECT\n'$expect[$i]'");
}
else {
- ok (0 == capture_warnings(sub {
+ # Turning off this type of warning should make the
+ # count go down by at least 1.
+ ok ($count - 1 >= capture_warnings(sub {
$_ = "x";
eval "$strict no warnings '$warning_type'; $regex;" }
),
@@ -941,11 +943,20 @@ for my $strict ("", "no warnings 'experimental::re_strict'; use re 'strict';")
# correct. This test relies on the fact that we
# are outside the scope of any ‘use warnings’.
local $^W;
- my @warns = capture_warnings(sub { $_ = "x";
- eval "$strict $regex" });
+ my $turn_off_sets =
+ ($ref == \@experimental_regex_sets)
+ ? ""
+ : "no warnings 'experimental::regex_sets';";
+ my @warns = capture_warnings(sub {
+ $_ = "x";
+ eval "$strict $turn_off_sets $regex"
+ });
# Warning should be on as well if is testing
# '(?[...])' which turns on strict
- if ($this_default_on || grep { $_ =~ /\Q(?[/ } @expect ) {
+ if ( $this_default_on
+ || ( grep { $_ =~ /\Q(?[/ } @expect
+ and $ref != \@warning_tests))
+ {
ok @warns > 0, "... and the warning is on by default";
}
elsif (! (ok @warns == 0,