Skip to content

Commit 2e0f425

Browse files
committed
Add tests for type specifications
1 parent 7367ed1 commit 2e0f425

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

test/typechecking/type_specs/dune

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(include ../../utils/dune.common)
2+
3+
(include dune.inc)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
(rule
2+
(targets _gospel)
3+
(action (run mkdir -p _gospel))) ; create the compilation directory.
4+
(rule
5+
(deps
6+
%{bin:gospel}
7+
(:checker %{project_root}/test/utils/testchecker.exe)
8+
_gospel)
9+
(action
10+
(with-outputs-to positive.mli.output
11+
(run %{checker} %{dep:positive.mli}))))
12+
13+
(rule
14+
(alias runtest)
15+
(action
16+
(diff positive.mli positive.mli.output)))
17+
18+
(rule
19+
(alias test-cmis)
20+
(action
21+
(chdir %{project_root}
22+
; Syntax sanity check
23+
(run ocamlc -c %{dep:positive.mli}))))
24+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
(**************************************************************************)
2+
(* *)
3+
(* GOSPEL -- A Specification Language for OCaml *)
4+
(* *)
5+
(* Copyright (c) 2018- The VOCaL Project *)
6+
(* *)
7+
(* This software is free software, distributed under the MIT license *)
8+
(* (as described in file LICENSE enclosed). *)
9+
(**************************************************************************)
10+
11+
(*@ type nat = integer
12+
with x invariant x >= 0
13+
and positive_fraction = fraction
14+
with x invariant
15+
forall r. let _ = { res = r; f = x } in r > 0
16+
and negative_fraction = fraction
17+
with x invariant
18+
forall r. let _ = { res = r; f = x } in r < 0
19+
and compute = { res : integer; f : fraction }
20+
with x invariant x.res = x.res = (x.f.n1 / x.f.n2)
21+
and fraction = { n1 : integer; n2 : nat } *)

0 commit comments

Comments
 (0)