Skip to content

Commit

Permalink
test-omit-proofs: add tests for ProofGeneral#688 and ProofGeneral#687
Browse files Browse the repository at this point in the history
  • Loading branch information
hendriktews committed Mar 5, 2023
1 parent 60fde3a commit d0a9533
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
38 changes: 38 additions & 0 deletions ci/simple-tests/omit_test.v
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
(*
* Coq sources for test-omit-proofs.el
*
* Up to test marker 4 the sources are used for
* omit-proofs-omit-and-not-omit: The proof of the first lemma
* classic_excluded_middle should not be omitted, while the proof of the
* second classic_excluded_middle is.
*
* Lemma never_omit_hints is for test omit-proofs-never-omit-hints: Proofs
* containing commands should never be skipped (except for a few white-listed
* commands.
*
* Lemma never_omit_let is for test omit-proofs-never-omit-lets: Proofs of
* let-theorems should never be omitted.
*
*)


Definition classical_logic : Prop := forall(P : Prop), ~~P -> P.

Expand All @@ -23,3 +40,24 @@ Proof using.
Qed.

(* automatic test marker 4 *)

Lemma never_omit_hints : 1 + 1 = 2.
Proof using.
#[local] Hint Resolve classic_excluded_middle : core.
(* automatic test marker 5 *)
auto.
Qed.

(* automatic test marker 6 *)

Section let_test.

Let never_omit_let : 1 + 1 = 2.
Proof using.
(* automatic test marker 7 *)
auto.
Qed.

End let_test.

(* automatic test marker 8 *)
52 changes: 52 additions & 0 deletions ci/simple-tests/test-omit-proofs.el
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ If so, return the first non-nil value returned by PRED."
;; to process.
(accept-process-output nil 0.1)))

(defun reset-coq ()
"Reset Coq and Proof General.
Do `proof-shell-exit' to kill Coq and reset the locked region and
a lot of other internal state of Proof General. Used at the
beginning of the test when several tests work on the same Coq
source file."
(when (and (boundp 'proof-shell-buffer)
(buffer-live-p proof-shell-buffer))
(proof-shell-exit t)
(message "Coq and Proof General reseted")))

(defun overlay-less (a b)
"Compare two overlays.
Return t if overlay A has smaller size than overlay B and should
Expand Down Expand Up @@ -76,7 +87,9 @@ In particular, test that with proof-omit-proofs-option configured:
- stuff before the proof still has normal color "
(setq proof-omit-proofs-option t
proof-three-window-enable nil)
(reset-coq)
(find-file "omit_test.v")
(goto-char (point-min))

;; Check 1: check that the proof is valid and omit can be disabled
(message "1: check that the proof is valid and omit can be disabled")
Expand Down Expand Up @@ -152,3 +165,42 @@ In particular, test that with proof-omit-proofs-option configured:
(should (eq (first-overlay-face) 'proof-locked-face))
(should (search-forward "automatic test marker 2" nil t))
(should (eq (first-overlay-face) 'proof-locked-face)))

(ert-deftest omit-proofs-never-omit-hints ()
:expected-result :failed
"Test that proofs containing Hint are never omitted.
This test only checks that the face in the middle of the proof is
the normal `proof-locked-face'."
(setq proof-omit-proofs-option t
proof-three-window-enable nil)
(reset-coq)
(find-file "omit_test.v")
(goto-char (point-min))
;; Check that proofs with Hint commands are never omitted
(message "Check that proofs with Hint commands are never omitted")
(should (search-forward "automatic test marker 6" nil t))
(forward-line -1)
(proof-goto-point)
(wait-for-coq)
(should (search-backward "automatic test marker 5" nil t))
(should (eq (first-overlay-face) 'proof-locked-face)))


(ert-deftest omit-proofs-never-omit-lets ()
:expected-result :failed
"Test that proofs for Let local declarations are never omitted.
This test only checks that the face in the middle of the proof is
the normal `proof-locked-face'."
(setq proof-omit-proofs-option t
proof-three-window-enable nil)
(reset-coq)
(find-file "omit_test.v")
(goto-char (point-min))
;; Check that proofs for Let local declarations are never omitted.
(message "Check that proofs for Let local declarations are never omitted.")
(should (search-forward "automatic test marker 8" nil t))
(forward-line -1)
(proof-goto-point)
(wait-for-coq)
(should (search-backward "automatic test marker 7" nil t))
(should (eq (first-overlay-face) 'proof-locked-face)))

0 comments on commit d0a9533

Please sign in to comment.