diff options
author | Karl Williamson <khw@cpan.org> | 2017-05-25 20:09:07 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2017-07-12 21:14:24 -0600 |
commit | b3169593bf2efcd9a2b6848304e79f5a6ac362fe (patch) | |
tree | 94d2936e79158072f3069c2a54bb0937782f07d4 /ext/XS-APItest/t | |
parent | 04f42bf61483ac70f2927c2fe03f542893091fcb (diff) | |
download | perl-b3169593bf2efcd9a2b6848304e79f5a6ac362fe.tar.gz |
APItest/t/utf8_warn_base.pl: Eliminate hash element
This is leftover from an earlier version of the tests, and can be
calculated instead of having to manually specify it.
Diffstat (limited to 'ext/XS-APItest/t')
-rw-r--r-- | ext/XS-APItest/t/utf8_warn_base.pl | 82 |
1 files changed, 21 insertions, 61 deletions
diff --git a/ext/XS-APItest/t/utf8_warn_base.pl b/ext/XS-APItest/t/utf8_warn_base.pl index a7d9484ffa..3eb76e7992 100644 --- a/ext/XS-APItest/t/utf8_warn_base.pl +++ b/ext/XS-APItest/t/utf8_warn_base.pl @@ -45,12 +45,11 @@ sub nonportable_regex ($) { # be allowed/warned on. my @tests = ( # ($testname, $bytes, $warn_flags, $disallow_flags, $expected_error_flags, - # $category, $allowed_uv, $expected_len, $needed_to_discern_len, $message ) + # $category, $allowed_uv, $needed_to_discern_len, $message ) [ "lowest surrogate", (isASCII) ? "\xed\xa0\x80" : I8_to_native("\xf1\xb6\xa0\xa0"), $::UTF8_WARN_SURROGATE, $::UTF8_DISALLOW_SURROGATE, $::UTF8_GOT_SURROGATE, 'surrogate', 0xD800, - (isASCII) ? 3 : 4, 2, qr/surrogate/ ], @@ -58,7 +57,6 @@ my @tests = ( (isASCII) ? "\xed\xa4\x8d" : I8_to_native("\xf1\xb6\xa8\xad"), $::UTF8_WARN_SURROGATE, $::UTF8_DISALLOW_SURROGATE, $::UTF8_GOT_SURROGATE, 'surrogate', 0xD90D, - (isASCII) ? 3 : 4, 2, qr/surrogate/ ], @@ -66,7 +64,6 @@ my @tests = ( (isASCII) ? "\xed\xbf\xbf" : I8_to_native("\xf1\xb7\xbf\xbf"), $::UTF8_WARN_SURROGATE, $::UTF8_DISALLOW_SURROGATE, $::UTF8_GOT_SURROGATE, 'surrogate', 0xDFFF, - (isASCII) ? 3 : 4, 2, qr/surrogate/ ], @@ -74,7 +71,6 @@ my @tests = ( (isASCII) ? "\xf4\x90\x80\x80" : I8_to_native("\xf9\xa2\xa0\xa0\xa0"), $::UTF8_WARN_SUPER, $::UTF8_DISALLOW_SUPER, $::UTF8_GOT_SUPER, 'non_unicode', 0x110000, - (isASCII) ? 4 : 5, 2, qr/(not Unicode|for a non-Unicode code point).* may not be portable/ ], @@ -83,7 +79,6 @@ my @tests = ( $::UTF8_WARN_SUPER, $::UTF8_DISALLOW_SUPER, $::UTF8_GOT_SUPER, 'non_unicode', (isASCII) ? 0x140000 : 0x200000, - (isASCII) ? 4 : 5, 1, qr/(not Unicode|for a non-Unicode code point).* may not be portable/ ], @@ -92,7 +87,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0xFDD0, (isASCII) ? 3 : 4, - (isASCII) ? 3 : 4, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "a mid non-character code point of the 32 consecutive ones", @@ -100,7 +94,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0xFDE0, (isASCII) ? 3 : 4, - (isASCII) ? 3 : 4, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "final of 32 consecutive non-character code points", @@ -108,7 +101,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0xFDEF, (isASCII) ? 3 : 4, - (isASCII) ? 3 : 4, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+FFFE", @@ -116,7 +108,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0xFFFE, (isASCII) ? 3 : 4, - (isASCII) ? 3 : 4, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+FFFF", @@ -124,49 +115,48 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0xFFFF, (isASCII) ? 3 : 4, - (isASCII) ? 3 : 4, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+1FFFE", (isASCII) ? "\xf0\x9f\xbf\xbe" : I8_to_native("\xf3\xbf\xbf\xbe"), $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0x1FFFE, - 4, 4, + 4, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+1FFFF", (isASCII) ? "\xf0\x9f\xbf\xbf" : I8_to_native("\xf3\xbf\xbf\xbf"), $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0x1FFFF, - 4, 4, + 4, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+2FFFE", (isASCII) ? "\xf0\xaf\xbf\xbe" : I8_to_native("\xf5\xbf\xbf\xbe"), $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0x2FFFE, - 4, 4, + 4, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+2FFFF", (isASCII) ? "\xf0\xaf\xbf\xbf" : I8_to_native("\xf5\xbf\xbf\xbf"), $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0x2FFFF, - 4, 4, + 4, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+3FFFE", (isASCII) ? "\xf0\xbf\xbf\xbe" : I8_to_native("\xf7\xbf\xbf\xbe"), $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0x3FFFE, - 4, 4, + 4, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+3FFFF", (isASCII) ? "\xf0\xbf\xbf\xbf" : I8_to_native("\xf7\xbf\xbf\xbf"), $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0x3FFFF, - 4, 4, + 4, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+4FFFE", @@ -174,7 +164,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0x4FFFE, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+4FFFF", @@ -182,7 +171,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0x4FFFF, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+5FFFE", @@ -190,7 +178,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0x5FFFE, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+5FFFF", @@ -198,7 +185,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0x5FFFF, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+6FFFE", @@ -206,7 +192,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0x6FFFE, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+6FFFF", @@ -214,7 +199,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0x6FFFF, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+7FFFE", @@ -222,7 +206,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0x7FFFE, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+7FFFF", @@ -230,7 +213,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0x7FFFF, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+8FFFE", @@ -238,7 +220,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0x8FFFE, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+8FFFF", @@ -246,7 +227,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0x8FFFF, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+9FFFE", @@ -254,7 +234,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0x9FFFE, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+9FFFF", @@ -262,7 +241,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0x9FFFF, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+AFFFE", @@ -270,7 +248,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0xAFFFE, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+AFFFF", @@ -278,7 +255,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0xAFFFF, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+BFFFE", @@ -286,7 +262,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0xBFFFE, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+BFFFF", @@ -294,7 +269,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0xBFFFF, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+CFFFE", @@ -302,7 +276,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0xCFFFE, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+CFFFF", @@ -310,7 +283,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0xCFFFF, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+DFFFE", @@ -318,7 +290,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0xDFFFE, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+DFFFF", @@ -326,7 +297,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0xDFFFF, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+EFFFE", @@ -334,7 +304,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0xEFFFE, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+EFFFF", @@ -342,7 +311,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0xEFFFF, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+FFFFE", @@ -350,7 +318,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0xFFFFE, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+FFFFF", @@ -358,7 +325,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0xFFFFF, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+10FFFE", @@ -366,7 +332,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0x10FFFE, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "non-character code point U+10FFFF", @@ -374,7 +339,6 @@ my @tests = ( $::UTF8_WARN_NONCHAR, $::UTF8_DISALLOW_NONCHAR, $::UTF8_GOT_NONCHAR, 'nonchar', 0x10FFFF, (isASCII) ? 4 : 5, - (isASCII) ? 4 : 5, qr/Unicode non-character.*is not recommended for open interchange/ ], [ "requires at least 32 bits", @@ -387,7 +351,6 @@ my @tests = ( $::UTF8_WARN_ABOVE_31_BIT, $::UTF8_DISALLOW_ABOVE_31_BIT, $::UTF8_GOT_ABOVE_31_BIT, 'utf8', 0x80000000, - (isASCII) ? 7 : $::max_bytes, (isASCII) ? 1 : 8, nonportable_regex(0x80000000) ], @@ -399,7 +362,6 @@ my @tests = ( $::UTF8_WARN_ABOVE_31_BIT, $::UTF8_DISALLOW_ABOVE_31_BIT, $::UTF8_GOT_ABOVE_31_BIT, 'utf8', 0xFFFFFFFF, - (isASCII) ? 7 : $::max_bytes, (isASCII) ? 1 : 8, nonportable_regex(0xffffffff) ], @@ -411,7 +373,6 @@ my @tests = ( "\xff\xa0\xa0\xa0\xa0\xa0\xa0\xa2\xa0\xa0\xa0\xa0\xa0\xa0"), $::UTF8_WARN_SUPER, $::UTF8_DISALLOW_SUPER, $::UTF8_GOT_SUPER, 'utf8', 0x80000000, - (isASCII) ? 7 : $::max_bytes, 1, nonportable_regex(0x80000000) ], @@ -437,7 +398,6 @@ my @tests = ( $::UTF8_DISALLOW_ABOVE_31_BIT, $::UTF8_GOT_ABOVE_31_BIT, 'utf8', -1, - (! isASCII || $::is64bit) ? $::max_bytes : 7, (isASCII || $::is64bit) ? 2 : 8, qr/overflows/ ], @@ -452,7 +412,7 @@ if (! $::is64bit) { $::UTF8_WARN_ABOVE_31_BIT, $::UTF8_DISALLOW_ABOVE_31_BIT, $::UTF8_GOT_ABOVE_31_BIT, 'utf8', -1, - 7, 1, + 1, qr/and( is)? not portable/ ]; } @@ -468,7 +428,7 @@ else { $::UTF8_WARN_ABOVE_31_BIT, $::UTF8_DISALLOW_ABOVE_31_BIT, $::UTF8_GOT_ABOVE_31_BIT, 'utf8', 0x1000000000, - $::max_bytes, (isASCII) ? 1 : 7, + (isASCII) ? 1 : 7, qr/and( is)? not portable/ ]; if (! isASCII) { @@ -480,7 +440,7 @@ else { $::UTF8_WARN_ABOVE_31_BIT,$::UTF8_DISALLOW_ABOVE_31_BIT, $::UTF8_GOT_ABOVE_31_BIT, 'utf8', 0x800000000, - $::max_bytes, 7, + 7, nonportable_regex(0x80000000) ], [ "requires at least 32 bits", @@ -489,7 +449,7 @@ else { $::UTF8_WARN_ABOVE_31_BIT,$::UTF8_DISALLOW_ABOVE_31_BIT, $::UTF8_GOT_ABOVE_31_BIT, 'utf8', 0x10000000000, - $::max_bytes, 6, + 6, nonportable_regex(0x10000000000) ], [ "requires at least 32 bits", @@ -498,7 +458,7 @@ else { $::UTF8_WARN_ABOVE_31_BIT,$::UTF8_DISALLOW_ABOVE_31_BIT, $::UTF8_GOT_ABOVE_31_BIT, 'utf8', 0x200000000000, - $::max_bytes, 5, + 5, nonportable_regex(0x20000000000) ], [ "requires at least 32 bits", @@ -507,7 +467,7 @@ else { $::UTF8_WARN_ABOVE_31_BIT,$::UTF8_DISALLOW_ABOVE_31_BIT, $::UTF8_GOT_ABOVE_31_BIT, 'utf8', 0x4000000000000, - $::max_bytes, 4, + 4, nonportable_regex(0x4000000000000) ], [ "requires at least 32 bits", @@ -516,7 +476,7 @@ else { $::UTF8_WARN_ABOVE_31_BIT,$::UTF8_DISALLOW_ABOVE_31_BIT, $::UTF8_GOT_ABOVE_31_BIT, 'utf8', 0x80000000000000, - $::max_bytes, 3, + 3, nonportable_regex(0x80000000000000) ], [ "requires at least 32 bits", @@ -525,7 +485,7 @@ else { $::UTF8_WARN_ABOVE_31_BIT,$::UTF8_DISALLOW_ABOVE_31_BIT, $::UTF8_GOT_ABOVE_31_BIT, 'utf8', 0x1000000000000000, - $::max_bytes, 2, + 2, nonportable_regex(0x1000000000000000) ]; } @@ -541,7 +501,7 @@ foreach my $test (@tests) { next if $test_count % $num_test_files != $::TEST_CHUNK; my ($testname, $bytes, $warn_flags, $disallow_flags, $expected_error_flags, - $category, $allowed_uv, $expected_len, $needed_to_discern_len, $message + $category, $allowed_uv, $needed_to_discern_len, $message ) = @$test; my $length = length $bytes; @@ -673,10 +633,10 @@ foreach my $test (@tests) { { foreach my $overlong ("", "overlong") { - # If we're already at the longest possible, we - # can't create an overlong (which would be longer) - # can't handle anything larger. - next if $overlong && $expected_len >= $::max_bytes; + # If we're creating an overlong, it can't be longer than + # the maximum length, so skip if we're already at that + # length. + next if $overlong && $length >= $::max_bytes; my @malformations; my @expected_errors; @@ -700,7 +660,7 @@ foreach my $test (@tests) { my $this_bytes = $bytes; my $this_length = $length; my $expected_uv = $allowed_uv; - my $this_expected_len = $expected_len; + my $this_expected_len = $length; my $this_needed_to_discern_len = $needed_to_discern_len; if ($malformations_name) { $expected_uv = 0; |