aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorBasil L. Contovounesios2019-04-07 03:36:47 +0100
committerBasil L. Contovounesios2019-04-07 03:56:27 +0100
commit08235af38c92e95d8ec9d268916d8910ea50ab2d (patch)
treed065cbd0fcb339ddf2f2fd0b809400a54deb99ef /test
parent43f4c7ddd2077b2e786d069bbb9e2de32f23ffb2 (diff)
downloademacs-08235af38c92e95d8ec9d268916d8910ea50ab2d.tar.gz
emacs-08235af38c92e95d8ec9d268916d8910ea50ab2d.zip
Distinguish buttons from widgets (bug#34506)
* lisp/button.el (button-at): * lisp/wid-edit.el (widget-at): Avoid returning a false positive when looking for a button and finding a widget, or vice versa. * test/lisp/button-tests.el: * test/lisp/wid-edit-tests.el: New files.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/button-tests.el40
-rw-r--r--test/lisp/wid-edit-tests.el39
2 files changed, 79 insertions, 0 deletions
diff --git a/test/lisp/button-tests.el b/test/lisp/button-tests.el
new file mode 100644
index 00000000000..d54a992ab89
--- /dev/null
+++ b/test/lisp/button-tests.el
@@ -0,0 +1,40 @@
1;;; button-tests.el --- tests for button.el -*- lexical-binding: t -*-
2
3;; Copyright (C) 2019 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;;; Code:
21
22(require 'ert)
23
24(ert-deftest button-at ()
25 "Test `button-at' behavior."
26 (with-temp-buffer
27 (should-not (button-at (point)))
28 (let ((button (insert-text-button "text button"))
29 (marker (button-at (1- (point)))))
30 (should (markerp marker))
31 (should (= (button-end button) (button-end marker) (point))))
32 (let ((button (insert-button "overlay button"))
33 (overlay (button-at (1- (point)))))
34 (should (overlayp overlay))
35 (should (eq button overlay)))
36 ;; Buttons and widgets are incompatible (bug#34506).
37 (widget-create 'link "link widget")
38 (should-not (button-at (1- (point))))))
39
40;;; button-tests.el ends here
diff --git a/test/lisp/wid-edit-tests.el b/test/lisp/wid-edit-tests.el
new file mode 100644
index 00000000000..a4350e715ed
--- /dev/null
+++ b/test/lisp/wid-edit-tests.el
@@ -0,0 +1,39 @@
1;;; wid-edit-tests.el --- tests for wid-edit.el -*- lexical-binding: t -*-
2
3;; Copyright (C) 2019 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;;; Code:
21
22(require 'ert)
23(require 'wid-edit)
24
25(ert-deftest widget-at ()
26 "Test `widget-at' behavior."
27 (with-temp-buffer
28 (should-not (widget-at))
29 (let ((marco (widget-create 'link "link widget"))
30 (polo (widget-at (1- (point)))))
31 (should (widgetp polo))
32 (should (eq marco polo)))
33 ;; Buttons and widgets are incompatible (bug#34506).
34 (insert-text-button "text button")
35 (should-not (widget-at (1- (point))))
36 (insert-button "overlay button")
37 (should-not (widget-at (1- (point))))))
38
39;;; wid-edit-tests.el ends here