Commit | Line | Data |
92331800 |
1 | #!perl -w |
2 | |
3 | BEGIN { |
4 | if ($ENV{'PERL_CORE'}){ |
5 | chdir 't'; |
6 | @INC = '../lib'; |
7 | } |
8 | } |
9 | |
10 | use Test::More tests => 8; |
11 | |
12 | package UTF8Field; |
13 | use strict; |
14 | |
15 | use overload '""' => 'stringify'; |
16 | |
17 | sub new { |
18 | my $class = shift; |
19 | return bless [shift, 0], $class; |
20 | } |
21 | |
22 | sub stringify { |
23 | my $self = shift; |
24 | $self->[1] = ! $self->[1]; |
25 | if ($self->[1]) { |
26 | utf8::downgrade($self->[0]); |
27 | } else { |
28 | utf8::upgrade($self->[0]); |
29 | } |
30 | $self->[0]; |
31 | } |
32 | |
33 | package main; |
34 | |
35 | # Bug 34297 |
36 | foreach my $t ("ASCII", "B\366se") { |
37 | my $length = length $t; |
38 | |
39 | my $u = UTF8Field->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'"); |
44 | } |