1b39c5158Smillert#!perl -w 2b39c5158Smillert 3b39c5158Smillertuse strict; 4*256a93a4Safresh1use warnings; 5*256a93a4Safresh1 6b39c5158Smillertuse Digest::MD5 qw(md5_hex); 7b39c5158Smillert 8*256a93a4Safresh1print "1..5\n"; 9*256a93a4Safresh1 10b39c5158Smillertmy $str; 11b39c5158Smillert$str = "foo\xFF\x{100}"; 12b39c5158Smillert 13b39c5158Smillerteval { 14b39c5158Smillert print md5_hex($str); 15b39c5158Smillert print "not ok 1\n"; # should not run 16b39c5158Smillert}; 17b39c5158Smillertprint "not " unless $@ && $@ =~ /^(Big byte|Wide character)/; 18b39c5158Smillertprint "ok 1\n"; 19b39c5158Smillert 20b39c5158Smillertmy $exp = ord "A" == 193 ? # EBCDIC 21b39c5158Smillert "c307ec81deba65e9a222ca81cd8f6ccd" : 22b39c5158Smillert "503debffe559537231ed24f25651ec20"; # Latin 1 23b39c5158Smillert 24b39c5158Smillertchop($str); # only bytes left 25b39c5158Smillertprint "not " unless md5_hex($str) eq $exp; 26b39c5158Smillertprint "ok 2\n"; 27b39c5158Smillert 28b39c5158Smillert# reference 29b39c5158Smillertprint "not " unless md5_hex("foo\xFF") eq $exp; 30b39c5158Smillertprint "ok 3\n"; 31898184e3Ssthen 32898184e3Ssthen# autopromotion 33898184e3Ssthenif ($] >= 5.007003) { 34898184e3Ssthen 35898184e3Ssthenmy $unistring = "Oslo.pm har sosialt medlemsmøte onsdag 1. April 2008, klokken 18:30. Vi treffes på Marhaba Café, Keysersgate 1."; 36898184e3Ssthen 37898184e3Ssthenrequire Encode; 38898184e3Ssthen$unistring = Encode::decode_utf8($unistring); 39898184e3Ssthenprint "not " if ( not utf8::is_utf8($unistring)); 40898184e3Ssthenprint "ok 4\n"; 41898184e3Ssthen 42898184e3Ssthenmd5_hex($unistring, ""); 43898184e3Ssthenprint "not " if ( not utf8::is_utf8($unistring)); 44898184e3Ssthenprint "ok 5\n" 45898184e3Ssthen 46898184e3Ssthen} else { 47898184e3Ssthen print "ok 4 # SKIP Your perl is too old to properly test unicode semantics\nok 5 # SKIP No, really\n"; 48898184e3Ssthen} 49