summaryrefslogtreecommitdiff
path: root/test-suite/misc
diff options
context:
space:
mode:
Diffstat (limited to 'test-suite/misc')
-rwxr-xr-xtest-suite/misc/7595.sh5
-rw-r--r--test-suite/misc/7595/FOO.v39
-rw-r--r--test-suite/misc/7595/base.v28
-rwxr-xr-xtest-suite/misc/7704.sh7
-rw-r--r--test-suite/misc/aux7704.v6
-rwxr-xr-xtest-suite/misc/deps-checksum.sh1
-rwxr-xr-xtest-suite/misc/deps-order.sh9
-rwxr-xr-xtest-suite/misc/deps-utf8.sh9
-rwxr-xr-xtest-suite/misc/exitstatus.sh7
-rwxr-xr-xtest-suite/misc/poly-capture-global-univs.sh19
-rw-r--r--test-suite/misc/poly-capture-global-univs/_CoqProject9
-rw-r--r--test-suite/misc/poly-capture-global-univs/src/evil.ml49
-rw-r--r--test-suite/misc/poly-capture-global-univs/src/evilImpl.ml22
-rw-r--r--test-suite/misc/poly-capture-global-univs/src/evilImpl.mli2
-rw-r--r--test-suite/misc/poly-capture-global-univs/src/evil_plugin.mlpack2
-rw-r--r--test-suite/misc/poly-capture-global-univs/theories/evil.v13
-rwxr-xr-xtest-suite/misc/printers.sh5
-rwxr-xr-xtest-suite/misc/universes.sh5
18 files changed, 181 insertions, 16 deletions
diff --git a/test-suite/misc/7595.sh b/test-suite/misc/7595.sh
new file mode 100755
index 00000000..836e354e
--- /dev/null
+++ b/test-suite/misc/7595.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e
+
+$coqc -R misc/7595 Test misc/7595/base.v
+$coqc -R misc/7595 Test misc/7595/FOO.v
diff --git a/test-suite/misc/7595/FOO.v b/test-suite/misc/7595/FOO.v
new file mode 100644
index 00000000..30c957d3
--- /dev/null
+++ b/test-suite/misc/7595/FOO.v
@@ -0,0 +1,39 @@
+Require Import Test.base.
+
+Lemma dec_stable `{Decision P} : ¬¬P → P.
+Proof. firstorder. Qed.
+
+(** The tactic [destruct_decide] destructs a sumbool [dec]. If one of the
+components is double negated, it will try to remove the double negation. *)
+Tactic Notation "destruct_decide" constr(dec) "as" ident(H) :=
+ destruct dec as [H|H];
+ try match type of H with
+ | ¬¬_ => apply dec_stable in H
+ end.
+Tactic Notation "destruct_decide" constr(dec) :=
+ let H := fresh in destruct_decide dec as H.
+
+
+(** * Monadic operations *)
+Instance option_guard: MGuard option := λ P dec A f,
+ match dec with left H => f H | _ => None end.
+
+(** * Tactics *)
+Tactic Notation "case_option_guard" "as" ident(Hx) :=
+ match goal with
+ | H : context C [@mguard option _ ?P ?dec] |- _ =>
+ change (@mguard option _ P dec) with (λ A (f : P → option A),
+ match @decide P dec with left H' => f H' | _ => None end) in *;
+ destruct_decide (@decide P dec) as Hx
+ | |- context C [@mguard option _ ?P ?dec] =>
+ change (@mguard option _ P dec) with (λ A (f : P → option A),
+ match @decide P dec with left H' => f H' | _ => None end) in *;
+ destruct_decide (@decide P dec) as Hx
+ end.
+Tactic Notation "case_option_guard" :=
+ let H := fresh in case_option_guard as H.
+
+(* This proof failed depending on the name of the module. *)
+Lemma option_guard_True {A} P `{Decision P} (mx : option A) :
+ P → (guard P; mx) = mx.
+Proof. intros. case_option_guard. reflexivity. contradiction. Qed.
diff --git a/test-suite/misc/7595/base.v b/test-suite/misc/7595/base.v
new file mode 100644
index 00000000..6a6b7b79
--- /dev/null
+++ b/test-suite/misc/7595/base.v
@@ -0,0 +1,28 @@
+From Coq Require Export Morphisms RelationClasses List Bool Utf8 Setoid.
+Set Default Proof Using "Type".
+Export ListNotations.
+From Coq.Program Require Export Basics Syntax.
+Global Generalizable All Variables.
+
+(** * Type classes *)
+(** ** Decidable propositions *)
+(** This type class by (Spitters/van der Weegen, 2011) collects decidable
+propositions. *)
+Class Decision (P : Prop) := decide : {P} + {¬P}.
+Hint Mode Decision ! : typeclass_instances.
+Arguments decide _ {_} : simpl never, assert.
+
+(** ** Proof irrelevant types *)
+(** This type class collects types that are proof irrelevant. That means, all
+elements of the type are equal. We use this notion only used for propositions,
+but by universe polymorphism we can generalize it. *)
+Class ProofIrrel (A : Type) : Prop := proof_irrel (x y : A) : x = y.
+Hint Mode ProofIrrel ! : typeclass_instances.
+
+Class MGuard (M : Type → Type) :=
+ mguard: ∀ P {dec : Decision P} {A}, (P → M A) → M A.
+Arguments mguard _ _ _ !_ _ _ / : assert.
+Notation "'guard' P ; z" := (mguard P (λ _, z))
+ (at level 20, z at level 200, only parsing, right associativity) .
+Notation "'guard' P 'as' H ; z" := (mguard P (λ H, z))
+ (at level 20, z at level 200, only parsing, right associativity) .
diff --git a/test-suite/misc/7704.sh b/test-suite/misc/7704.sh
new file mode 100755
index 00000000..0ca2c97d
--- /dev/null
+++ b/test-suite/misc/7704.sh
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+set -e
+
+export PATH=$BIN:$PATH
+
+${coqtop#"$BIN"} -compile misc/aux7704.v
diff --git a/test-suite/misc/aux7704.v b/test-suite/misc/aux7704.v
new file mode 100644
index 00000000..6fdcf676
--- /dev/null
+++ b/test-suite/misc/aux7704.v
@@ -0,0 +1,6 @@
+
+Goal True /\ True.
+Proof.
+ split.
+ par:exact I.
+Qed.
diff --git a/test-suite/misc/deps-checksum.sh b/test-suite/misc/deps-checksum.sh
index e07612b8..a15a8fbe 100755
--- a/test-suite/misc/deps-checksum.sh
+++ b/test-suite/misc/deps-checksum.sh
@@ -1,3 +1,4 @@
+#!/bin/sh
rm -f misc/deps/A/*.vo misc/deps/B/*.vo
$coqc -R misc/deps/A A misc/deps/A/A.v
$coqc -R misc/deps/B A misc/deps/B/A.v
diff --git a/test-suite/misc/deps-order.sh b/test-suite/misc/deps-order.sh
index 299f4946..6bb2ba2d 100755
--- a/test-suite/misc/deps-order.sh
+++ b/test-suite/misc/deps-order.sh
@@ -1,17 +1,18 @@
+#!/bin/sh
# Check that both coqdep and coqtop/coqc supports -R
# Check that both coqdep and coqtop/coqc takes the later -R
# See bugs 2242, 2337, 2339
rm -f misc/deps/lib/*.vo misc/deps/client/*.vo
-tmpoutput=`mktemp /tmp/coqcheck.XXXXXX`
-$coqdep -R misc/deps/lib lib -R misc/deps/client client misc/deps/client/bar.v 2>&1 | head -n 1 > $tmpoutput
-diff -u --strip-trailing-cr misc/deps/deps.out $tmpoutput 2>&1
+tmpoutput=$(mktemp /tmp/coqcheck.XXXXXX)
+$coqdep -R misc/deps/lib lib -R misc/deps/client client misc/deps/client/bar.v 2>&1 | head -n 1 > "$tmpoutput"
+diff -u --strip-trailing-cr misc/deps/deps.out "$tmpoutput" 2>&1
R=$?
times
$coqc -R misc/deps/lib lib misc/deps/lib/foo.v 2>&1
$coqc -R misc/deps/lib lib -R misc/deps/client client misc/deps/client/foo.v 2>&1
$coqtop -R misc/deps/lib lib -R misc/deps/client client -load-vernac-source misc/deps/client/bar.v 2>&1
S=$?
-if [ $R = 0 -a $S = 0 ]; then
+if [ $R = 0 ] && [ $S = 0 ]; then
printf "coqdep and coqtop agree\n"
exit 0
else
diff --git a/test-suite/misc/deps-utf8.sh b/test-suite/misc/deps-utf8.sh
index 13e264c0..acb45b22 100755
--- a/test-suite/misc/deps-utf8.sh
+++ b/test-suite/misc/deps-utf8.sh
@@ -1,15 +1,16 @@
+#!/bin/sh
# Check reading directories matching non pure ascii idents
# See bug #5715 (utf-8 working on macos X and linux)
# Windows is still not compliant
-a=`uname`
-if [ "$a" = "Darwin" -o "$a" = "Linux" ]; then
+a=$(uname)
+if [ "$a" = "Darwin" ] || [ "$a" = "Linux" ]; then
rm -f misc/deps/théorèmes/*.v
-tmpoutput=`mktemp /tmp/coqcheck.XXXXXX`
+tmpoutput=$(mktemp /tmp/coqcheck.XXXXXX)
$coqc -R misc/deps AlphaBêta misc/deps/αβ/γδ.v
R=$?
$coqtop -R misc/deps AlphaBêta -load-vernac-source misc/deps/αβ/εζ.v
S=$?
-if [ $R = 0 -a $S = 0 ]; then
+if [ $R = 0 ] && [ $S = 0 ]; then
exit 0
else
exit 1
diff --git a/test-suite/misc/exitstatus.sh b/test-suite/misc/exitstatus.sh
index cea1de86..a327f424 100755
--- a/test-suite/misc/exitstatus.sh
+++ b/test-suite/misc/exitstatus.sh
@@ -1,7 +1,8 @@
+#!/bin/sh
$coqtop -load-vernac-source misc/exitstatus/illtyped.v
N=$?
$coqc misc/exitstatus/illtyped.v
P=$?
-printf "On ill-typed input, coqtop returned $N.\n"
-printf "On ill-typed input, coqc returned $P.\n"
-if [ $N = 1 -a $P = 1 ]; then exit 0; else exit 1; fi
+printf "On ill-typed input, coqtop returned %s.\n" "$N"
+printf "On ill-typed input, coqc returned %s.\n" "$P"
+if [ $N = 1 ] && [ $P = 1 ]; then exit 0; else exit 1; fi
diff --git a/test-suite/misc/poly-capture-global-univs.sh b/test-suite/misc/poly-capture-global-univs.sh
new file mode 100755
index 00000000..e066ac03
--- /dev/null
+++ b/test-suite/misc/poly-capture-global-univs.sh
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+
+set -e
+
+export COQBIN=$BIN
+export PATH=$COQBIN:$PATH
+
+cd misc/poly-capture-global-univs/
+
+coq_makefile -f _CoqProject -o Makefile
+
+make clean
+
+make src/evil_plugin.cmxs
+
+if make; then
+ >&2 echo 'Should have failed!'
+ exit 1
+fi
diff --git a/test-suite/misc/poly-capture-global-univs/_CoqProject b/test-suite/misc/poly-capture-global-univs/_CoqProject
new file mode 100644
index 00000000..70ec2460
--- /dev/null
+++ b/test-suite/misc/poly-capture-global-univs/_CoqProject
@@ -0,0 +1,9 @@
+-Q theories Evil
+-I src
+
+src/evil.ml4
+src/evilImpl.ml
+src/evilImpl.mli
+src/evil_plugin.mlpack
+theories/evil.v
+
diff --git a/test-suite/misc/poly-capture-global-univs/src/evil.ml4 b/test-suite/misc/poly-capture-global-univs/src/evil.ml4
new file mode 100644
index 00000000..565e979a
--- /dev/null
+++ b/test-suite/misc/poly-capture-global-univs/src/evil.ml4
@@ -0,0 +1,9 @@
+
+open Stdarg
+open EvilImpl
+
+DECLARE PLUGIN "evil_plugin"
+
+VERNAC COMMAND FUNCTIONAL EXTEND VernacEvil CLASSIFIED AS SIDEFF
+| [ "Evil" ident(x) ident(y) ] -> [ fun ~atts ~st -> evil x y; st ]
+END
diff --git a/test-suite/misc/poly-capture-global-univs/src/evilImpl.ml b/test-suite/misc/poly-capture-global-univs/src/evilImpl.ml
new file mode 100644
index 00000000..6d8ce7c5
--- /dev/null
+++ b/test-suite/misc/poly-capture-global-univs/src/evilImpl.ml
@@ -0,0 +1,22 @@
+open Names
+
+let evil t f =
+ let open Univ in
+ let open Entries in
+ let open Decl_kinds in
+ let open Constr in
+ let k = IsDefinition Definition in
+ let u = Level.var 0 in
+ let tu = mkType (Universe.make u) in
+ let te = Declare.definition_entry
+ ~univs:(Monomorphic_const_entry (ContextSet.singleton u)) tu
+ in
+ let tc = Declare.declare_constant t (DefinitionEntry te, k) in
+ let tc = mkConst tc in
+
+ let fe = Declare.definition_entry
+ ~univs:(Polymorphic_const_entry (UContext.make (Instance.of_array [|u|],Constraint.empty)))
+ ~types:(Term.mkArrow tc tu)
+ (mkLambda (Name.Name (Id.of_string "x"), tc, mkRel 1))
+ in
+ ignore (Declare.declare_constant f (DefinitionEntry fe, k))
diff --git a/test-suite/misc/poly-capture-global-univs/src/evilImpl.mli b/test-suite/misc/poly-capture-global-univs/src/evilImpl.mli
new file mode 100644
index 00000000..97c7e3da
--- /dev/null
+++ b/test-suite/misc/poly-capture-global-univs/src/evilImpl.mli
@@ -0,0 +1,2 @@
+
+val evil : Names.Id.t -> Names.Id.t -> unit
diff --git a/test-suite/misc/poly-capture-global-univs/src/evil_plugin.mlpack b/test-suite/misc/poly-capture-global-univs/src/evil_plugin.mlpack
new file mode 100644
index 00000000..0093328a
--- /dev/null
+++ b/test-suite/misc/poly-capture-global-univs/src/evil_plugin.mlpack
@@ -0,0 +1,2 @@
+EvilImpl
+Evil
diff --git a/test-suite/misc/poly-capture-global-univs/theories/evil.v b/test-suite/misc/poly-capture-global-univs/theories/evil.v
new file mode 100644
index 00000000..7fd98c27
--- /dev/null
+++ b/test-suite/misc/poly-capture-global-univs/theories/evil.v
@@ -0,0 +1,13 @@
+
+Declare ML Module "evil_plugin".
+
+Evil T f. (* <- if this doesn't fail then the rest goes through *)
+
+Definition g : Type -> Set := f.
+
+Require Import Hurkens.
+
+Lemma absurd : False.
+Proof.
+ exact (TypeNeqSmallType.paradox (g Type) eq_refl).
+Qed.
diff --git a/test-suite/misc/printers.sh b/test-suite/misc/printers.sh
index 28e7dc36..ef3f056d 100755
--- a/test-suite/misc/printers.sh
+++ b/test-suite/misc/printers.sh
@@ -1,3 +1,2 @@
-printf "Drop. #use\"include\";; #quit;;\n" | $coqtopbyte 2>&1 | egrep "Error|Unbound"
-if [ $? = 0 ]; then exit 1; else exit 0; fi
-
+#!/bin/sh
+if printf "Drop. #use\"include\";; #quit;;\n" | $coqtopbyte 2>&1 | grep -E "Error|Unbound" ; then exit 1; else exit 0; fi
diff --git a/test-suite/misc/universes.sh b/test-suite/misc/universes.sh
index d87a8603..ef61ca62 100755
--- a/test-suite/misc/universes.sh
+++ b/test-suite/misc/universes.sh
@@ -1,8 +1,9 @@
+#!/bin/sh
# Sort universes for the whole standard library
EXPECTED_UNIVERSES=4 # Prop is not counted
$coqc -R misc/universes Universes misc/universes/all_stdlib 2>&1
$coqc -R misc/universes Universes misc/universes/universes 2>&1
mv universes.txt misc/universes
-N=`awk '{print $3}' misc/universes/universes.txt | sort -u | wc -l`
-printf "Found %s/%s universes\n" $N $EXPECTED_UNIVERSES
+N=$(awk '{print $3}' misc/universes/universes.txt | sort -u | wc -l)
+printf "Found %s/%s universes\n" "$N" "$EXPECTED_UNIVERSES"
if [ "$N" -eq $EXPECTED_UNIVERSES ]; then exit 0; else exit 1; fi