This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Strengthen weak refs when sorting in-place
[perl5.git] / t / base / translate.t
CommitLineData
d5b98071
KW
1#!./perl
2
3# Verify round trip of translations from the native character set to unicode
4# and back work. If this is wrong, nothing will be reliable.
5
6print "1..257\n"; # 0-255 plus one beyond
7
8for my $i (0 .. 255) {
9 my $uni = utf8::native_to_unicode($i);
10 if ($uni < 0 || $uni >= 256) {
11 print "not ";
12 }
13 elsif (utf8::unicode_to_native(utf8::native_to_unicode($i)) != $i) {
14 print "not ";
15 }
16 print "ok ";
8abe6e1a 17 print $i + 1 . " - native_to_unicode $i";
d5b98071
KW
18 print "\n";
19}
20
21# Choose a largish number that might cause a seg fault if inappropriate array
22# lookup
23if (utf8::unicode_to_native(utf8::native_to_unicode(100000)) != 100000) {
24 print "not ";
25}
8abe6e1a 26print "ok 257 - native_to_unicode of large number\n";