Skip to content

Commit 368e29a

Browse files
committed
[pure] [lsp] Try to recover unit testing of pure interface
PR #289 silently removed important unit tests in the Pure module. We try to recover them, but indeed, they don't work, as it seems the library handling API introduced in #289 is lacking in terms of how it can be used. There seem to be many problems with the new system in terms of what a language server needs, in particular regarding assumptions about the underlying file system.
1 parent 79c49c0 commit 368e29a

File tree

5 files changed

+64
-2
lines changed

5 files changed

+64
-2
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ env:
99
global:
1010
- OPAMJOBS="2"
1111
- OPAMYES="true"
12-
- TEST_TARGETS="real_tests"
12+
- TEST_TARGETS="real_tests unit-tests"
1313
matrix:
1414
- OCAML_VERSION=4.05.0
1515
- OCAML_VERSION=4.06.0

GNUmakefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ LAMBDAPI = dune exec -- lambdapi check --lib-root lib
1919
OK_TESTFILES = $(sort $(wildcard tests/OK/*.dk tests/OK/*.lp))
2020
KO_TESTFILES = $(sort $(wildcard tests/KO/*.dk tests/KO/*.lp))
2121

22-
.PHONY: tests
22+
.PHONY: tests unit-tests
23+
24+
unit-tests:
25+
@dune build runtest
26+
2327
tests: bin
2428
@printf "## OK tests ##\n"
2529
@for file in $(OK_TESTFILES) ; do \

src/pure/dune

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
(name pure)
33
(public_name lambdapi.pure)
44
(modules pure)
5+
(inline_tests (deps foo.lp))
6+
(preprocess (pps ppx_inline_test))
57
(libraries stdlib-shims core))

src/pure/foo.lp

Whitespace-only changes.

src/pure/pure.ml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,59 @@ let end_proof : proof_state -> command_result = fun s ->
9696
let get_symbols : state -> (Terms.sym * Pos.popt) StrMap.t = fun s ->
9797
Time.restore (fst s);
9898
!(Sign.((current_sign ()).sign_symbols))
99+
100+
(* Equality on *)
101+
let test_file = "./foo.lp"
102+
103+
let%test _ =
104+
let st = initial_state test_file in
105+
let (c,_) = parse_text st test_file "constant symbol B : TYPE" in
106+
List.equal Command.equal c c
107+
108+
(* Equality not *)
109+
let%test _ =
110+
let st = initial_state test_file in
111+
let (c,_) = parse_text st test_file "constant symbol B : TYPE" in
112+
let (d,_) = parse_text st test_file "constant symbol C : TYPE" in
113+
not (List.equal Command.equal c d)
114+
115+
(* Equality is not sensitive to whitespace *)
116+
let%test _ =
117+
let st = initial_state test_file in
118+
let (c,_) = parse_text st test_file "constant symbol B : TYPE" in
119+
let (d,_) = parse_text st test_file " constant symbol B : TYPE " in
120+
List.equal Command.equal c d
121+
122+
(* More complex test stressing most commands *)
123+
let%test _ =
124+
let st = initial_state test_file in
125+
let (c,_) = parse_text st test_file
126+
(* copied from tests/OK/foo.lp. keep in sync. *)
127+
"constant symbol B : TYPE
128+
129+
constant symbol true : B
130+
constant symbol false : B
131+
132+
symbol neg : B ⇒ B
133+
134+
rule neg true → false
135+
rule neg false → true
136+
137+
constant symbol Prop : TYPE
138+
139+
injective symbol P : Prop ⇒ TYPE
140+
141+
constant symbol eq : B ⇒ B ⇒ Prop
142+
constant symbol refl b : P (eq b b)
143+
144+
constant symbol case (p : B⇒Prop) : P (p true) ⇒ P (p false) ⇒ ∀b, P b
145+
146+
theorem notK : ∀b, P (eq (neg (neg b)) b)
147+
proof
148+
assume b
149+
apply case (λb, eq (neg (neg b)) b)
150+
apply refl
151+
apply refl
152+
qed
153+
" in
154+
List.equal Command.equal c c

0 commit comments

Comments
 (0)