diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1999-10-12 05:24:39 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1999-10-12 05:24:39 +0000 |
commit | 4b5b211868f30398434fa5a1a79573d04770ccf2 (patch) | |
tree | e25bc5f39337ac3c82aa7e96f152533cb30ad7df /t/op/pack.t | |
parent | ce70748ce2d3d9defeea8ef8502d3c62a671c707 (diff) | |
download | perl-4b5b211868f30398434fa5a1a79573d04770ccf2.tar.gz |
allow any unpack specifier to take a count via '/'
(from Ilya Zakharevich)
p4raw-id: //depot/perl@4352
Diffstat (limited to 't/op/pack.t')
-rwxr-xr-x | t/op/pack.t | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/t/op/pack.t b/t/op/pack.t index 9b96289497..11ada3905d 100755 --- a/t/op/pack.t +++ b/t/op/pack.t @@ -6,7 +6,7 @@ BEGIN { require Config; import Config; } -print "1..153\n"; +print "1..156\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 @@ -357,7 +357,7 @@ print "ok ", $test++, "\n"; print "not " unless pack("V", 0xdeadbeef) eq "\xef\xbe\xad\xde"; print "ok ", $test++, "\n"; -# 144..149: / +# 144..152: / my $z; eval { ($x) = unpack '/a*','hello' }; @@ -372,7 +372,19 @@ 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++; -# 150..153: / with # +eval { ($x) = unpack 'a/a*/a*', '212ab345678901234567' }; +print $@ eq '' && $x eq 'ab3456789012' ? "ok $test\n" : "#$x,$@\nnot ok $test\n"; +$test++; + +eval { ($x) = unpack 'a/a*/a*', '3012ab345678901234567' }; +print $@ eq '' && $x eq 'ab3456789012' ? "ok $test\n" : "not ok $test\n"; +$test++; + +eval { ($x) = unpack 'a/a*/b*', '212ab' }; +print $@ eq '' && $x eq '100001100100' ? "ok $test\n" : "#$x,$@\nnot ok $test\n"; +$test++; + +# 153..156: / with # eval { ($z,$x,$y) = unpack <<EOU, "003ok \003yes\004z\000abc" }; a3/A # Count in ASCII |