Skip to content

Commit 4f16878

Browse files
committed
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.
1 parent eabfb4c commit 4f16878

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

t/re/reg_mesg.t

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,9 @@ for my $strict ("", "no warnings 'experimental::re_strict'; use re 'strict';")
931931
diag("GOT\n'$got[$i]'\nEXPECT\n'$expect[$i]'");
932932
}
933933
else {
934-
ok (0 == capture_warnings(sub {
934+
# Turning off this type of warning should make the
935+
# count go down by at least 1.
936+
ok ($count - 1 >= capture_warnings(sub {
935937
$_ = "x";
936938
eval "$strict no warnings '$warning_type'; $regex;" }
937939
),
@@ -941,11 +943,20 @@ for my $strict ("", "no warnings 'experimental::re_strict'; use re 'strict';")
941943
# correct. This test relies on the fact that we
942944
# are outside the scope of any ‘use warnings’.
943945
local $^W;
944-
my @warns = capture_warnings(sub { $_ = "x";
945-
eval "$strict $regex" });
946+
my $turn_off_sets =
947+
($ref == \@experimental_regex_sets)
948+
? ""
949+
: "no warnings 'experimental::regex_sets';";
950+
my @warns = capture_warnings(sub {
951+
$_ = "x";
952+
eval "$strict $turn_off_sets $regex"
953+
});
946954
# Warning should be on as well if is testing
947955
# '(?[...])' which turns on strict
948-
if ($this_default_on || grep { $_ =~ /\Q(?[/ } @expect ) {
956+
if ( $this_default_on
957+
|| ( grep { $_ =~ /\Q(?[/ } @expect
958+
and $ref != \@warning_tests))
959+
{
949960
ok @warns > 0, "... and the warning is on by default";
950961
}
951962
elsif (! (ok @warns == 0,

0 commit comments

Comments
 (0)