X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fop%2Flc.t;h=571868fe027a9d1acba506a9eb6e2f68858d75c4;hb=584420f022db57225e9644b9c6668ff9f567984a;hp=460fed2619dfae2b956462d2845f144f690eac00;hpb=04d26ecebd77cf17d10ce0138bddf4a7c888100f;p=p5sagit%2Fp5-mst-13.2.git diff --git a/t/op/lc.t b/t/op/lc.t index 460fed2..571868f 100644 --- a/t/op/lc.t +++ b/t/op/lc.t @@ -6,7 +6,7 @@ BEGIN { require './test.pl'; } -plan tests => 59; +plan tests => 87; $a = "HELLO.* world"; $b = "hello.* WORLD"; @@ -163,3 +163,45 @@ for my $a (0,1) { is($a, v10, "[perl #18857]"); } } + + +# [perl #38619] Bug in lc and uc (interaction between UTF-8, substr, and lc/uc) + +for ("a\x{100}", "xyz\x{100}") { + is(substr(uc($_), 0), uc($_), "[perl #38619] uc"); +} +for ("A\x{100}", "XYZ\x{100}") { + is(substr(lc($_), 0), lc($_), "[perl #38619] lc"); +} +for ("a\x{100}", "ßyz\x{100}") { # ß to Ss (different length) + is(substr(ucfirst($_), 0), ucfirst($_), "[perl #38619] ucfirst"); +} + +# Related to [perl #38619] +# the original report concerns PERL_MAGIC_utf8. +# these cases concern PERL_MAGIC_regex_global. + +for (map { $_ } "a\x{100}", "abc\x{100}", "\x{100}") { + chop; # get ("a", "abc", "") in utf8 + my $return = uc($_) =~ /\G(.?)/g; + my $result = $return ? $1 : "not"; + my $expect = (uc($_) =~ /(.?)/g)[0]; + is($return, 1, "[perl #38619]"); + is($result, $expect, "[perl #38619]"); +} + +for (map { $_ } "A\x{100}", "ABC\x{100}", "\x{100}") { + chop; # get ("A", "ABC", "") in utf8 + my $return = lc($_) =~ /\G(.?)/g; + my $result = $return ? $1 : "not"; + my $expect = (lc($_) =~ /(.?)/g)[0]; + is($return, 1, "[perl #38619]"); + is($result, $expect, "[perl #38619]"); +} + +for (1, 4, 9, 16, 25) { + is(uc "\x{03B0}" x $_, "\x{3a5}\x{308}\x{301}" x $_, + 'uc U+03B0 grows threefold'); + + is(lc "\x{0130}" x $_, "i\x{307}" x $_, 'lc U+0130 grows'); +}