diff options
author | Karl Williamson <khw@khw-desktop.(none)> | 2009-11-20 11:02:01 -0700 |
---|---|---|
committer | Rafael Garcia-Suarez <rgs@consttype.org> | 2009-11-23 14:17:36 +0100 |
commit | 61fc5122f0d8a509834282b8ecb3252d2e4c9f5d (patch) | |
tree | 5208ad914b6cd8f923c81ff9517c4b8ca5fcafb3 /lib | |
parent | 7f40cf6b25ea33d8a2dbbe1b42267811532b235d (diff) | |
download | perl-61fc5122f0d8a509834282b8ecb3252d2e4c9f5d.tar.gz |
Make unicode semantics the default
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/legacy.pm | 6 | ||||
-rw-r--r-- | lib/legacy.t | 32 |
2 files changed, 17 insertions, 21 deletions
diff --git a/lib/legacy.pm b/lib/legacy.pm index 66ddc00fdb..67f287ffd7 100755 --- a/lib/legacy.pm +++ b/lib/legacy.pm @@ -2,7 +2,7 @@ package legacy; our $VERSION = '1.00'; -$unicode8bit::hint_uni8bit = 0x00000800; +$unicode8bit::hint_not_uni8bit = 0x00000800; my %legacy_bundle = ( "5.10" => [qw(unicode8bit)], @@ -156,7 +156,7 @@ sub import { if (!exists $legacy{$name}) { unknown_legacy($name); } - $^H &= ~$unicode8bit::hint_uni8bit; # The only valid thing as of yet + $^H |= $unicode8bit::hint_not_uni8bit; # The only valid thing as of yet } } @@ -179,7 +179,7 @@ sub unimport { unknown_legacy($name); } else { - $^H |= $unicode8bit::hint_uni8bit; # The only valid thing as of yet + $^H &= ~ $unicode8bit::hint_not_uni8bit; # The only valid thing now } } } diff --git a/lib/legacy.t b/lib/legacy.t index 1d332b7be3..1f0cce953e 100644 --- a/lib/legacy.t +++ b/lib/legacy.t @@ -7,10 +7,9 @@ BEGIN { require './test.pl'; } -#use Test::More; +plan(13312); # Determined by experimentation -#plan("no_plan"); -plan(13312); +# Test the upper/lower/title case mappings for all characters 0-255. # First compute the case mappings without resorting to the functions we're # testing. @@ -28,7 +27,7 @@ my @posix_to_lower = @posix_to_upper; # Override the elements in the to_lower arrays that have different lower case -# mappings with those mappings. +# mappings for my $i (0x41 .. 0x5A) { $posix_to_lower[$i] = chr(ord($posix_to_lower[$i]) + 32); $latin1_to_lower[$i] = chr(ord($latin1_to_lower[$i]) + 32); @@ -82,12 +81,12 @@ $empty{'lc'} = $empty{'uc'} = ""; for my $prefix (\%empty, \%posix, \%cyrillic, \%latin1) { for my $suffix (\%empty, \%posix, \%cyrillic, \%latin1) { for my $i (0 .. 255) { # For each possible posix or latin1 character - my $cp = sprintf "%02X", $i; + my $cp = sprintf "U+%04X", $i; # First try using latin1 (Unicode) semantics. no legacy "unicode8bit"; - my $phrase = 'with unicode'; + my $phrase = 'with uni8bit'; my $char = chr($i); my $pre_lc = $prefix->{'lc'}; my $pre_uc = $prefix->{'uc'}; @@ -99,25 +98,22 @@ for my $prefix (\%empty, \%posix, \%cyrillic, \%latin1) { my $expected_lower = $pre_lc . $latin1_to_lower[$i] . $post_lc; is (uc($to_upper), $expected_upper, - - # The names are commented out for now to avoid 'wide character - # in print' messages. - ); #"$cp: $phrase: uc('$to_upper') eq '$expected_upper'"); + display("$cp: $phrase: uc($to_upper) eq $expected_upper")); is (lc($to_lower), $expected_lower, - ); #"$cp: $phrase: lc('$to_lower') eq '$expected_lower'"); + display("$cp: $phrase: lc($to_lower) eq $expected_lower")); if ($pre_uc eq "") { # Title case if null prefix. my $expected_title = $latin1_to_title[$i] . $post_lc; is (ucfirst($to_upper), $expected_title, - ); #"$cp: $phrase: ucfirst('$to_upper') eq '$expected_title'"); + display("$cp: $phrase: ucfirst($to_upper) eq $expected_title")); my $expected_lcfirst = $latin1_to_lower[$i] . $post_uc; is (lcfirst($to_lower), $expected_lcfirst, - ); #"$cp: $phrase: lcfirst('$to_lower') eq '$expected_lcfirst'"); + display("$cp: $phrase: lcfirst($to_lower) eq $expected_lcfirst")); } # Then try with posix semantics. use legacy "unicode8bit"; - $phrase = 'no unicode'; + $phrase = 'no uni8bit'; # These don't contribute anything in this case. next if $suffix == \%cyrillic; @@ -129,17 +125,17 @@ for my $prefix (\%empty, \%posix, \%cyrillic, \%latin1) { $expected_lower = $pre_lc . $posix_to_lower[$i] . $post_lc; is (uc($to_upper), $expected_upper, - ); #"$cp: $phrase: uc('$to_upper') eq '$expected_upper'"); + display("$cp: $phrase: uc($to_upper) eq $expected_upper")); is (lc($to_lower), $expected_lower, - ); #"$cp: $phrase: lc('$to_lower') eq '$expected_lower'"); + display("$cp: $phrase: lc($to_lower) eq $expected_lower")); if ($pre_uc eq "") { my $expected_title = $posix_to_title[$i] . $post_lc; is (ucfirst($to_upper), $expected_title, - ); #"$cp: $phrase: ucfirst('$to_upper') eq '$expected_title'"); + display("$cp: $phrase: ucfirst($to_upper) eq $expected_title")); my $expected_lcfirst = $posix_to_lower[$i] . $post_uc; is (lcfirst($to_lower), $expected_lcfirst, - ); #"$cp: $phrase: lcfirst('$to_lower') eq '$expected_lcfirst'"); + display("$cp: $phrase: lcfirst($to_lower) eq $expected_lcfirst")); } } } |