aboutsummaryrefslogtreecommitdiff
path: root/test-suite/ltac2
diff options
context:
space:
mode:
Diffstat (limited to 'test-suite/ltac2')
-rw-r--r--test-suite/ltac2/evar.v17
-rw-r--r--test-suite/ltac2/ind.v25
-rw-r--r--test-suite/ltac2/rebind.v4
-rw-r--r--test-suite/ltac2/syntax_cast.v14
4 files changed, 57 insertions, 3 deletions
diff --git a/test-suite/ltac2/evar.v b/test-suite/ltac2/evar.v
new file mode 100644
index 0000000000..2c82673edd
--- /dev/null
+++ b/test-suite/ltac2/evar.v
@@ -0,0 +1,17 @@
+Require Import Ltac2.Ltac2.
+
+Goal exists (a: nat), a = 1.
+Proof.
+ match! goal with
+ | [ |- ?g ] => Control.assert_false (Constr.has_evar g)
+ end.
+ eexists.
+ match! goal with
+ | [ |- ?g ] => Control.assert_true (Constr.has_evar g)
+ end.
+ match! goal with
+ | [ |- ?x = ?y ] =>
+ Control.assert_true (Constr.is_evar x);
+ Control.assert_false (Constr.is_evar y)
+ end.
+Abort.
diff --git a/test-suite/ltac2/ind.v b/test-suite/ltac2/ind.v
new file mode 100644
index 0000000000..6f7352d224
--- /dev/null
+++ b/test-suite/ltac2/ind.v
@@ -0,0 +1,25 @@
+Require Import Ltac2.Ltac2.
+Require Import Ltac2.Option.
+
+Ltac2 Eval
+ let nat := Option.get (Env.get [@Coq; @Init; @Datatypes; @nat]) in
+ let nat := match nat with
+ | Std.IndRef nat => nat
+ | _ => Control.throw Not_found
+ end in
+ let data := Ind.data nat in
+ (* Check that there is only one inductive in the block *)
+ let ntypes := Ind.nblocks data in
+ let () := if Int.equal ntypes 1 then () else Control.throw Not_found in
+ let nat' := Ind.repr (Ind.get_block data 0) in
+ (* Check it corresponds *)
+ let () := if Ind.equal nat nat' then () else Control.throw Not_found in
+ let () := if Int.equal (Ind.index nat) 0 then () else Control.throw Not_found in
+ (* Check the number of constructors *)
+ let nconstr := Ind.nconstructors data in
+ let () := if Int.equal nconstr 2 then () else Control.throw Not_found in
+ (* Create a fresh instance *)
+ let s := Ind.get_constructor data 1 in
+ let s := Env.instantiate (Std.ConstructRef s) in
+ constr:($s 0)
+.
diff --git a/test-suite/ltac2/rebind.v b/test-suite/ltac2/rebind.v
index 7b3a460c8c..9108871e28 100644
--- a/test-suite/ltac2/rebind.v
+++ b/test-suite/ltac2/rebind.v
@@ -26,12 +26,10 @@ Ltac2 rec nat_eq n m :=
| S n => match m with | O => false | S m => nat_eq n m end
end.
-Ltac2 Type exn ::= [ Assertion_failed ].
-
Ltac2 assert_eq n m :=
match nat_eq n m with
| true => ()
- | false => Control.throw Assertion_failed end.
+ | false => Control.throw Assertion_failure end.
Ltac2 mutable x := O.
Ltac2 y := x.
diff --git a/test-suite/ltac2/syntax_cast.v b/test-suite/ltac2/syntax_cast.v
new file mode 100644
index 0000000000..f62d49173d
--- /dev/null
+++ b/test-suite/ltac2/syntax_cast.v
@@ -0,0 +1,14 @@
+Require Import Ltac2.Ltac2.
+
+Ltac2 foo0 x y : unit := ().
+Ltac2 foo1 : unit := ().
+Fail Ltac2 foo2 : unit -> unit := ().
+Ltac2 foo3 : unit -> unit := fun (_ : unit) => ().
+
+Ltac2 bar0 := fun x y : unit => ().
+Fail Ltac2 bar1 := fun x : unit => 0.
+Ltac2 bar2 := fun x : unit list => [].
+
+Ltac2 qux0 := let x : unit := () in ().
+Ltac2 qux1 () := let x y z : unit := () in x 0 "".
+Fail Ltac2 qux2 := let x : unit -> unit := () in ().