| 1 |
Require Import TestSuite.admit. |
| 2 |
|
| 3 |
(** [not tac] is equivalent to [fail tac "succeeds"] if [tac] succeeds, and is equivalent to [idtac] if [tac] fails *) |
| 4 |
Tactic Notation "not" tactic3(tac) := |
| 5 |
(tryif tac then fail 0 tac "succeeds" else idtac); (* error if the tactic solved all goals *) []. |
| 6 |
|
| 7 |
(** Test if a tactic succeeds, but always roll-back the results *) |
| 8 |
Tactic Notation "test" tactic3(tac) := tryif not tac then fail 0 tac "fails" else idtac. |
| 9 |
|
| 10 |
Goal Set. |
| 11 |
Proof. |
| 12 |
not fail. |
| 13 |
not not idtac. |
| 14 |
not fail 0. |
| 15 |
(** Would be nice if we could get [not fail 1] to pass, maybe *) |
| 16 |
not not admit. |
| 17 |
not not test admit. |
| 18 |
not progress test admit. |
| 19 |
(* test grouping *) |
| 20 |
not (not idtac; fail). |
| 21 |
assert True. |
| 22 |
all:not fail. |
| 23 |
2:not fail. |
| 24 |
all:admit. |
| 25 |
Defined. |
| 26 |
|
| 27 |
Goal Set. |
| 28 |
Proof. |
| 29 |
test idtac. |
| 30 |
test try fail. |
| 31 |
test admit. |
| 32 |
test match goal with |- Set => idtac end. |
| 33 |
test (idtac; match goal with |- Set => idtac end). |
| 34 |
(* test grouping *) |
| 35 |
first [ (test idtac; fail); fail 1 | idtac ]. |
| 36 |
try test fail. |
| 37 |
try test test fail. |
| 38 |
test test idtac. |
| 39 |
test test admit. |
| 40 |
Fail test fail. |
| 41 |
test (idtac; []). |
| 42 |
test (assert True; [|]). |
| 43 |
(* would be nice, perhaps, if we could catch [fail 1] and not just [fail 0] this *) |
| 44 |
try ((test fail); fail 1). |
| 45 |
assert True. |
| 46 |
all:test idtac. |
| 47 |
all:test admit. |
| 48 |
2:test admit. |
| 49 |
all:admit. |
| 50 |
Defined. |