let msg_prefix = "*** REGTEST *** "
let print_msg s = prerr_endline (msg_prefix ^ s)
-type state = Term | ETerm | EType | EReduced
+type state = Term | EMetasenv | ETerm | EType | EReduced
(* regtest file format
* < cic term in concrete syntax >
type regtest = {
term: string; (* raw cic term *)
+ emetasenv : string; (* expected metasenv *)
eterm: string; (* expected term *)
etype: string; (* expected type *)
ereduced: string; (* expected reduced term *)
output_string oc
(String.concat ""
[ test.term; rawsep ^ "\n";
+ test.emetasenv; rawsep ^ "\n";
test.eterm; rawsep ^ "\n";
test.etype; rawsep ^ "\n";
test.ereduced ]);
let parse_regtest =
let term = Buffer.create 1024 in (* raw term *)
+ let emetasenv = Buffer.create 1024 in (* expected metasenv *)
let eterm = Buffer.create 1024 in (* raw expected term *)
let etype = Buffer.create 1024 in (* raw expected type *)
let ereduced = Buffer.create 1024 in (* raw expected reducted term *)
let state = ref Term in
let bump_state () =
match !state with
- | Term -> state := ETerm
+ | Term -> state := EMetasenv
+ | EMetasenv -> state := ETerm
| ETerm -> state := EType
| EType -> state := EReduced
| EReduced -> assert false
in
let buffer_of_state = function
- | Term -> term | ETerm -> eterm | EType -> etype | EReduced -> ereduced
+ | Term -> term | EMetasenv -> emetasenv | ETerm -> eterm | EType -> etype | EReduced -> ereduced
in
fun fname ->
state := Term;
- Buffer.clear term; Buffer.clear eterm; Buffer.clear etype;
- Buffer.clear ereduced;
+ Buffer.clear term; Buffer.clear emetasenv; Buffer.clear eterm;
+ Buffer.clear etype; Buffer.clear ereduced;
let ic = open_in fname in
(try
while true do
| l -> Buffer.add_string (buffer_of_state !state) (line ^ "\n")
done
with End_of_file -> ());
+prerr_endline ("@@@ " ^ Buffer.contents emetasenv);
{ term = Buffer.contents term;
+ emetasenv = Buffer.contents emetasenv;
eterm = Buffer.contents eterm;
etype = Buffer.contents etype;
ereduced = Buffer.contents ereduced }
let test_this raw_term =
let empty_context = [] in
let (metasenv, cic_term) = BatchParser.parse raw_term in
- let cic_type = CicTypeChecker.type_of_aux' metasenv empty_context cic_term in
- let cic_reduced = CicReduction.whd empty_context cic_term in
+ let etype =
+ try
+ CicPp.ppterm (CicTypeChecker.type_of_aux' metasenv empty_context cic_term)
+ with
+ _ -> "MALFORMED"
+ in
+ let ereduced =
+ try
+ CicPp.ppterm (CicReduction.whd empty_context cic_term)
+ with
+ _ -> "MALFORMED"
+ in
{
term = raw_term; (* useless *)
+ emetasenv = CicMetaSubst.ppmetasenv metasenv [] ^ "\n";
eterm = CicPp.ppterm cic_term ^ "\n";
- etype = CicPp.ppterm cic_type ^ "\n";
- ereduced = CicPp.ppterm cic_reduced ^ "\n";
+ etype = etype ^ "\n";
+ ereduced = ereduced ^ "\n";
}
let main () =