our $VERSION = '0.2';
+use Storable qw(dclone);
+
require Exporter;
our @ISA = qw(Exporter);
_search(\@BLOCKS, 0, $#BLOCKS, $code);
} else {
if (exists $BLOCKS{$arg}) {
- return $BLOCKS{$arg};
+ return dclone $BLOCKS{$arg};
} else {
return;
}
_search(\@SCRIPTS, 0, $#SCRIPTS, $code);
} else {
if (exists $SCRIPTS{$arg}) {
- return $SCRIPTS{$arg};
+ return dclone $SCRIPTS{$arg};
} else {
return;
}
sub charblocks {
_charblocks() unless %BLOCKS;
- return \%BLOCKS;
+ return dclone \%BLOCKS;
}
=head2 charscripts
sub charscripts {
_charscripts() unless %SCRIPTS;
- return \%SCRIPTS;
+ return dclone \%SCRIPTS;
}
=head2 Blocks versus Scripts
_casespec() unless %CASESPEC;
- return $CASESPEC{$code};
+ return ref $CASESPEC{$code} ? dclone $CASESPEC{$code} : $CASESPEC{$code};
}
=head2 Unicode::UCD::UnicodeVersion
use Unicode::UCD;
use Test::More;
-BEGIN { plan tests => 176 };
+BEGIN { plan tests => 178 };
use Unicode::UCD 'charinfo';
is(Unicode::UCD::_getcode('x123'), undef, "_getcode(x123)");
is(Unicode::UCD::_getcode('0x123x'), undef, "_getcode(x123)");
is(Unicode::UCD::_getcode('U+123x'), undef, "_getcode(x123)");
+
+{
+ my $r1 = charscript('Latin');
+ my $n1 = @$r1;
+ is($n1, 26, "26 ranges in Latin script (Unicode 4.0.0)");
+ shift @$r1 while @$r1;
+ my $r2 = charscript('Latin');
+ is(@$r2, $n1, "modifying results should not mess up internal caches");
+}
+