@@ -189,3 +189,96 @@ let end_proof : proof_state -> command_result =
189
189
190
190
let get_symbols : state -> Term.sym Extra.StrMap.t =
191
191
fun (_ , ss ) -> ss.in_scope
192
+
193
+ (* Equality on *)
194
+ let test_file = " ./tests/foo.lp"
195
+
196
+ (* Equality is reflexive *)
197
+ let % test _ =
198
+ let _st = initial_state test_file in
199
+ let (c,_) = parse_text (* st *) ~fname: test_file " constant symbol B : TYPE;" in
200
+ List. equal Command. equal c c
201
+
202
+ (* Equality not *)
203
+ let % test _ =
204
+ let _st = initial_state test_file in
205
+ let (c,_) = parse_text (* st *) ~fname: test_file " constant symbol B : TYPE;" in
206
+ let (d,_) = parse_text (* st *) ~fname: test_file " constant symbol C : TYPE;" in
207
+ not (List. equal Command. equal c d)
208
+
209
+ (* Equality is not sensitive to whitespace *)
210
+ let % test _ =
211
+ let _st = initial_state test_file in
212
+ let (c,_) = parse_text (* st *) ~fname: test_file " constant symbol B : TYPE;" in
213
+ let (d,_) = parse_text (* st *) ~fname: test_file " constant symbol B : TYPE; " in
214
+ List. equal Command. equal c d
215
+
216
+ (* More complex tests stressing most commands *)
217
+
218
+ (* Equality is reflexive *)
219
+ let % test _ =
220
+ let _st = initial_state test_file in
221
+ let (c,_) = parse_text (* st *) ~fname: test_file
222
+ (* copied from tests/OK/foo.lp. keep in sync. *)
223
+ " constant symbol B : TYPE;
224
+
225
+ constant symbol true : B;
226
+ constant symbol false : B;
227
+
228
+ symbol neg : B → B;
229
+
230
+ rule neg true ↪ false;
231
+ rule neg false ↪ true;
232
+
233
+ constant symbol Prop : TYPE;
234
+
235
+ injective symbol P : Prop → TYPE;
236
+
237
+ constant symbol eq : B → B → Prop;
238
+ constant symbol refl b : P (eq b b);
239
+
240
+ constant symbol case (p : B → Prop) : P (p true) → P (p false) → Π b, P b;
241
+
242
+ opaque symbol notK : Π b, P (eq (neg (neg b)) b)
243
+ ≔ begin
244
+ assume b;
245
+ apply case (λ b, eq (neg (neg b)) b)
246
+ {apply refl}
247
+ {apply refl}
248
+ end;
249
+ " in
250
+ List. equal Command. equal c c
251
+
252
+ (* TODO *)
253
+
254
+ (* test: Check that parsing from the file is the same that parsing from string *)
255
+
256
+ (* test: Check that parsing commutes *)
257
+
258
+ let pp_pos fmt (c : Command.t ) =
259
+ Format. fprintf fmt " %a" Pos. pp (Command. get_pos c)
260
+
261
+ (* auxiliary function *)
262
+ let parse_split input =
263
+ let input_split = String. split_on_char ';' input in
264
+ let input_split = List. map (fun s -> s ^ " ;" ) input_split in
265
+ let input_split = List. (take (length input_split - 1 )) input_split in
266
+ Format. eprintf " input_split: @[%a@]@\n " Format. (pp_print_list pp_print_string) input_split;
267
+ let cmds_1, _ = parse_text ~fname: test_file input in
268
+ let cmds_2, _ = List. map (parse_text ~fname: test_file) input_split |> List. unzip in
269
+ let cmds_2 = List. flatten cmds_2 in
270
+ Format. eprintf " pos for 1: @[%a@]@\n " Format. (pp_print_list pp_pos) cmds_1;
271
+ Format. eprintf " pos for 2: @[%a@]@\n " Format. (pp_print_list pp_pos) cmds_2;
272
+ List. equal Command. equal cmds_1 cmds_2
273
+
274
+ let % test _ =
275
+ let input = "
276
+ constant symbol B : TYPE;
277
+ constant symbol C : TYPE;
278
+ " in
279
+ parse_split input
280
+
281
+ (* Test for notation: check that parsing with notation is correct and that fails when not present *)
282
+
283
+ (* Test for positions: check that the positions are correct, including when we
284
+ resume parsing from the middle of the file *)
0 commit comments