From: Karl Williamson Date: Mon, 24 May 2010 17:01:10 +0000 (-0600) Subject: Change a few tests to use new test.pl EBCDIC stuff X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8a38a8369536df0f4eac69e5a26e9b86f9123d1d;p=p5sagit%2Fp5-mst-13.2.git Change a few tests to use new test.pl EBCDIC stuff A few .t's are delivered here which use the new conversion functions in test.pl. Obviously, this commit doesn't have to be incorporated, but it does simplify those tests. --- diff --git a/t/op/chop.t b/t/op/chop.t index 39577c2..30f7bff 100644 --- a/t/op/chop.t +++ b/t/op/chop.t @@ -183,7 +183,7 @@ ok($@ =~ /Can\'t modify.*chop.*in.*assignment/); eval 'chomp($x, $y) = (1, 2);'; ok($@ =~ /Can\'t modify.*chom?p.*in.*assignment/); -my @chars = ("N", ord('A') == 193 ? "\xee" : "\xd3", substr ("\xd4\x{100}", 0, 1), chr 1296); +my @chars = ("N", latin1_to_native("\xd3"), substr ("\xd4\x{100}", 0, 1), chr 1296); foreach my $start (@chars) { foreach my $end (@chars) { local $/ = $end; diff --git a/t/op/index.t b/t/op/index.t index 6cc3f42..59b5542 100644 --- a/t/op/index.t +++ b/t/op/index.t @@ -92,13 +92,8 @@ is(rindex($a, "foo", ), 0); { my $search; my $text; - if (ord('A') == 193) { - $search = "foo \x71 bar"; - $text = "a\xb1\xb1a $search $search quux"; - } else { - $search = "foo \xc9 bar"; - $text = "a\xa3\xa3a $search $search quux"; - } + $search = latin1_to_native("foo \xc9 bar"); + $text = latin1_to_native("a\xa3\xa3a $search $search quux"); my $text_utf8 = $text; utf8::upgrade($text_utf8); diff --git a/t/op/lc.t b/t/op/lc.t index 6b7625b..22242b2 100644 --- a/t/op/lc.t +++ b/t/op/lc.t @@ -74,31 +74,14 @@ is(lc($b) , "\x{101}\x{101}aa", 'lc'); # \x{149} is LATIN SMALL LETTER N PRECEDED BY APOSTROPHE, its uppercase is # \x{2BC}\x{E4} or MODIFIER LETTER APOSTROPHE and N. -# In EBCDIC \x{DF} is LATIN SMALL LETTER Y WITH DIAERESIS, -# and it's uppercase is \x{178}, LATIN CAPITAL LETTER Y WITH DIAERESIS. - -if (ord("A") == 193) { # EBCDIC - is("\U\x{DF}aB\x{149}cD" , "\x{178}AB\x{2BC}NCD", - "multicharacter uppercase"); -} elsif (ord("A") == 65) { - is("\U\x{DF}aB\x{149}cD" , "SSAB\x{2BC}NCD", +is(latin1_to_native("\U\x{DF}aB\x{149}cD"), latin1_to_native("SSAB\x{2BC}NCD"), "multicharacter uppercase"); -} else { - fail("what is your encoding?"); -} # The \x{DF} is its own lowercase, ditto for \x{149}. # There are no single character -> multiple characters lowercase mappings. -if (ord("A") == 193) { # EBCDIC - is("\LaB\x{149}cD" , "ab\x{149}cd", +is(latin1_to_native("\L\x{DF}aB\x{149}cD"), latin1_to_native("\x{DF}ab\x{149}cd"), "multicharacter lowercase"); -} elsif (ord("A") == 65) { - is("\L\x{DF}aB\x{149}cD" , "\x{DF}ab\x{149}cd", - "multicharacter lowercase"); -} else { - fail("what is your encoding?"); -} # titlecase is used for \u / ucfirst. diff --git a/t/uni/class.t b/t/uni/class.t index 3dde508..107a202 100644 --- a/t/uni/class.t +++ b/t/uni/class.t @@ -50,13 +50,7 @@ sub test_regexp ($$) { use strict; -my $str; - -if (ord('A') == 193) { - $str = join "", map chr($_), 0x40, 0x5A, 0x7F, 0x7B, 0x5B, 0x6C, 0x50, 0x7D, 0x4D, 0x5D, 0x5C, 0x4E, 0x6B, 0x60, 0x4B, 0x61, 0xF0 .. 0xF9, 0x7A, 0x5E, 0x4C, 0x7E, 0x6E, 0x6F, 0x7C, 0xC1 .. 0xC9, 0xD1 .. 0xD9, 0xE2 .. 0xE9, 0xAD, 0xE0, 0xBD, 0x5F, 0x6D, 0x79, 0x81 .. 0x89, 0x91 .. 0x96; # IBM-1047 -} else { - $str = join "", map chr($_), 0x20 .. 0x6F; -} +my $str = join "", map latin1_to_native(chr($_)), 0x20 .. 0x6F; # make sure it finds built-in class is(($str =~ /(\p{Letter}+)/)[0], 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');