2 struct Foo(name:Text, next:@Foo?=none)
4 enum MyEnum(Zero, One(x:Int), Two(x:Num, y:Text))
9 >> bytes : [Byte] = obj
10 >> roundtrip : Int64 = bytes
11 assert roundtrip == obj
15 >> bytes : [Byte] = obj
16 >> roundtrip : Int = bytes
17 assert roundtrip == obj
20 >> obj := 9999999999999999999999999999999999999999999999999999
21 >> bytes : [Byte] = obj
22 >> roundtrip : Int = bytes
23 assert roundtrip == obj
27 >> bytes : [Byte] = obj
28 >> roundtrip : Text = bytes
29 assert roundtrip == obj
32 >> obj := [Int64(10), Int64(20), Int64(30)].reversed()
33 >> bytes : [Byte] = obj
34 >> roundtrip : [Int64] = bytes
35 assert roundtrip == obj
39 >> bytes : [Byte] = obj
40 >> roundtrip : Bool = bytes
41 assert roundtrip == obj
45 >> bytes : [Byte] = obj
46 >> roundtrip : @[Int] = bytes
47 assert roundtrip != obj
48 assert roundtrip[] == obj[]
51 >> obj := {"A":10, "B":20; fallback={"C":30}}
52 >> bytes : [Byte] = obj
53 >> roundtrip : {Text:Int} = bytes
54 assert roundtrip == obj
55 assert roundtrip.fallback == obj.fallback
58 >> obj := @Foo("root")
59 >> obj.next = @Foo("abcdef", next=obj)
60 >> bytes : [Byte] = obj
61 >> roundtrip : @Foo = bytes
62 assert "$roundtrip" == "$obj"
65 >> obj := MyEnum.Two(123, "OKAY")
66 >> bytes : [Byte] = obj
67 >> roundtrip : MyEnum = bytes
68 assert roundtrip == obj
71 >> obj : Text? = "Hello"
72 >> bytes : [Byte] = obj
73 >> roundtrip : Text? = bytes
74 assert roundtrip == obj
78 >> bytes : [Byte] = obj
79 >> roundtrip : Num? = bytes
80 assert roundtrip == obj
83 cases := [0, -1, 1, 10, 100000, 999999999999999999999999999]
86 >> roundtrip : Int = bytes