@@ -117,6 +117,26 @@ Proof.
117
117
" Coq source code for checking that goals are updated even in case of error." )
118
118
119
119
120
+ (defconst coq-src-update-goal-after-search
121
+ "
122
+ Lemma g : 1 + 1 = 2.
123
+ Proof using.
124
+ simpl.
125
+ Search (0 + _).
126
+ "
127
+ " Coq source code for checking that goals are up-to-date after Search." )
128
+
129
+
130
+ (defconst coq-src-update-goal-after-check
131
+ "
132
+ Lemma h : 1 + 2 = 3.
133
+ Proof using.
134
+ simpl.
135
+ Check plus_O_n.
136
+ "
137
+ " Coq source code for checking that goals are up-to-date after Check." )
138
+
139
+
120
140
; ;; utility functions
121
141
122
142
(defun record-buffer-content (buf )
@@ -146,7 +166,8 @@ BUF should be a string."
146
166
Process COQ-SRC in a new buffer in one step and check that the
147
167
goals buffer is not empty afterwards. If CHECK-RESPONSE-NONEMPTY
148
168
is non-nil, additionally check that the response buffer is
149
- non-empty, i.e., shows some error message."
169
+ non-empty, i.e., shows some message, and is visible in some
170
+ window also in two-pane mode."
150
171
(message " goals-after-test: Check goals are present after %s . " msg)
151
172
(setq proof-three-window-enable nil )
152
173
(let (buffer)
@@ -161,16 +182,20 @@ non-empty, i.e., shows some error message."
161
182
; ; (record-buffer-content "*goals*")
162
183
163
184
; ; check that there is a goal in the goals buffer
164
- (with-current-buffer " * goals* "
185
+ (with-current-buffer proof- goals-buffer
165
186
(goto-char (point-min ))
166
187
(should (looking-at " 1 \\ (sub\\ )?goal (ID" )))
167
188
168
189
(when check-response-nonempty
169
190
(message
170
191
" goals-after-test: Check response buffer is nonempty after %s."
171
192
msg)
172
- (with-current-buffer " *response*"
173
- (should (not (equal (point-min ) (point-max )))))))
193
+ (with-current-buffer proof-response-buffer
194
+ (should (not (equal (point-min ) (point-max )))))
195
+ (message
196
+ " goals-after-test: Check response buffer is visible after %s."
197
+ msg)
198
+ (should (get-buffer-window proof-response-buffer))))
174
199
175
200
; ; clean up
176
201
(when buffer
@@ -190,7 +215,7 @@ the goals buffer is expected to be empty."
190
215
; ; (record-buffer-content "*goals*")
191
216
192
217
; ; check that the goals buffer is empty
193
- (with-current-buffer " * goals* "
218
+ (with-current-buffer proof- goals-buffer
194
219
(should (equal (point-min ) (point-max )))))
195
220
196
221
(defun goals-buffer-should-get-reset (coq-src coq-stm msg )
@@ -221,7 +246,7 @@ which action the goals buffer should have been reset."
221
246
(proof-goto-point)
222
247
(wait-for-coq)
223
248
; ; there should be something in the goals buffer now
224
- (with-current-buffer " * goals* "
249
+ (with-current-buffer proof- goals-buffer
225
250
(should (not (equal (point-min ) (point-max )))))
226
251
227
252
(goals-buffer-should-be-empty (point-max ) msg))
@@ -272,50 +297,116 @@ which action the goals buffer should have been reset."
272
297
(goals-buffer-should-get-reset coq-src-qed
273
298
" Proof using" " Qed" ))
274
299
275
- (ert-deftest update-goals-after-error ()
276
- " Test goals are updated after an error."
277
- :expected-result :failed
278
- (message " update-goals-after-error: Check goals are updated after error " )
300
+ (defun update-goals-when-response (coq-src first-pos goal-2nd msg )
301
+ " Test goals are up-to-date after an error or a command that produces response.
302
+ Process COQ-SRC up to the line after the first match of regular
303
+ expression FIRST-POS. At this point the goals buffer should not
304
+ be empty. Process now COQ-SRC up to the end. If GOAL-2ND is a
305
+ regular expression as a string, then check that the goals have
306
+ been updated to contain a match for GOAL-2ND. If GOAL-2ND is no
307
+ string, only check that the goals buffer is non-empty. In any
308
+ case, check that the response buffer is not empty and visible in
309
+ two-pane mode."
310
+
311
+ (message " update-goals-when-response: Check goals are updated after %s " msg)
279
312
(setq proof-three-window-enable nil )
280
313
(let (buffer)
281
314
(unwind-protect
282
315
(progn
283
316
(find-file " goals.v" )
284
317
(setq buffer (current-buffer ))
285
- (insert coq-src-update-goal-after-error )
318
+ (insert coq-src)
286
319
(goto-char (point-min ))
287
- (should (re-search-forward " point A " nil t ))
288
- (beginning-of- line )
320
+ (should (re-search-forward first-pos nil t ))
321
+ (forward- line 1 )
289
322
(proof-goto-point)
290
323
(wait-for-coq)
291
324
; ; (record-buffer-content "*coq*")
292
325
; ; (record-buffer-content "*goals*")
293
326
294
- ; ; the complete goal should be present
295
- (message " Check that the complete goal is present in *goals* " )
296
- (with-current-buffer " *goals*"
297
- (goto-char (point-min ))
298
- (should (re-search-forward " (eq_one 1 -> False) -> False" nil t )))
327
+ ; ; goals should be present
328
+ (message " Check that goals are present " )
329
+ (with-current-buffer proof-goals-buffer
330
+ (should (not (equal (point-min ) (point-max )))))
299
331
300
- (should (re-search-forward " point B" nil t ))
301
- (beginning-of-line )
332
+ (goto-char (point-max ))
302
333
(proof-goto-point)
303
334
(wait-for-coq)
304
335
; ; (record-buffer-content "*coq*")
305
336
; ; (record-buffer-content "*goals*")
306
337
307
- ; ; the hypothesis H should be present
308
- (message " Check that the goals buffer has been updated " )
309
- (with-current-buffer " *goals*"
338
+ (with-current-buffer proof-goals-buffer
310
339
(goto-char (point-min ))
311
- (should (re-search-forward " H : eq_one 1 -> False" nil t )))
340
+ (if (stringp goal-2nd)
341
+ (progn
342
+ (message " Check that goals have been updated " )
343
+ (should (re-search-forward goal-2nd nil t )))
344
+ (message " Check that goals are still present " )
345
+ (should (not (equal (point-min ) (point-max ))))))
346
+
347
+ ; ; something should be in the response buffer
348
+ (message " Check that there is some response present " )
349
+ (with-current-buffer proof-response-buffer
350
+ (should (not (equal (point-min ) (point-max )))))
312
351
313
- ; ; some error should be in the response buffer
314
- (message " Check that there is some error message present " )
315
- (with-current-buffer " *response*"
316
- (should (not (equal (point-min ) (point-max ))))))
352
+ (message " Check that the response is visible in two-pane mode " )
353
+ (should (get-buffer-window proof-response-buffer)))
317
354
318
355
(when buffer
319
356
(with-current-buffer buffer
320
357
(set-buffer-modified-p nil ))
321
358
(kill-buffer buffer)))))
359
+
360
+ (ert-deftest goals-up-to-date-at-error ()
361
+ " Check that goals are updated before showing the error."
362
+ :expected-result :failed
363
+ (update-goals-when-response coq-src-update-goal-after-error
364
+ " Lemma foo"
365
+ " H : eq_one 1 -> False"
366
+ " error" ))
367
+
368
+ (ert-deftest goals-up-to-date-after-search-one-step ()
369
+ " Check that goals are still present before showing result of one search cmd.
370
+ This test checks a single Search command inside a proof. After
371
+ processing that Search command alone, the goals buffer should not
372
+ be empty and the response buffer should contain something and be
373
+ visible in two-pane mode."
374
+ (update-goals-when-response coq-src-update-goal-after-search
375
+ " simpl"
376
+ t
377
+ " Search" ))
378
+
379
+ (ert-deftest goals-updated-after-search-many-steps ()
380
+ " Check that goals are updated before showing result of search cmd.
381
+ This test checks several commands inside a proof with a final
382
+ Search command. After processing these commands, the goals buffer
383
+ should have been updated and the response buffer should contain
384
+ something and be visible in two-pane mode."
385
+ :expected-result :failed
386
+ (update-goals-when-response coq-src-update-goal-after-search
387
+ " Lemma g"
388
+ " 2 = 2"
389
+ " Search" ))
390
+
391
+ (ert-deftest goals-up-to-date-after-check-one-step ()
392
+ " Check that goals are still present before showing result of one check cmd.
393
+ This test checks a single Check command inside a proof. After
394
+ processing that Check command alone, the goals buffer should not
395
+ be empty and the response buffer should contain something and be
396
+ visible in two-pane mode."
397
+ (update-goals-when-response coq-src-update-goal-after-check
398
+ " simpl"
399
+ t
400
+ " Check" ))
401
+
402
+ (ert-deftest goals-updated-after-check-many-steps ()
403
+ " Check that goals are updated before showing result of check cmd.
404
+ This test checks several commands inside a proof with a final
405
+ Check command. After processing these commands, the goals buffer
406
+ should have been updated and the response buffer should contain
407
+ something and be visible in two-pane mode."
408
+ :expected-result :failed
409
+ (update-goals-when-response coq-src-update-goal-after-check
410
+ " Lemma h"
411
+ " 3 = 3"
412
+ " Check" ))
0 commit comments