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
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
6 print "1..257\n";   # 0-255 plus one beyond
7
8 for 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 ";
17     print $i + 1 . " - native_to_unicode $i";
18     print "\n";
19 }
20
21 # Choose a largish number that might cause a seg fault if inappropriate array
22 # lookup
23 if (utf8::unicode_to_native(utf8::native_to_unicode(100000)) != 100000) {
24     print "not ";
25 }
26 print "ok 257 - native_to_unicode of large number\n";