4 if ($ENV{'PERL_CORE'}){
10 use Test::More tests => 56;
15 use overload '""' => 'stringify';
19 return bless [shift, 0], $class;
24 $self->[1] = ! $self->[1];
26 utf8::downgrade($self->[0]);
28 utf8::upgrade($self->[0]);
36 foreach my $t ("ASCII", "B\366se") {
37 my $length = length $t;
39 my $u = UTF8Toggle->new($t);
40 is (length $u, $length, "length of '$t'");
41 is (length $u, $length, "length of '$t'");
42 is (length $u, $length, "length of '$t'");
43 is (length $u, $length, "length of '$t'");
46 my $u = UTF8Toggle->new("\311");
49 is ($lc, "\311", "E accute -> e accute");
52 is ($lc, "\351", "E accute -> e accute");
55 is ($lc, "\311", "E accute -> e accute");
57 $u = UTF8Toggle->new("\351");
60 is ($uc, "\351", "e accute -> E accute");
63 is ($uc, "\311", "e accute -> E accute");
66 is ($uc, "\351", "e accute -> E accute");
68 $u = UTF8Toggle->new("\311");
71 is ($lc, "\311", "E accute -> e accute");
74 is ($lc, "\351", "E accute -> e accute");
77 is ($lc, "\311", "E accute -> e accute");
79 $u = UTF8Toggle->new("\351");
82 is ($uc, "\351", "e accute -> E accute");
85 is ($uc, "\311", "e accute -> E accute");
88 is ($uc, "\351", "e accute -> E accute");
90 my $have_setlocale = 0;
93 import POSIX ':locale_h';
98 if (!$have_setlocale) {
99 skip "No setlocale", 24;
100 } elsif (!setlocale(&POSIX::LC_ALL, "en_GB.ISO8859-1")) {
101 skip "Could not setlocale to en_GB.ISO8859-1", 24;
104 my $u = UTF8Toggle->new("\311");
107 is ($lc, "\351", "E accute -> e accute");
110 is ($lc, "\351", "E accute -> e accute");
113 is ($lc, "\351", "E accute -> e accute");
115 $u = UTF8Toggle->new("\351");
118 is ($uc, "\311", "e accute -> E accute");
121 is ($uc, "\311", "e accute -> E accute");
124 is ($uc, "\311", "e accute -> E accute");
126 $u = UTF8Toggle->new("\311");
129 is ($lc, "\351", "E accute -> e accute");
132 is ($lc, "\351", "E accute -> e accute");
135 is ($lc, "\351", "E accute -> e accute");
137 $u = UTF8Toggle->new("\351");
140 is ($uc, "\311", "e accute -> E accute");
143 is ($uc, "\311", "e accute -> E accute");
146 is ($uc, "\311", "e accute -> E accute");