Skip to content

Commit

Permalink
t/loc_tools.pl: Print better failing test numbers
Browse files Browse the repository at this point in the history
This test module is 'required' from other perl test files.  If it
encounters an error, it doesn't know how to report it.  What it does is
call fail() if available, and a home-grown one otherwise.  Prior to this
commit the home-grown version just made all tests number 0.  This commit
changes that to make them sequentially numbered from a very high
starting one, so as not to interfere with the outer calls.
  • Loading branch information
khwilliamson committed Apr 29, 2021
1 parent 3bdcf83 commit bce5cba
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions t/loc_tools.pl
Expand Up @@ -83,14 +83,17 @@ ($)
}
}

# Larger than any real test
my $my_count = 1_000_000;

sub _my_fail($) {
my $message = shift;
if (defined &main::fail) {
fail($message);
}
else {
local($\, $", $,) = (undef, ' ', '');
print "not ok 0 $message\n";
print "not ok " . $my_count++ . $message . "\n";
}
}

Expand Down Expand Up @@ -538,12 +541,12 @@ ($)

my $save_locale = setlocale(&POSIX::LC_CTYPE());
if (! $save_locale) {
ok(0, "Verify could save previous locale");
_my_fail("Verify could save previous locale");
return 0;
}

if (! setlocale(&POSIX::LC_CTYPE(), $locale)) {
ok(0, "Verify could setlocale to $locale");
_my_fail("Verify could setlocale to $locale");
return 0;
}

Expand All @@ -556,7 +559,7 @@ ($)
# go through testing all the locales on the platform.
if (CORE::fc(chr utf8::unicode_to_native(0xdf)) ne "ss") {
if ($locale =~ /UTF-?8/i) {
ok (0, "Verify $locale with UTF-8 in name is a UTF-8 locale");
_my_fail("Verify $locale with UTF-8 in name is a UTF-8 locale");
}
}
else {
Expand Down

0 comments on commit bce5cba

Please sign in to comment.