Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

nil unpacks to Any, not Nil

  • Loading branch information...
commit 1dcb3973b5c2f5144e6ae8cd88e06612bc1d077a 1 parent 31c7bfd
Tomoki Aonuma authored
8 lib/MessagePack.pm6
View
@@ -4,9 +4,13 @@ module MessagePack;
use MessagePack::Unpacker;
-sub unpack($str) {
+multi sub unpack(Str $str) {
MessagePack::Unpacker.unpack($str);
}
-# vim: ft=perl6 :
+multi sub from-msgpack(Str $str) is export {
+ MessagePack::Unpacker.unpack($str);
+}
+
+# vim: ft=perl6
9 lib/MessagePack/Unpacker.pm6
View
@@ -23,7 +23,7 @@ class MessagePack::Unpacker {
has $!str;
my %unpack-for-type = (
- 0xc0 => { Nil },
+ 0xc0 => { Any },
0xc2 => { False },
0xc3 => { True },
0xca => { $_!unpack-float },
@@ -44,12 +44,8 @@ class MessagePack::Unpacker {
0xdf => { $_!unpack-map( pairs => $_!unpack-uint32) },
);
- submethod BUILD($str) {
- $!str = $str but Readable;
- }
-
method new($str) {
- self.bless(*, :$str);
+ self.bless(*, str => $str but Readable);
}
# Class method
@@ -176,4 +172,3 @@ class MessagePack::Unpacker {
}
# vim: ft=perl6
-
2  t/00-unpack.t
View
@@ -48,7 +48,7 @@ is .unpack("\xd3\x7f" ~ "\xff" x 7), 0x7fff_ffff_ffff_ffff, q[int64];
is .unpack("\xd3" ~ "\xff" x 8), -0x0000_0000_0000_0001, q[int64];
is .unpack("\xd3\x80" ~ "\x00" x 7), -0x8000_0000_0000_0000, q[int64];
-is .unpack("\xc0"), Nil, q[nil];
+is .unpack("\xc0"), Any, q[nil];
is .unpack("\xc2"), False, q[false];
is .unpack("\xc3"), True, q[true];
Please sign in to comment.
Something went wrong with that request. Please try again.