brintos

brintos / llvm-project-archived public Read only

0
0
Text · 960 B · 7a8955a Raw
34 lines · plain
1(* Tiny unit test framework - really just to help find which line is busted *)2let exit_status = ref 03 4let suite_name = ref ""5 6let group_name = ref ""7 8let case_num = ref 09 10let print_checkpoints = false11 12let group name =13  group_name := !suite_name ^ "/" ^ name;14  case_num := 0;15  if print_checkpoints then prerr_endline ("  " ^ name ^ "...")16 17let insist ?(exit_on_fail = false) cond =18  incr case_num;19  if not cond then exit_status := 10;20  ( match (print_checkpoints, cond) with21  | false, true -> ()22  | false, false ->23      prerr_endline24        ( "FAILED: " ^ !suite_name ^ "/" ^ !group_name ^ " #"25        ^ string_of_int !case_num )26  | true, true -> prerr_endline ("    " ^ string_of_int !case_num)27  | true, false -> prerr_endline ("    " ^ string_of_int !case_num ^ " FAIL") );28  if exit_on_fail && not cond then exit !exit_status else ()29 30let suite name f =31  suite_name := name;32  if print_checkpoints then prerr_endline (name ^ ":");33  f ()34