7 OUnit.assert_equal ?msg ~printer:Std.dump x y
9 module A = AbcIn.Make(struct
17 open_in_bin @@ Printf.sprintf "%s.abc" name in
18 A.of_bytes @@ BytesIn.of_channel ch
21 Stream.of_list @@ BytesOut.to_int_list xs
31 "cpool" >:: begin fun () ->
43 u30 2; u30 2; char 'h'; char 'i';
45 u30 3; u8 0x08; u30 1; u8 0x05; u30 1;
49 u30 2; u8 0x07; u30 1; u30 1
51 ok ~msg:"int" [1;2] cpool.int;
52 ok ~msg:"uint" [3] cpool.uint;
53 ok ~msg:"double" [4.2] cpool.double;
54 ok ~msg:"str" ["hi"] cpool.string;
55 ok ~msg:"ns" [Namespace 1; PrivateNamespace 1] cpool.namespace;
56 ok ~msg:"ns_set" [[1]] cpool.namespace_set;
57 ok ~msg:"mn" [QName(1,1)] cpool.multiname;
59 "method signature" >:: begin fun () ->
61 A.to_method_info @@ bytes [
62 (* param count *) u30 3;
63 (* return_type *) u30 1;
64 (* param types *) u30 1; u30 2; u30 3;
68 ok ~msg:"param" [1;2;3] m.params;
69 ok ~msg:"return" 1 m.return;
70 ok ~msg:"name" 4 m.method_name;
71 ok ~msg:"flags" [NeedArguments; NeedActivation] m.method_flags;
73 "metadata test" >:: begin fun () ->
75 A.to_metadata @@ bytes [
77 (* item_count *) u30 2;
78 (* items *) u30 1; u30 2; u30 3; u30 4
80 ok ~msg:"name" 0 metadata.metadata_name;
81 ok ~msg:"items" [(1,2);(3,4)] metadata.items
83 "trait" >:: begin fun () ->
88 (* slot_id *) u30 1; (* type_name *) u30 2; (* vindex *) u30 0;
90 ok ~msg:"name" 1 trait.trait_name;
91 ok ~msg:"data" (SlotTrait (1,2,0,0)) trait.data;
92 ok ~msg:"metadata" [] trait.trait_metadata
94 "instance" >:: begin fun () ->
96 A.to_instance @@ bytes [
101 (* interface *) u30 1;
103 (* trait_count *) u30 0;
105 ok 1 @@ instance.instance_name;
106 ok 2 @@ instance.super_name;
107 ok [Sealed] @@ instance.instance_flags;
108 ok [1] @@ instance.interfaces;
109 ok 3 @@ instance.iinit;
110 ok [] @@ instance.instance_traits
112 "class" >:: begin fun () ->
114 A.to_class @@ bytes [
116 (* trait_count *) u30 0;
121 "script" >:: begin fun () ->
123 A.to_script @@ bytes [
128 ok [] s.script_traits
130 "exception" >:: begin fun()->
132 A.to_exception @@ bytes [
139 ok ~msg:"from" 1 e.from_pos;
140 ok ~msg:"to" 2 e.to_pos;
141 ok ~msg:"target" 3 e.target;
142 ok ~msg:"type" 4 e.exception_type;
143 ok ~msg:"var" 5 e.var_name
145 "method body" >:: begin fun () ->
147 A.to_method_body @@ bytes [
149 (* max_stack *) u30 2;
150 (* local count *) u30 1;
151 (* init scope depth *) u30 0;
152 (* max scope depth *) u30 1;
154 (* exception *) u30 0;
155 (* tairt count *) u30 0
160 ok 0 m.init_scope_depth;
161 ok 1 m.max_scope_depth;
163 ok [] m.method_traits;
166 ]) +> run_test_tt_main