1 (* RUN: cp %s %T/irreader.ml
2 * RUN: %ocamlcomp -g -warn-error A -package llvm.irreader -linkpkg %T/irreader.ml -o %t
7 (* Note: It takes several seconds for ocamlopt to link an executable with
8 libLLVMCore.a, so it's better to write a big test than a bunch of
14 let context = global_context ()
16 (* Tiny unit test framework - really just to help find which line is busted *)
17 let print_checkpoints = false
20 if print_checkpoints then
21 prerr_endline (name ^ ":");
25 Printexc.record_backtrace true
28 if not cond then failwith "insist"
31 (*===-- IR Reader ---------------------------------------------------------===*)
33 let test_irreader () =
35 let buf = MemoryBuffer.of_string "@foo = global i32 42" in
36 let m = parse_ir context buf in
37 match lookup_global "foo" m with
39 insist ((global_initializer foo) = (const_int (i32_type context) 42))
45 let buf = MemoryBuffer.of_string "@foo = global garble" in
47 ignore (parse_ir context buf);
49 with Llvm_irreader.Error _ ->
54 (*===-- Driver ------------------------------------------------------------===*)
57 suite "irreader" test_irreader