Skip to content

Commit 033b4f5

Browse files
committed
Printing <PASSED::> and <FAILED::> + CWGroup and CWEndGroup
1 parent 887f7bb commit 033b4f5

File tree

6 files changed

+43
-16
lines changed

6 files changed

+43
-16
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
\#*
12
.DS_Store
23
*~
34
.vscode/

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,21 @@ Now run `make`.
1313

1414
Run `make .merlin` to create the `.merlin` file.
1515

16-
## Examples
16+
## New Vernacular Commands
1717

18-
A new vernacular command `CWTest qualid Assumes qualid*` is defined.
18+
A new vernacular command `CWTest msg? qualid Assumes qualid*` is defined.
1919
This command fails if the tested `qualid` depends on an axiom which is not listed
2020
after `Assumes`:
2121

2222
```coq
23-
CWTest lemma Assumes proof_irrelevance functional_extensionality.
23+
CWTest "Testing lemma" lemma Assumes proof_irrelevance functional_extensionality.
2424
```
2525

26+
The string argument after `CWTest` (`msg`) is optional.
27+
28+
Two other commands are `CWGroup msg` and `CWEndGroup`.
29+
30+
## Examples
31+
2632
See [theories/Demo.v](theories/Demo.v) and [theories/Demo2.v](theories/Demo2.v)
2733
for more examples.

src/coq_cw.ml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ let extract_axioms s =
1212
Printer.ContextObjectMap.fold fold s []
1313

1414
(* TODO: compare axiom names (constants) also *)
15-
let test_assumptions env sigma s ax_tys =
15+
let test_assumptions msg env sigma s ax_tys =
1616
let unify ty1 ty2 =
1717
match Reductionops.infer_conv env sigma ty1 ty2 with
1818
| Some _ -> true
@@ -23,7 +23,10 @@ let test_assumptions env sigma s ax_tys =
2323
| Printer.Axiom _ ->
2424
let ety = EConstr.of_constr ty in
2525
if List.exists (unify ety) ax_tys then ()
26-
else CErrors.user_err (str "Axiom: " ++ Printer.pr_econstr_env env sigma ety)
26+
else begin
27+
Feedback.msg_notice (str ("\n<FAILED::> " ^ msg ^ "\n"));
28+
CErrors.user_err (str "Axiom: " ++ Printer.pr_econstr_env env sigma ety)
29+
end
2730
| _ -> ()
2831
in
2932
Printer.ContextObjectMap.iter iter s
@@ -35,7 +38,7 @@ let locate r =
3538
(gr, Globnames.printable_constr_of_global gr)
3639
with Not_found -> CErrors.user_err (str "Not found: " ++ Libnames.pr_qualid r)
3740

38-
let test c_ref ax_refs =
41+
let test ?(msg = "Axioms") c_ref ax_refs =
3942
let env = Global.env() in
4043
let sigma = Evd.from_env env in
4144
let (gr, cstr) = locate c_ref in
@@ -47,5 +50,5 @@ let test c_ref ax_refs =
4750
(fun (sigma, tys) (_, c) ->
4851
let sigma, ty = Typing.type_of env sigma (EConstr.of_constr c) in
4952
sigma, ty :: tys) (sigma, []) ax_grs_cstrs in
50-
test_assumptions env sigma assumptions ax_tys;
51-
Feedback.msg_notice (str "SUCCESS")
53+
test_assumptions msg env sigma assumptions ax_tys;
54+
Feedback.msg_notice (str ("\n<PASSED::> " ^ msg ^ "\n"))

src/coq_cw.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
val test : Libnames.qualid -> Libnames.qualid list -> unit
1+
val test : ?msg:string -> Libnames.qualid -> Libnames.qualid list -> unit

src/g_coq_cw.ml4

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,22 @@
11
DECLARE PLUGIN "coq_cw_plugin"
22

3+
open Pp
34
open Stdarg
45

56
VERNAC COMMAND EXTEND CWTest CLASSIFIED AS QUERY
6-
| [ "CWTest" ref(e) "Assumes" ref_list(axioms)] -> [
7-
Coq_cw.test e axioms
7+
| [ "CWTest" string_opt(msg) ref(e) "Assumes" ref_list(axioms)] -> [
8+
Coq_cw.test ?msg e axioms
89
]
9-
END
10+
END
11+
12+
VERNAC COMMAND EXTEND CWGroup CLASSIFIED AS QUERY
13+
| [ "CWGroup" string(msg)] -> [
14+
Feedback.msg_notice (str ("\n<DESCRIBE::> " ^ msg ^ "\n"))
15+
]
16+
END
17+
18+
VERNAC COMMAND EXTEND CWEndGroup CLASSIFIED AS QUERY
19+
| [ "CWEndGroup"] -> [
20+
Feedback.msg_notice (str "\n<COMPLETEDIN::>\n")
21+
]
22+
END

theories/Demo.v

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@ Lemma lemma3 : (2 = 3) \/ ~(2 = 3).
1616
Proof.
1717
apply classic.
1818
Qed.
19-
19+
20+
CWGroup "Assumption Tests".
21+
2022
Fail CWTest lemma1 Assumes.
2123
CWTest lemma1 Assumes my_ax.
2224
Fail CWTest lemma1 Assumes classic.
23-
CWTest lemma1 Assumes lemma2.
25+
CWTest "lemma1" lemma1 Assumes lemma2.
2426
CWTest lemma1 Assumes classic my_ax.
25-
CWTest lemma2 Assumes my_ax.
27+
CWTest "lemma2" lemma2 Assumes my_ax.
2628

2729
CWTest lemma3 Assumes classic my_ax.
28-
Fail CWTest lemma3 Assumes my_ax.
30+
Fail CWTest lemma3 Assumes my_ax.
31+
32+
CWEndGroup.

0 commit comments

Comments
 (0)