summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2012-01-15 10:40:43 -0700
committerKarl Williamson <public@khwilliamson.com>2012-01-21 10:02:52 -0700
commitc213d471d86c3a5ff292680f385f8c7e9fcd5a95 (patch)
tree415f01c7aa382d6f2ea9d4a6766bbdff84f43ea5
parent7cae3803937000688a3564bfdabfb7a3935a6e86 (diff)
downloadperl-c213d471d86c3a5ff292680f385f8c7e9fcd5a95.tar.gz
locale.t: Start removing hard-coded test numbers
This .t uses it's own TAP output. I presume to avoid any issues with tainting. This commit starts the process of making it easier to add tests by having the ok() routine keep track of test numbers.
-rw-r--r--lib/locale.t17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/locale.t b/lib/locale.t
index 2d2891688a..a5ceeb62b4 100644
--- a/lib/locale.t
+++ b/lib/locale.t
@@ -65,12 +65,14 @@ sub LC_ALL ();
$a = 'abc %';
+my $test_num = 0;
+
sub ok {
- my ($n, $result, $message) = @_;
+ my ($result, $message) = @_;
$message = "" unless defined $message;
print 'not ' unless ($result);
- print "ok $n";
+ print "ok " . ++$test_num;
print " $message";
print "\n";
}
@@ -87,11 +89,11 @@ sub is_tainted { # hello, camel two.
}
sub check_taint ($$) {
- ok $_[0], is_tainted($_[1]), "verify that is tainted";
+ ok is_tainted($_[1]), "verify that is tainted";
}
sub check_taint_not ($$) {
- ok $_[0], (not is_tainted($_[1])), "verify that isn't tainted";
+ ok((not is_tainted($_[1])), "verify that isn't tainted");
}
use locale; # engage locale and therefore locale taint.
@@ -928,6 +930,9 @@ if ($didwarn) {
sub last_locales { 117 }
+$test_num = $last_locales;
+my $i = $test_num + 1;
+
# Test that tainting and case changing works on utf8 strings. These tests are
# placed last to avoid disturbing the hard-coded test numbers above this in
# this file.
@@ -935,8 +940,6 @@ setlocale(LC_ALL, "C");
{
use locale;
- my $i = &last_locales + 1;
-
foreach my $function ("uc", "ucfirst", "lc", "lcfirst") {
my @list; # List of code points to test for $function
@@ -992,7 +995,7 @@ setlocale(LC_ALL, "C");
: ($function eq "lcfirst")
? lcfirst($char)
: croak("Unexpected function \"$function\"");
- ok($i++, $changed eq $should_be, "$function(\"$char\") should be \"$should_be\", got \"$changed\"");
+ ok($changed eq $should_be, "$function(\"$char\") in C locale should be \"$should_be\", got \"$changed\"");
# Tainting shouldn't happen for empty strings, or those characters
# above 255.