summaryrefslogtreecommitdiff
path: root/t/op/pack.t
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>1999-02-10 02:04:52 +0200
committerGurusamy Sarathy <gsar@cpan.org>1999-02-15 06:26:39 +0000
commitef54e1a45e68bbd668c909c97e266f20578d5516 (patch)
treea96ebdb7f26c3b0299b7fa25241acb35de121905 /t/op/pack.t
parent9ef261b5e9ba232556e09d48dcf0e3964298f8f6 (diff)
downloadperl-ef54e1a45e68bbd668c909c97e266f20578d5516.tar.gz
support native integers, pack("L_",...) etc. (via private mail)
Message-Id: <199902092204.AAA29065@alpha.hut.fi> Subject: the "packnative" patch p4raw-id: //depot/perl@2936
Diffstat (limited to 't/op/pack.t')
-rwxr-xr-xt/op/pack.t36
1 files changed, 27 insertions, 9 deletions
diff --git a/t/op/pack.t b/t/op/pack.t
index 53b001d4ff..82f2b1cdd3 100755
--- a/t/op/pack.t
+++ b/t/op/pack.t
@@ -1,14 +1,12 @@
#!./perl
-# $RCSfile: pack.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:11 $
-
BEGIN {
chdir 't' if -d 't';
unshift @INC, '../lib' if -d '../lib';
require Config; import Config;
}
-print "1..72\n";
+print "1..78\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
@@ -166,6 +164,11 @@ foreach my $t (@templates) {
# 57..60: uuencode/decode
+# Note that first uuencoding known 'text' data and then checking the
+# binary values of the uuencoded version would not be portable between
+# character sets. Uuencoding is meant for encoding binary data, not
+# text data.
+
$in = pack 'C*', 0 .. 255;
# just to be anal, we do some random tr/`/ /
@@ -205,12 +208,7 @@ EOUU
print "not " unless unpack('u', $uu) eq $in;
print "ok ", $test++, "\n";
-# Note that first uuencoding known 'text' data and then checking the
-# binary values of the uuencoded version would not be portable between
-# character sets. Uuencoding is meant for encoding binary data, not
-# text data.
-
-# test the ascii template types (A, a, Z)
+# 61..72: test the ascii template types (A, a, Z)
print "not " unless pack('A*', "foo\0bar\0 ") eq "foo\0bar\0 ";
print "ok ", $test++, "\n";
@@ -248,3 +246,23 @@ print "ok ", $test++, "\n";
print "not " unless unpack('Z8', "foo\0bar \0") eq "foo";
print "ok ", $test++, "\n";
+# 73..77: packing native shorts/ints/longs
+
+print "not " unless length(pack("s_", 0)) == $Config{shortsize};
+print "ok ", $test++, "\n";
+
+print "not " unless length(pack("i_", 0)) == $Config{intsize};
+print "ok ", $test++, "\n";
+
+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 "ok ", $test++, "\n";
+
+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 "ok ", $test++, "\n";
+