Be more explicit on the List::Util build trick,
[p5sagit/p5-mst-13.2.git] / ext / Encode.t
index ceeb422..3f5d206 100644 (file)
@@ -2,13 +2,15 @@ BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
     require Config; import Config;
-    if ($Config{'extensions'} !~ /\Encode\b/) {
+    if ($Config{'extensions'} !~ /\bEncode\b/) {
       print "1..0 # Skip: Encode was not built\n";
       exit 0;
     }
 }
 use Test;
-use Encode qw(from_to encode decode encode_utf8 decode_utf8 find_encoding);
+use Encode qw(from_to encode decode
+             encode_utf8 decode_utf8
+             find_encoding is_utf8);
 use charnames qw(greek);
 my @encodings = grep(/iso-?8859/,Encode::encodings());
 my $n = 2;
@@ -16,7 +18,7 @@ my @character_set = ('0'..'9', 'A'..'Z', 'a'..'z');
 my @source = qw(ascii iso8859-1 cp1250);
 my @destiny = qw(cp1047 cp37 posix-bc);
 my @ebcdic_sets = qw(cp1047 cp37 posix-bc);
-plan test => 38+$n*@encodings + 2*@source*@destiny*@character_set + 2*@ebcdic_sets*256;
+plan test => 38+$n*@encodings + 2*@source*@destiny*@character_set + 2*@ebcdic_sets*256 + 6;
 my $str = join('',map(chr($_),0x20..0x7E));
 my $cpy = $str;
 ok(length($str),from_to($cpy,'iso8859-1','Unicode'),"Length Wrong");
@@ -120,3 +122,19 @@ for my $i (0x41,128,256,0x20AC)
  }
 
 
+# is_utf8
+
+ok(  is_utf8("\x{100}"));
+ok(! is_utf8("a"));
+ok(! is_utf8(""));
+"\x{100}" =~ /(.)/;
+ok(  is_utf8($1)); # ID 20011127.151
+$a = $1;
+ok(  is_utf8($a));
+$a = "\x{100}";
+chop $a;
+ok(  is_utf8($a)); # weird but true: an empty UTF-8 string
+
+
+
+