Commit | Line | Data |
a687059c |
1 | #!./perl |
2 | |
a1a0e61e |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
20822f61 |
5 | @INC = '../lib'; |
a1a0e61e |
6 | require Config; import Config; |
7 | } |
8 | |
9e639032 |
9 | print "1..163\n"; |
a687059c |
10 | |
bbdab043 |
11 | $format = "c2 x5 C C x s d i l a6"; |
450a55e4 |
12 | # Need the expression in here to force ary[5] to be numeric. This avoids |
13 | # test2 failing because ary2 goes str->numeric->str and ary doesn't. |
14 | @ary = (1,-100,127,128,32767,987.654321098 / 100.0,12345,123456,"abcdef"); |
a687059c |
15 | $foo = pack($format,@ary); |
16 | @ary2 = unpack($format,$foo); |
17 | |
18 | print ($#ary == $#ary2 ? "ok 1\n" : "not ok 1\n"); |
19 | |
20 | $out1=join(':',@ary); |
21 | $out2=join(':',@ary2); |
ae165b0c |
22 | # Using long double NVs may introduce greater accuracy than wanted. |
658bbd66 |
23 | $out1 =~ s/:9\.87654321097999\d*:/:9.87654321098:/; |
c4ab3e64 |
24 | $out2 =~ s/:9\.87654321097999\d*:/:9.87654321098:/; |
11882669 |
25 | if ($out1 eq $out2) { |
26 | print "ok 2\n"; |
27 | } else { |
28 | print "# out1: $out1\n"; |
29 | print "# out2: $out2\n"; |
30 | print "not ok 2\n"; |
31 | } |
a687059c |
32 | |
33 | print ($foo =~ /def/ ? "ok 3\n" : "not ok 3\n"); |
79072805 |
34 | |
35 | # How about counting bits? |
36 | |
37 | print +($x = unpack("%32B*", "\001\002\004\010\020\040\100\200\377")) == 16 |
38 | ? "ok 4\n" : "not ok 4 $x\n"; |
39 | |
40 | print +($x = unpack("%32b69", "\001\002\004\010\020\040\100\200\017")) == 12 |
41 | ? "ok 5\n" : "not ok 5 $x\n"; |
42 | |
43 | print +($x = unpack("%32B69", "\001\002\004\010\020\040\100\200\017")) == 9 |
44 | ? "ok 6\n" : "not ok 6 $x\n"; |
45 | |
9d116dd7 |
46 | my $sum = 129; # ASCII |
a1a0e61e |
47 | $sum = 103 if ($Config{ebcdic} eq 'define'); |
9d116dd7 |
48 | |
49 | print +($x = unpack("%32B*", "Now is the time for all good blurfl")) == $sum |
79072805 |
50 | ? "ok 7\n" : "not ok 7 $x\n"; |
51 | |
b8440792 |
52 | open(BIN, "./perl") || open(BIN, "./perl.exe") |
53 | || die "Can't open ../perl or ../perl.exe: $!\n"; |
79072805 |
54 | sysread BIN, $foo, 8192; |
55 | close BIN; |
56 | |
57 | $sum = unpack("%32b*", $foo); |
58 | $longway = unpack("b*", $foo); |
59 | print $sum == $longway =~ tr/1/1/ ? "ok 8\n" : "not ok 8\n"; |
73a1c01a |
60 | |
61 | print +($x = unpack("I",pack("I", 0xFFFFFFFF))) == 0xFFFFFFFF |
62 | ? "ok 9\n" : "not ok 9 $x\n"; |
def98dd4 |
63 | |
64 | # check 'w' |
65 | my $test=10; |
55497cff |
66 | my @x = (5,130,256,560,32000,3097152,268435455,1073741844, |
67 | '4503599627365785','23728385234614992549757750638446'); |
def98dd4 |
68 | my $x = pack('w*', @x); |
55497cff |
69 | my $y = pack 'H*', '0581028200843081fa0081bd8440ffffff7f848080801487ffffffffffdb19caefe8e1eeeea0c2e1e3e8ede1ee6e'; |
def98dd4 |
70 | |
71 | print $x eq $y ? "ok $test\n" : "not ok $test\n"; $test++; |
72 | |
73 | @y = unpack('w*', $y); |
55497cff |
74 | my $a; |
75 | while ($a = pop @x) { |
76 | my $b = pop @y; |
77 | print $a eq $b ? "ok $test\n" : "not ok $test\n$a\n$b\n"; $test++; |
78 | } |
def98dd4 |
79 | |
80 | @y = unpack('w2', $x); |
81 | |
82 | print scalar(@y) == 2 ? "ok $test\n" : "not ok $test\n"; $test++; |
83 | print $y[1] == 130 ? "ok $test\n" : "not ok $test\n"; $test++; |
84 | |
55497cff |
85 | # test exeptions |
def98dd4 |
86 | eval { $x = unpack 'w', pack 'C*', 0xff, 0xff}; |
87 | print $@ ne '' ? "ok $test\n" : "not ok $test\n"; $test++; |
88 | |
89 | eval { $x = unpack 'w', pack 'C*', 0xff, 0xff, 0xff, 0xff}; |
90 | print $@ ne '' ? "ok $test\n" : "not ok $test\n"; $test++; |
91 | |
92 | eval { $x = unpack 'w', pack 'C*', 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; |
93 | print $@ ne '' ? "ok $test\n" : "not ok $test\n"; $test++; |
94 | |
84902520 |
95 | # |
96 | # test the "p" template |
97 | |
98 | # literals |
99 | print((unpack("p",pack("p","foo")) eq "foo" ? "ok " : "not ok "),$test++,"\n"); |
100 | |
101 | # scalars |
102 | print((unpack("p",pack("p",$test)) == $test ? "ok " : "not ok "),$test++,"\n"); |
103 | |
104 | # temps |
105 | sub foo { my $a = "a"; return $a . $a++ . $a++ } |
106 | { |
9f1b1f2d |
107 | use warnings; |
84902520 |
108 | my $last = $test; |
109 | local $SIG{__WARN__} = sub { |
110 | print "ok ",$test++,"\n" if $_[0] =~ /temporary val/ |
111 | }; |
112 | my $junk = pack("p", &foo); |
113 | print "not ok ", $test++, "\n" if $last == $test; |
114 | } |
115 | |
116 | # undef should give null pointer |
117 | print((pack("p", undef) =~ /^\0+/ ? "ok " : "not ok "),$test++,"\n"); |
118 | |
20408e3c |
119 | # Check for optimizer bug (e.g. Digital Unix GEM cc with -O4 on DU V4.0B gives |
120 | # 4294967295 instead of -1) |
121 | # see #ifdef __osf__ in pp.c pp_unpack |
122 | # Test 30: |
123 | print( ((unpack("i",pack("i",-1))) == -1 ? "ok " : "not ok "),$test++,"\n"); |
124 | |
d4217c7e |
125 | # 31..36: test the pack lengths of s S i I l L |
126 | print "not " unless length(pack("s", 0)) == 2; |
127 | print "ok ", $test++, "\n"; |
128 | |
129 | print "not " unless length(pack("S", 0)) == 2; |
130 | print "ok ", $test++, "\n"; |
131 | |
132 | print "not " unless length(pack("i", 0)) >= 4; |
133 | print "ok ", $test++, "\n"; |
134 | |
135 | print "not " unless length(pack("I", 0)) >= 4; |
136 | print "ok ", $test++, "\n"; |
137 | |
138 | print "not " unless length(pack("l", 0)) == 4; |
139 | print "ok ", $test++, "\n"; |
140 | |
141 | print "not " unless length(pack("L", 0)) == 4; |
142 | print "ok ", $test++, "\n"; |
143 | |
144 | # 37..40: test the pack lengths of n N v V |
145 | |
146 | print "not " unless length(pack("n", 0)) == 2; |
147 | print "ok ", $test++, "\n"; |
148 | |
149 | print "not " unless length(pack("N", 0)) == 4; |
150 | print "ok ", $test++, "\n"; |
151 | |
152 | print "not " unless length(pack("v", 0)) == 2; |
153 | print "ok ", $test++, "\n"; |
154 | |
155 | print "not " unless length(pack("V", 0)) == 4; |
156 | print "ok ", $test++, "\n"; |
157 | |
158 | # 41..56: test unpack-pack lengths |
159 | |
160 | my @templates = qw(c C i I s S l L n N v V f d); |
161 | |
162 | # quads not supported everywhere: if not, retest floats/doubles |
163 | # to preserve the test count... |
164 | eval { my $q = pack("q",0) }; |
165 | push @templates, $@ !~ /Invalid type in pack/ ? qw(q Q) : qw(f d); |
166 | |
167 | foreach my $t (@templates) { |
168 | my @t = unpack("$t*", pack("$t*", 12, 34)); |
169 | print "not " |
170 | unless @t == 2 and (($t[0] == 12 and $t[1] == 34) or ($t =~ /[nv]/i)); |
171 | print "ok ", $test++, "\n"; |
172 | } |
9d116dd7 |
173 | |
eddc390b |
174 | # 57..60: uuencode/decode |
9d116dd7 |
175 | |
ef54e1a4 |
176 | # Note that first uuencoding known 'text' data and then checking the |
177 | # binary values of the uuencoded version would not be portable between |
178 | # character sets. Uuencoding is meant for encoding binary data, not |
179 | # text data. |
180 | |
342930fb |
181 | $in = pack 'C*', 0 .. 255; |
ba1ac976 |
182 | |
183 | # just to be anal, we do some random tr/`/ / |
9d116dd7 |
184 | $uu = <<'EOUU'; |
ba1ac976 |
185 | M` $"`P0%!@<("0H+# T.#Q`1$A,4%187&!D:&QP='A\@(2(C)"4F)R@I*BLL |
9d116dd7 |
186 | M+2XO,#$R,S0U-C<X.3H[/#T^/T!!0D-$149'2$E*2TQ-3D]045)35%565UA9 |
187 | M6EM<75Y?8&%B8V1E9F=H:6IK;&UN;W!Q<G-T=79W>'EZ>WQ]?G^`@8*#A(6& |
188 | MAXB)BHN,C8Z/D)&2DY25EI>8F9J;G)V>GZ"AHJ.DI::GJ*FJJZRMKJ^PL;*S |
189 | MM+6VM[BYNKN\O;Z_P,'"P\3%QL?(R<K+S,W.S]#1TM/4U=;7V-G:V]S=WM_@ |
ba1ac976 |
190 | ?X>+CY.7FY^CIZNOL[>[O\/'R\_3U]O?X^?K[_/W^_P ` |
9d116dd7 |
191 | EOUU |
192 | |
ba1ac976 |
193 | $_ = $uu; |
194 | tr/ /`/; |
195 | print "not " unless pack('u', $in) eq $_; |
9d116dd7 |
196 | print "ok ", $test++, "\n"; |
197 | |
198 | print "not " unless unpack('u', $uu) eq $in; |
199 | print "ok ", $test++, "\n"; |
200 | |
eddc390b |
201 | $in = "\x1f\x8b\x08\x08\x58\xdc\xc4\x35\x02\x03\x4a\x41\x50\x55\x00\xf3\x2a\x2d\x2e\x51\x48\xcc\xcb\x2f\xc9\x48\x2d\x52\x08\x48\x2d\xca\x51\x28\x2d\x4d\xce\x4f\x49\x2d\xe2\x02\x00\x64\x66\x60\x5c\x1a\x00\x00\x00"; |
202 | $uu = <<'EOUU'; |
203 | M'XL("%C<Q#4"`TI!4%4`\RHM+E%(S,LOR4@M4@A(+<I1*"U-SD])+>("`&1F |
204 | &8%P:```` |
205 | EOUU |
206 | |
207 | print "not " unless unpack('u', $uu) eq $in; |
208 | print "ok ", $test++, "\n"; |
209 | |
210 | # 60 identical to 59 except that backquotes have been changed to spaces |
211 | |
212 | $uu = <<'EOUU'; |
213 | M'XL("%C<Q#4" TI!4%4 \RHM+E%(S,LOR4@M4@A(+<I1*"U-SD])+>(" &1F |
214 | &8%P: |
215 | EOUU |
216 | |
217 | print "not " unless unpack('u', $uu) eq $in; |
218 | print "ok ", $test++, "\n"; |
219 | |
2b6c5635 |
220 | # 61..73: test the ascii template types (A, a, Z) |
5a929a98 |
221 | |
222 | print "not " unless pack('A*', "foo\0bar\0 ") eq "foo\0bar\0 "; |
223 | print "ok ", $test++, "\n"; |
224 | |
225 | print "not " unless pack('A11', "foo\0bar\0 ") eq "foo\0bar\0 "; |
226 | print "ok ", $test++, "\n"; |
227 | |
228 | print "not " unless unpack('A*', "foo\0bar \0") eq "foo\0bar"; |
229 | print "ok ", $test++, "\n"; |
230 | |
231 | print "not " unless unpack('A8', "foo\0bar \0") eq "foo\0bar"; |
232 | print "ok ", $test++, "\n"; |
233 | |
234 | print "not " unless pack('a*', "foo\0bar\0 ") eq "foo\0bar\0 "; |
235 | print "ok ", $test++, "\n"; |
236 | |
237 | print "not " unless pack('a11', "foo\0bar\0 ") eq "foo\0bar\0 \0\0"; |
238 | print "ok ", $test++, "\n"; |
239 | |
240 | print "not " unless unpack('a*', "foo\0bar \0") eq "foo\0bar \0"; |
241 | print "ok ", $test++, "\n"; |
242 | |
243 | print "not " unless unpack('a8', "foo\0bar \0") eq "foo\0bar "; |
244 | print "ok ", $test++, "\n"; |
245 | |
2b6c5635 |
246 | print "not " unless pack('Z*', "foo\0bar\0 ") eq "foo\0bar\0 \0"; |
5a929a98 |
247 | print "ok ", $test++, "\n"; |
248 | |
249 | print "not " unless pack('Z11', "foo\0bar\0 ") eq "foo\0bar\0 \0\0"; |
250 | print "ok ", $test++, "\n"; |
251 | |
2b6c5635 |
252 | print "not " unless pack('Z3', "foo") eq "fo\0"; |
253 | print "ok ", $test++, "\n"; |
254 | |
5a929a98 |
255 | print "not " unless unpack('Z*', "foo\0bar \0") eq "foo"; |
256 | print "ok ", $test++, "\n"; |
257 | |
258 | print "not " unless unpack('Z8', "foo\0bar \0") eq "foo"; |
259 | print "ok ", $test++, "\n"; |
260 | |
2b6c5635 |
261 | # 74..79: packing native shorts/ints/longs |
ef54e1a4 |
262 | |
f61d411c |
263 | print "not " unless length(pack("s!", 0)) == $Config{shortsize}; |
ef54e1a4 |
264 | print "ok ", $test++, "\n"; |
265 | |
f61d411c |
266 | print "not " unless length(pack("i!", 0)) == $Config{intsize}; |
ef54e1a4 |
267 | print "ok ", $test++, "\n"; |
268 | |
f61d411c |
269 | print "not " unless length(pack("l!", 0)) == $Config{longsize}; |
ef54e1a4 |
270 | print "ok ", $test++, "\n"; |
271 | |
f61d411c |
272 | print "not " unless length(pack("s!", 0)) <= length(pack("i!", 0)); |
ef54e1a4 |
273 | print "ok ", $test++, "\n"; |
274 | |
f61d411c |
275 | print "not " unless length(pack("i!", 0)) <= length(pack("l!", 0)); |
ef54e1a4 |
276 | print "ok ", $test++, "\n"; |
277 | |
f61d411c |
278 | print "not " unless length(pack("i!", 0)) == length(pack("i", 0)); |
ef54e1a4 |
279 | print "ok ", $test++, "\n"; |
280 | |
2b6c5635 |
281 | # 80..139: pack <-> unpack bijectionism |
726ea183 |
282 | |
2b6c5635 |
283 | # 80.. 84 c |
d99ad34e |
284 | foreach my $c (-128, -1, 0, 1, 127) { |
285 | print "not " unless unpack("c", pack("c", $c)) == $c; |
286 | print "ok ", $test++, "\n"; |
287 | } |
9de70c85 |
288 | |
2b6c5635 |
289 | # 85.. 89: C |
d99ad34e |
290 | foreach my $C (0, 1, 127, 128, 255) { |
291 | print "not " unless unpack("C", pack("C", $C)) == $C; |
292 | print "ok ", $test++, "\n"; |
293 | } |
726ea183 |
294 | |
2b6c5635 |
295 | # 90.. 94: s |
d99ad34e |
296 | foreach my $s (-32768, -1, 0, 1, 32767) { |
297 | print "not " unless unpack("s", pack("s", $s)) == $s; |
298 | print "ok ", $test++, "\n"; |
299 | } |
726ea183 |
300 | |
2b6c5635 |
301 | # 95.. 99: S |
d99ad34e |
302 | foreach my $S (0, 1, 32767, 32768, 65535) { |
303 | print "not " unless unpack("S", pack("S", $S)) == $S; |
304 | print "ok ", $test++, "\n"; |
305 | } |
726ea183 |
306 | |
2b6c5635 |
307 | # 100..104: i |
d99ad34e |
308 | foreach my $i (-2147483648, -1, 0, 1, 2147483647) { |
309 | print "not " unless unpack("i", pack("i", $i)) == $i; |
310 | print "ok ", $test++, "\n"; |
311 | } |
726ea183 |
312 | |
2b6c5635 |
313 | # 105..109: I |
d99ad34e |
314 | foreach my $I (0, 1, 2147483647, 2147483648, 4294967295) { |
315 | print "not " unless unpack("I", pack("I", $I)) == $I; |
316 | print "ok ", $test++, "\n"; |
317 | } |
726ea183 |
318 | |
2b6c5635 |
319 | # 110..114: l |
d99ad34e |
320 | foreach my $l (-2147483648, -1, 0, 1, 2147483647) { |
321 | print "not " unless unpack("l", pack("l", $l)) == $l; |
322 | print "ok ", $test++, "\n"; |
323 | } |
726ea183 |
324 | |
2b6c5635 |
325 | # 115..119: L |
d99ad34e |
326 | foreach my $L (0, 1, 2147483647, 2147483648, 4294967295) { |
327 | print "not " unless unpack("L", pack("L", $L)) == $L; |
328 | print "ok ", $test++, "\n"; |
329 | } |
726ea183 |
330 | |
2b6c5635 |
331 | # 120..124: n |
d99ad34e |
332 | foreach my $n (0, 1, 32767, 32768, 65535) { |
333 | print "not " unless unpack("n", pack("n", $n)) == $n; |
334 | print "ok ", $test++, "\n"; |
335 | } |
726ea183 |
336 | |
2b6c5635 |
337 | # 125..129: v |
d99ad34e |
338 | foreach my $v (0, 1, 32767, 32768, 65535) { |
339 | print "not " unless unpack("v", pack("v", $v)) == $v; |
340 | print "ok ", $test++, "\n"; |
341 | } |
726ea183 |
342 | |
2b6c5635 |
343 | # 130..134: N |
d99ad34e |
344 | foreach my $N (0, 1, 2147483647, 2147483648, 4294967295) { |
345 | print "not " unless unpack("N", pack("N", $N)) == $N; |
346 | print "ok ", $test++, "\n"; |
347 | } |
726ea183 |
348 | |
2b6c5635 |
349 | # 135..139: V |
d99ad34e |
350 | foreach my $V (0, 1, 2147483647, 2147483648, 4294967295) { |
351 | print "not " unless unpack("V", pack("V", $V)) == $V; |
352 | print "ok ", $test++, "\n"; |
353 | } |
726ea183 |
354 | |
2b6c5635 |
355 | # 140..143: pack nvNV byteorders |
726ea183 |
356 | |
d99ad34e |
357 | print "not " unless pack("n", 0xdead) eq "\xde\xad"; |
726ea183 |
358 | print "ok ", $test++, "\n"; |
359 | |
d99ad34e |
360 | print "not " unless pack("v", 0xdead) eq "\xad\xde"; |
c67712b2 |
361 | print "ok ", $test++, "\n"; |
726ea183 |
362 | |
d99ad34e |
363 | print "not " unless pack("N", 0xdeadbeef) eq "\xde\xad\xbe\xef"; |
726ea183 |
364 | print "ok ", $test++, "\n"; |
365 | |
d99ad34e |
366 | print "not " unless pack("V", 0xdeadbeef) eq "\xef\xbe\xad\xde"; |
c67712b2 |
367 | print "ok ", $test++, "\n"; |
43192e07 |
368 | |
4b5b2118 |
369 | # 144..152: / |
43192e07 |
370 | |
371 | my $z; |
17f4a12d |
372 | eval { ($x) = unpack '/a*','hello' }; |
43192e07 |
373 | print 'not ' unless $@; print "ok $test\n"; $test++; |
17f4a12d |
374 | eval { ($z,$x,$y) = unpack 'a3/A C/a* C/Z', "003ok \003yes\004z\000abc" }; |
43192e07 |
375 | print $@ eq '' && $z eq 'ok' ? "ok $test\n" : "not ok $test\n"; $test++; |
376 | print $@ eq '' && $x eq 'yes' ? "ok $test\n" : "not ok $test\n"; $test++; |
377 | print $@ eq '' && $y eq 'z' ? "ok $test\n" : "not ok $test\n"; $test++; |
378 | |
17f4a12d |
379 | eval { ($x) = pack '/a*','hello' }; |
43192e07 |
380 | print 'not ' unless $@; print "ok $test\n"; $test++; |
3399f041 |
381 | $z = pack 'n/a* N/Z* w/A*','string','hi there ','etc'; |
382 | print 'not ' unless $z eq "\000\006string\0\0\0\012hi there \000\003etc"; |
383 | print "ok $test\n"; $test++; |
43192e07 |
384 | |
4b5b2118 |
385 | eval { ($x) = unpack 'a/a*/a*', '212ab345678901234567' }; |
386 | print $@ eq '' && $x eq 'ab3456789012' ? "ok $test\n" : "#$x,$@\nnot ok $test\n"; |
387 | $test++; |
388 | |
389 | eval { ($x) = unpack 'a/a*/a*', '3012ab345678901234567' }; |
390 | print $@ eq '' && $x eq 'ab3456789012' ? "ok $test\n" : "not ok $test\n"; |
391 | $test++; |
392 | |
393 | eval { ($x) = unpack 'a/a*/b*', '212ab' }; |
ee50adbe |
394 | my $expected_x = '100001100100'; |
395 | if ($Config{ebcdic} eq 'define') { $expected_x = '100000010100'; } |
396 | print $@ eq '' && $x eq $expected_x ? "ok $test\n" : "#$x,$@\nnot ok $test\n"; |
4b5b2118 |
397 | $test++; |
398 | |
399 | # 153..156: / with # |
17f4a12d |
400 | |
401 | eval { ($z,$x,$y) = unpack <<EOU, "003ok \003yes\004z\000abc" }; |
402 | a3/A # Count in ASCII |
403 | C/a* # Count in a C char |
404 | C/Z # Count in a C char but skip after \0 |
405 | EOU |
406 | print $@ eq '' && $z eq 'ok' ? "ok $test\n" : "not ok $test\n"; $test++; |
407 | print $@ eq '' && $x eq 'yes' ? "ok $test\n" : "not ok $test\n"; $test++; |
408 | print $@ eq '' && $y eq 'z' ? "ok $test\n" : "not ok $test\n"; $test++; |
409 | |
410 | $z = pack <<EOP,'string','etc'; |
411 | n/a* # Count as network short |
412 | w/A* # Count a BER integer |
413 | EOP |
414 | print 'not ' unless $z eq "\000\006string\003etc"; print "ok $test\n"; $test++; |
036b4402 |
415 | |
11882669 |
416 | # 157..169: ??? |
417 | |
036b4402 |
418 | print 'not ' unless "1.20.300.4000" eq sprintf "%vd", pack("U*",1,20,300,4000); |
419 | print "ok $test\n"; $test++; |
420 | print 'not ' unless "1.20.300.4000" eq |
421 | sprintf "%vd", pack(" U*",1,20,300,4000); |
422 | print "ok $test\n"; $test++; |
423 | print 'not ' unless v1.20.300.4000 ne |
424 | sprintf "%vd", pack("C0U*",1,20,300,4000); |
425 | print "ok $test\n"; $test++; |
426 | |
11882669 |
427 | # 160: unpack("C") and ord() equivalence for Unicode |
428 | |
93dfd55e |
429 | print "not " unless unpack("C", chr(0x100)) eq ord(chr(0x100)) && |
430 | ord(chr(0x100)) == 0x100; |
11882669 |
431 | print "ok $test\n"; $test++; |
432 | |
433 | # 161: use bytes + unpack C == UTF-8 unraveling |
434 | |
435 | { |
436 | use bytes; |
437 | my @bytes = unpack("C*", pack("U", 0x100)); |
438 | print "not " unless "@bytes" eq "196 128"; |
439 | print "ok $test\n"; $test++; |
440 | } |
441 | |
442 | # 162: pack C > 255 |
443 | |
444 | print "not " unless ord(pack("C", 0x100)) == 0x100; |
445 | print "ok $test\n"; $test++; |
446 | |
447 | # 163: pack C > 255 + use bytes == wraparound |
448 | |
449 | { |
450 | use bytes; |
451 | |
452 | print "not " unless ord(pack("C", 0x100 + 0xab)) == 0xab; |
453 | print "ok $test\n"; $test++; |
454 | } |
455 | |