integrate cfgperl contents into mainline
[p5sagit/p5-mst-13.2.git] / t / op / pack.t
index 4bfbfa3..082b954 100755 (executable)
@@ -6,7 +6,7 @@ BEGIN {
     require Config; import Config;
 }
 
-print "1..142\n";
+print "1..148\n";
 
 $format = "c2 x5 C C x s d i l a6";
 # Need the expression in here to force ary[5] to be numeric.  This avoids
@@ -248,22 +248,22 @@ print "ok ", $test++, "\n";
 
 # 73..78: packing native shorts/ints/longs
 
-print "not " unless length(pack("s_", 0)) == $Config{shortsize};
+print "not " unless length(pack("s!", 0)) == $Config{shortsize};
 print "ok ", $test++, "\n";
 
-print "not " unless length(pack("i_", 0)) == $Config{intsize};
+print "not " unless length(pack("i!", 0)) == $Config{intsize};
 print "ok ", $test++, "\n";
 
-print "not " unless length(pack("l_", 0)) == $Config{longsize};
+print "not " unless length(pack("l!", 0)) == $Config{longsize};
 print "ok ", $test++, "\n";
 
-print "not " unless length(pack("s_", 0)) <= length(pack("i_", 0));
+print "not " unless length(pack("s!", 0)) <= length(pack("i!", 0));
 print "ok ", $test++, "\n";
 
-print "not " unless length(pack("i_", 0)) <= length(pack("l_", 0));
+print "not " unless length(pack("i!", 0)) <= length(pack("l!", 0));
 print "ok ", $test++, "\n";
 
-print "not " unless length(pack("i_", 0)) == length(pack("i", 0));
+print "not " unless length(pack("i!", 0)) == length(pack("i", 0));
 print "ok ", $test++, "\n";
 
 # 79..138: pack <-> unpack bijectionism
@@ -353,3 +353,19 @@ print "ok ", $test++, "\n";
 
 print "not " unless pack("V", 0xdeadbeef) eq "\xef\xbe\xad\xde";
 print "ok ", $test++, "\n";
+
+# 143..148: # 
+
+my $z;
+eval { ($x) = unpack '#a*','hello' };
+print 'not ' unless $@; print "ok $test\n"; $test++;
+eval { ($z,$x,$y) = unpack 'a3#A C#a* C#Z', "003ok \003yes\004z\000abc" };
+print $@ eq '' && $z eq 'ok' ? "ok $test\n" : "not ok $test\n"; $test++;
+print $@ eq '' && $x eq 'yes' ? "ok $test\n" : "not ok $test\n"; $test++;
+print $@ eq '' && $y eq 'z' ? "ok $test\n" : "not ok $test\n"; $test++;
+
+eval { ($x) = pack '#a*','hello' };
+print 'not ' unless $@; print "ok $test\n"; $test++;
+$z = pack 'n#a* w#A*','string','etc';
+print 'not ' unless $z eq "\000\006string\003etc"; print "ok $test\n"; $test++;
+