aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMattias EngdegÄrd2020-06-21 21:04:30 +0200
committerMattias EngdegÄrd2020-06-22 09:51:11 +0200
commit73daab99914b4972a7cd167b03102be4c68e83e5 (patch)
tree454a7f5d3c33b72c1ba0b7f3cffb453473386c30 /test
parentce4ec1793041ae0f013234ef7189ed855b5227a3 (diff)
downloademacs-73daab99914b4972a7cd167b03102be4c68e83e5.tar.gz
emacs-73daab99914b4972a7cd167b03102be4c68e83e5.zip
Preserve point in pascal-mode completion (bug#41740)
Failure to do so caused errors in several cases. Reported by Shinichi Sakata. * lisp/progmodes/pascal.el (pascal-type-completion) (pascal-completion): Wrap code that may move point in save-excursion. * test/lisp/progmodes/pascal-tests.el: New file.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/progmodes/pascal-tests.el55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/lisp/progmodes/pascal-tests.el b/test/lisp/progmodes/pascal-tests.el
new file mode 100644
index 00000000000..10d6e0433d0
--- /dev/null
+++ b/test/lisp/progmodes/pascal-tests.el
@@ -0,0 +1,55 @@
1;;; pascal-tests.el --- tests for pascal.el -*- lexical-binding: t -*-
2
3;; Copyright (C) 2020 Free Software Foundation, Inc.
4
5;; This file is part of GNU Emacs.
6
7;; GNU Emacs is free software: you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; GNU Emacs is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
19
20(require 'ert)
21(require 'pascal)
22
23(ert-deftest pascal-completion ()
24 ;; Bug#41740: completion functions must preserve point.
25 (let ((pascal-completion-cache nil))
26 (with-temp-buffer
27 (pascal-mode)
28 (insert "program test; var")
29 (let* ((point-before (point))
30 (completions (pascal-completion "var" nil 'metadata))
31 (point-after (point)))
32 (should (equal completions nil))
33 (should (equal point-before point-after)))))
34
35 (let ((pascal-completion-cache nil))
36 (with-temp-buffer
37 (pascal-mode)
38 (insert "program test; function f(x : i")
39 (let* ((point-before (point))
40 (completions (pascal-completion "i" nil 'metadata))
41 (point-after (point)))
42 (should (equal completions nil))
43 (should (equal point-before point-after)))))
44
45 (let ((pascal-completion-cache nil))
46 (with-temp-buffer
47 (pascal-mode)
48 (insert "program test; function f(x : integer) : real")
49 (let* ((point-before (point))
50 (completions (pascal-completion "real" nil 'metadata))
51 (point-after (point)))
52 (should (equal completions nil))
53 (should (equal point-before point-after))))))
54
55(provide 'pascal-tests)