Blame t/cow.t

Packit d0f5c2
#
Packit d0f5c2
# $Id: cow.t,v 1.2 2016/08/04 03:15:58 dankogai Exp $
Packit d0f5c2
#
Packit d0f5c2
use strict;
Packit d0f5c2
use Encode ();
Packit d0f5c2
use Test::More tests => 4;
Packit d0f5c2
Packit d0f5c2
Packit d0f5c2
my %a = ( "L\x{c3}\x{a9}on" => "acme" );
Packit d0f5c2
my ($k) = ( keys %a );
Packit d0f5c2
Encode::_utf8_on($k);
Packit d0f5c2
my %h = ( $k => "acme" );
Packit d0f5c2
is $h{"L\x{e9}on"} => 'acme';
Packit d0f5c2
($k) = ( keys %h );
Packit d0f5c2
Encode::_utf8_off($k);
Packit d0f5c2
%a = ( $k => "acme" );
Packit d0f5c2
is $h{"L\x{e9}on"} => 'acme';
Packit d0f5c2
# use Devel::Peek;
Packit d0f5c2
# Dump(\%h);
Packit d0f5c2
Packit d0f5c2
{ # invalid input to encode/decode/from_to should not affect COW-shared scalars
Packit d0f5c2
	my $x = Encode::decode('UTF-8', "\303\244" x 4);
Packit d0f5c2
	my $orig = "$x"; # non-COW copy
Packit d0f5c2
	is($x, $orig, "copy of original string matches");
Packit d0f5c2
	{ my $y = $x; Encode::from_to($y, "UTF-8", "iso-8859-1"); }
Packit d0f5c2
	is($x, $orig, "original scalar unmodified after from_to() call");
Packit d0f5c2
}