16 let test_index value =
18 Cpool.add Cpool.empty value in
19 assert_equal 1 (Cpool.index cpool value)
22 assert_equal cpool (to_abc @@ Cpool.add Cpool.empty value)
29 test_index (`Int ~-42));
32 test_index (`UInt 42));
35 test_index (`String "foobar"));
38 test_index (`QName ((`Namespace "std"),"print"));
39 test_index (`Multiname ("print",[]));
40 test_index (`Multiname ("print",[`Namespace "std"])));
43 ok {empty_cpool with string=["foobar"]} (`String "foobar");
44 ok {empty_cpool with int=[30]} (`Int 30);
45 ok {empty_cpool with int=[~-30]} (`Int ~-30);
46 ok {empty_cpool with uint=[42]} (`UInt 42));
51 string = ["foobar"; "std"];
52 namespace = [AbcType.Namespace 2];
53 multiname = [QName (1,1)]}
54 (`QName (`Namespace "std","foobar")));
59 string = ["std";"foobar"];
60 namespace = [AbcType.Namespace 1];
62 multiname=[Multiname (2,1)]}
63 (`Multiname ("foobar",[`Namespace "std"])));
64 "cpool entry should be unique" >::
68 [`String "foo"; `String "bar"; `String "foo"] in
69 assert_equal 1 (Cpool.index cpool (`String "foo"));
70 assert_equal {empty_cpool with string=["foo";"bar"]} @@
72 "index is not change" >::
75 Cpool.add empty (`Int 42) in
77 Cpool.add cpool1 (`Int 42) in
79 (Cpool.index cpool1 @@ `Int 42)
80 (Cpool.index cpool2 @@ `Int 42))
81 ]) +> run_test_tt_main