aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAndrea Corallo2020-11-22 22:23:16 +0100
committerAndrea Corallo2020-11-22 22:23:16 +0100
commit033e96055cc172d8d84adc128aee7f7d9889bb00 (patch)
tree4e6e0a24c60f4c8776fb574bf31727dcaf4af4ba /test
parent6781cd670d1487bbf0364d80de68ca9733342769 (diff)
parent9b6ad3107f93d40f82c3c53dc0984c6d70aded83 (diff)
downloademacs-033e96055cc172d8d84adc128aee7f7d9889bb00.tar.gz
emacs-033e96055cc172d8d84adc128aee7f7d9889bb00.zip
Merge remote-tracking branch 'savannah/master' into HEAD
Diffstat (limited to 'test')
-rw-r--r--test/lisp/cedet/semantic-utest.el7
-rw-r--r--test/lisp/cus-edit-tests.el80
-rw-r--r--test/lisp/emacs-lisp/bytecomp-tests.el32
-rw-r--r--test/lisp/help-tests.el6
-rw-r--r--test/lisp/progmodes/cperl-mode-resources/cperl-bug-26850.pl16
-rw-r--r--test/lisp/progmodes/cperl-mode-tests.el15
-rw-r--r--test/manual/etags/ETAGS.good_114
-rw-r--r--test/manual/etags/ETAGS.good_214
-rw-r--r--test/manual/etags/ETAGS.good_314
-rw-r--r--test/manual/etags/ETAGS.good_414
-rw-r--r--test/manual/etags/ETAGS.good_514
-rw-r--r--test/manual/etags/ETAGS.good_614
-rw-r--r--test/manual/indent/tcl.tcl4
-rw-r--r--test/src/data-tests.el50
-rw-r--r--test/src/fns-tests.el7
-rw-r--r--test/src/keymap-tests.el81
-rw-r--r--test/src/syntax-resources/syntax-comments.txt26
-rw-r--r--test/src/syntax-tests.el66
18 files changed, 413 insertions, 61 deletions
diff --git a/test/lisp/cedet/semantic-utest.el b/test/lisp/cedet/semantic-utest.el
index e537871528c..bcbd7d686e3 100644
--- a/test/lisp/cedet/semantic-utest.el
+++ b/test/lisp/cedet/semantic-utest.el
@@ -38,14 +38,9 @@
38(defvar semantic-utest-test-directory (expand-file-name "tests" cedet-utest-directory) 38(defvar semantic-utest-test-directory (expand-file-name "tests" cedet-utest-directory)
39 "Location of test files.") 39 "Location of test files.")
40 40
41(defvar semantic-utest-temp-directory (if (fboundp 'temp-directory)
42 (temp-directory)
43 temporary-file-directory)
44 "Temporary directory to use when creating files.")
45
46(defun semantic-utest-fname (name) 41(defun semantic-utest-fname (name)
47 "Create a filename for NAME in /tmp." 42 "Create a filename for NAME in /tmp."
48 (expand-file-name name semantic-utest-temp-directory)) 43 (expand-file-name name temporary-file-directory))
49 44
50;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 45;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
51;; Data for C tests 46;; Data for C tests
diff --git a/test/lisp/cus-edit-tests.el b/test/lisp/cus-edit-tests.el
new file mode 100644
index 00000000000..bb88b8dd9fa
--- /dev/null
+++ b/test/lisp/cus-edit-tests.el
@@ -0,0 +1,80 @@
1;;; cus-edit-tests.el --- Tests for cus-edit.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;;; Commentary:
21
22;;; Code:
23
24(require 'ert)
25(require 'ert-x)
26(eval-when-compile (require 'cl-lib))
27(require 'cus-edit)
28
29(defmacro with-cus-edit-test (buffer &rest body)
30 (declare (indent 1))
31 `(save-window-excursion
32 (unwind-protect
33 (progn ,@body)
34 (when-let ((buf (get-buffer ,buffer)))
35 (kill-buffer buf)))))
36
37
38;;;; showing/hiding obsolete options
39
40(defgroup cus-edit-tests nil "test"
41 :group 'test-group)
42
43(defcustom cus-edit-tests--obsolete-option-tag nil
44 "This should never be removed; it is obsolete for testing purposes."
45 :type 'boolean
46 :version "917.10") ; a super high version number
47(make-obsolete-variable 'cus-edit-tests--obsolete-option-tag nil "X.X-test")
48(defconst cus-edit-tests--obsolete-option-tag
49 (custom-unlispify-tag-name 'cus-edit-tests--obsolete-option-tag))
50
51(ert-deftest cus-edit-tests-customize-apropos/hide-obsolete ()
52 (with-cus-edit-test "*Customize Apropos*"
53 (customize-apropos "cus-edit-tests")
54 (should-not (search-forward cus-edit-tests--obsolete-option-tag nil t))))
55
56(ert-deftest cus-edit-tests-customize-changed-options/hide-obsolete ()
57 (with-cus-edit-test "*Customize Changed Options*"
58 (customize-changed-options "917.2") ; some future version
59 (should-not (search-forward cus-edit-tests--obsolete-option-tag nil t))))
60
61(ert-deftest cus-edit-tests-customize-group/hide-obsolete ()
62 "Check that obsolete variables do not show up."
63 (with-cus-edit-test "*Customize Group: Cus Edit Tests*"
64 (customize-group 'cus-edit-tests)
65 (should-not (search-forward cus-edit-tests--obsolete-option-tag nil t))))
66
67(ert-deftest cus-edit-tests-customize-option/show-obsolete ()
68 (with-cus-edit-test "*Customize Option: Cus Edit Tests Obsolete Option Tag*"
69 (customize-option 'cus-edit-tests--obsolete-option-tag)
70 (goto-char (point-min))
71 (should (search-forward cus-edit-tests--obsolete-option-tag nil t))))
72
73(ert-deftest cus-edit-tests-customize-saved/show-obsolete ()
74 (with-cus-edit-test "*Customize Saved*"
75 (cl-letf (((get 'cus-edit-tests--obsolete-option-tag 'saved-value) '(t)))
76 (customize-saved)
77 (should (search-forward cus-edit-tests--obsolete-option-tag nil t)))))
78
79(provide 'cus-edit-tests)
80;;; cus-edit-tests.el ends here
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el
index 13cbedfe1f7..680aa514a27 100644
--- a/test/lisp/emacs-lisp/bytecomp-tests.el
+++ b/test/lisp/emacs-lisp/bytecomp-tests.el
@@ -516,19 +516,25 @@ Subtests signal errors if something goes wrong."
516 ;; Should not warn that mt--test2 is not known to be defined. 516 ;; Should not warn that mt--test2 is not known to be defined.
517 (should-not (re-search-forward "my--test2" nil t)))) 517 (should-not (re-search-forward "my--test2" nil t))))
518 518
519(defmacro bytecomp--with-warning-test (re-warning &rest form)
520 (declare (indent 1))
521 `(with-current-buffer (get-buffer-create "*Compile-Log*")
522 (let ((inhibit-read-only t)) (erase-buffer))
523 (byte-compile ,@form)
524 (ert-info ((buffer-string) :prefix "buffer: ")
525 (should (re-search-forward ,re-warning)))))
526
519(ert-deftest bytecomp-warn-wrong-args () 527(ert-deftest bytecomp-warn-wrong-args ()
520 (with-current-buffer (get-buffer-create "*Compile-Log*") 528 (bytecomp--with-warning-test "remq.*3.*2"
521 (let ((inhibit-read-only t)) (erase-buffer)) 529 '(remq 1 2 3)))
522 (byte-compile '(remq 1 2 3))
523 (ert-info ((buffer-string) :prefix "buffer: ")
524 (should (re-search-forward "remq.*3.*2")))))
525 530
526(ert-deftest bytecomp-warn-wrong-args-subr () 531(ert-deftest bytecomp-warn-wrong-args-subr ()
527 (with-current-buffer (get-buffer-create "*Compile-Log*") 532 (bytecomp--with-warning-test "safe-length.*3.*1"
528 (let ((inhibit-read-only t)) (erase-buffer)) 533 '(safe-length 1 2 3)))
529 (byte-compile '(safe-length 1 2 3)) 534
530 (ert-info ((buffer-string) :prefix "buffer: ") 535(ert-deftest bytecomp-warn-variable-lacks-prefix ()
531 (should (re-search-forward "safe-length.*3.*1"))))) 536 (bytecomp--with-warning-test "foo.*lacks a prefix"
537 '(defvar foo nil)))
532 538
533(ert-deftest test-eager-load-macro-expansion () 539(ert-deftest test-eager-load-macro-expansion ()
534 (test-byte-comp-compile-and-load nil 540 (test-byte-comp-compile-and-load nil
@@ -810,6 +816,12 @@ literals (Bug#20852)."
810 816
811 (test-suppression 817 (test-suppression
812 '(defun zot () 818 '(defun zot ()
819 (next-line))
820 '((interactive-only next-line))
821 "interactive use only")
822
823 (test-suppression
824 '(defun zot ()
813 (mapcar #'list '(1 2 3)) 825 (mapcar #'list '(1 2 3))
814 nil) 826 nil)
815 '((mapcar mapcar)) 827 '((mapcar mapcar))
diff --git a/test/lisp/help-tests.el b/test/lisp/help-tests.el
index 42be0296c4f..49cb40b29d9 100644
--- a/test/lisp/help-tests.el
+++ b/test/lisp/help-tests.el
@@ -392,6 +392,12 @@ C-b undefined
392 (define-key global-map (kbd "C-c C-l r") nil) 392 (define-key global-map (kbd "C-c C-l r") nil)
393 (define-key global-map (kbd "C-c C-l") nil))) 393 (define-key global-map (kbd "C-c C-l") nil)))
394 394
395(ert-deftest help-substitute-command-keys/preserves-text-properties ()
396 "Check that we preserve text properties (Bug#17052)."
397 (should (equal (substitute-command-keys
398 (propertize "foo \\[save-buffer]" 'face 'bold))
399 (propertize "foo C-x C-s" 'face 'bold))))
400
395(provide 'help-tests) 401(provide 'help-tests)
396 402
397;;; help-tests.el ends here 403;;; help-tests.el ends here
diff --git a/test/lisp/progmodes/cperl-mode-resources/cperl-bug-26850.pl b/test/lisp/progmodes/cperl-mode-resources/cperl-bug-26850.pl
new file mode 100644
index 00000000000..a02ea29fe9d
--- /dev/null
+++ b/test/lisp/progmodes/cperl-mode-resources/cperl-bug-26850.pl
@@ -0,0 +1,16 @@
1sub interesting {
2 $_ = shift;
3 return
4 />Today is .+\'s birthday\.</
5 || / like[ds]? your post in </
6 || /like[ds] your new subscription\. </
7 || / likes? that you're interested in </
8 || /> likes? your comment: /
9 || /&amp;birthdays=.*birthdays?\.<\/a>/;
10}
11
12sub boring {
13 return
14 / likes? your post in </
15 || / likes? that you're interested in </
16}
diff --git a/test/lisp/progmodes/cperl-mode-tests.el b/test/lisp/progmodes/cperl-mode-tests.el
index a0dd391840f..896160bb883 100644
--- a/test/lisp/progmodes/cperl-mode-tests.el
+++ b/test/lisp/progmodes/cperl-mode-tests.el
@@ -228,6 +228,21 @@ documentation it does the right thing anyway."
228 (cperl-indent-command) 228 (cperl-indent-command)
229 (forward-line 1)))) 229 (forward-line 1))))
230 230
231(ert-deftest cperl-test-bug-28650 ()
232 "Verify that regular expressions are recognized after 'return'.
233The test uses the syntax property \"inside a string\" for the
234text in regular expressions, which is non-nil for both cperl-mode
235and perl-mode."
236 (with-temp-buffer
237 (insert-file-contents (ert-resource-file "cperl-bug-26850.pl"))
238 (goto-char (point-min))
239 (re-search-forward "sub interesting {[^}]*}")
240 (should-not (equal (nth 3 (cperl-test-ppss (match-string 0) "Today"))
241 nil))
242 (re-search-forward "sub boring {[^}]*}")
243 (should-not (equal (nth 3 (cperl-test-ppss (match-string 0) "likes\\?"))
244 nil))))
245
231(ert-deftest cperl-test-bug-30393 () 246(ert-deftest cperl-test-bug-30393 ()
232 "Verify that indentation is not disturbed by an open paren in col 0. 247 "Verify that indentation is not disturbed by an open paren in col 0.
233Perl is not Lisp: An open paren in column 0 does not start a function." 248Perl is not Lisp: An open paren in column 0 does not start a function."
diff --git a/test/manual/etags/ETAGS.good_1 b/test/manual/etags/ETAGS.good_1
index 5451a79efaa..3de15514e79 100644
--- a/test/manual/etags/ETAGS.good_1
+++ b/test/manual/etags/ETAGS.good_1
@@ -3153,13 +3153,13 @@ tex-src/gzip.texi,303
3153@node Top,62,2139 3153@node Top,62,2139
3154@node Copying,80,2652 3154@node Copying,80,2652
3155@node Overview,83,2705 3155@node Overview,83,2705
3156@node Sample,166,7272 3156@node Sample,166,7273
3157@node Invoking gzip,Invoking gzip210,8828 3157@node Invoking gzip,Invoking gzip210,8829
3158@node Advanced usage,Advanced usage357,13496 3158@node Advanced usage,Advanced usage357,13497
3159@node Environment,420,15208 3159@node Environment,420,15209
3160@node Tapes,437,15769 3160@node Tapes,437,15770
3161@node Problems,460,16768 3161@node Problems,460,16769
3162@node Concept Index,Concept Index473,17288 3162@node Concept Index,Concept Index473,17289
3163 3163
3164tex-src/texinfo.tex,30627 3164tex-src/texinfo.tex,30627
3165\def\texinfoversion{\texinfoversion26,1035 3165\def\texinfoversion{\texinfoversion26,1035
diff --git a/test/manual/etags/ETAGS.good_2 b/test/manual/etags/ETAGS.good_2
index ab2111eafb2..ddb8d19540b 100644
--- a/test/manual/etags/ETAGS.good_2
+++ b/test/manual/etags/ETAGS.good_2
@@ -3726,13 +3726,13 @@ tex-src/gzip.texi,303
3726@node Top,62,2139 3726@node Top,62,2139
3727@node Copying,80,2652 3727@node Copying,80,2652
3728@node Overview,83,2705 3728@node Overview,83,2705
3729@node Sample,166,7272 3729@node Sample,166,7273
3730@node Invoking gzip,Invoking gzip210,8828 3730@node Invoking gzip,Invoking gzip210,8829
3731@node Advanced usage,Advanced usage357,13496 3731@node Advanced usage,Advanced usage357,13497
3732@node Environment,420,15208 3732@node Environment,420,15209
3733@node Tapes,437,15769 3733@node Tapes,437,15770
3734@node Problems,460,16768 3734@node Problems,460,16769
3735@node Concept Index,Concept Index473,17288 3735@node Concept Index,Concept Index473,17289
3736 3736
3737tex-src/texinfo.tex,30627 3737tex-src/texinfo.tex,30627
3738\def\texinfoversion{\texinfoversion26,1035 3738\def\texinfoversion{\texinfoversion26,1035
diff --git a/test/manual/etags/ETAGS.good_3 b/test/manual/etags/ETAGS.good_3
index e53fb9629c5..40be768aacb 100644
--- a/test/manual/etags/ETAGS.good_3
+++ b/test/manual/etags/ETAGS.good_3
@@ -3560,13 +3560,13 @@ tex-src/gzip.texi,303
3560@node Top,62,2139 3560@node Top,62,2139
3561@node Copying,80,2652 3561@node Copying,80,2652
3562@node Overview,83,2705 3562@node Overview,83,2705
3563@node Sample,166,7272 3563@node Sample,166,7273
3564@node Invoking gzip,Invoking gzip210,8828 3564@node Invoking gzip,Invoking gzip210,8829
3565@node Advanced usage,Advanced usage357,13496 3565@node Advanced usage,Advanced usage357,13497
3566@node Environment,420,15208 3566@node Environment,420,15209
3567@node Tapes,437,15769 3567@node Tapes,437,15770
3568@node Problems,460,16768 3568@node Problems,460,16769
3569@node Concept Index,Concept Index473,17288 3569@node Concept Index,Concept Index473,17289
3570 3570
3571tex-src/texinfo.tex,30627 3571tex-src/texinfo.tex,30627
3572\def\texinfoversion{\texinfoversion26,1035 3572\def\texinfoversion{\texinfoversion26,1035
diff --git a/test/manual/etags/ETAGS.good_4 b/test/manual/etags/ETAGS.good_4
index 5a4b5b4b8ba..15f67c5d28a 100644
--- a/test/manual/etags/ETAGS.good_4
+++ b/test/manual/etags/ETAGS.good_4
@@ -3317,13 +3317,13 @@ tex-src/gzip.texi,303
3317@node Top,62,2139 3317@node Top,62,2139
3318@node Copying,80,2652 3318@node Copying,80,2652
3319@node Overview,83,2705 3319@node Overview,83,2705
3320@node Sample,166,7272 3320@node Sample,166,7273
3321@node Invoking gzip,Invoking gzip210,8828 3321@node Invoking gzip,Invoking gzip210,8829
3322@node Advanced usage,Advanced usage357,13496 3322@node Advanced usage,Advanced usage357,13497
3323@node Environment,420,15208 3323@node Environment,420,15209
3324@node Tapes,437,15769 3324@node Tapes,437,15770
3325@node Problems,460,16768 3325@node Problems,460,16769
3326@node Concept Index,Concept Index473,17288 3326@node Concept Index,Concept Index473,17289
3327 3327
3328tex-src/texinfo.tex,30627 3328tex-src/texinfo.tex,30627
3329\def\texinfoversion{\texinfoversion26,1035 3329\def\texinfoversion{\texinfoversion26,1035
diff --git a/test/manual/etags/ETAGS.good_5 b/test/manual/etags/ETAGS.good_5
index f89cfefc388..583de5cbe22 100644
--- a/test/manual/etags/ETAGS.good_5
+++ b/test/manual/etags/ETAGS.good_5
@@ -4297,13 +4297,13 @@ tex-src/gzip.texi,303
4297@node Top,62,2139 4297@node Top,62,2139
4298@node Copying,80,2652 4298@node Copying,80,2652
4299@node Overview,83,2705 4299@node Overview,83,2705
4300@node Sample,166,7272 4300@node Sample,166,7273
4301@node Invoking gzip,Invoking gzip210,8828 4301@node Invoking gzip,Invoking gzip210,8829
4302@node Advanced usage,Advanced usage357,13496 4302@node Advanced usage,Advanced usage357,13497
4303@node Environment,420,15208 4303@node Environment,420,15209
4304@node Tapes,437,15769 4304@node Tapes,437,15770
4305@node Problems,460,16768 4305@node Problems,460,16769
4306@node Concept Index,Concept Index473,17288 4306@node Concept Index,Concept Index473,17289
4307 4307
4308tex-src/texinfo.tex,30627 4308tex-src/texinfo.tex,30627
4309\def\texinfoversion{\texinfoversion26,1035 4309\def\texinfoversion{\texinfoversion26,1035
diff --git a/test/manual/etags/ETAGS.good_6 b/test/manual/etags/ETAGS.good_6
index 0a31ed078e8..86df93afab1 100644
--- a/test/manual/etags/ETAGS.good_6
+++ b/test/manual/etags/ETAGS.good_6
@@ -4297,13 +4297,13 @@ tex-src/gzip.texi,303
4297@node Top,62,2139 4297@node Top,62,2139
4298@node Copying,80,2652 4298@node Copying,80,2652
4299@node Overview,83,2705 4299@node Overview,83,2705
4300@node Sample,166,7272 4300@node Sample,166,7273
4301@node Invoking gzip,Invoking gzip210,8828 4301@node Invoking gzip,Invoking gzip210,8829
4302@node Advanced usage,Advanced usage357,13496 4302@node Advanced usage,Advanced usage357,13497
4303@node Environment,420,15208 4303@node Environment,420,15209
4304@node Tapes,437,15769 4304@node Tapes,437,15770
4305@node Problems,460,16768 4305@node Problems,460,16769
4306@node Concept Index,Concept Index473,17288 4306@node Concept Index,Concept Index473,17289
4307 4307
4308tex-src/texinfo.tex,30627 4308tex-src/texinfo.tex,30627
4309\def\texinfoversion{\texinfoversion26,1035 4309\def\texinfoversion{\texinfoversion26,1035
diff --git a/test/manual/indent/tcl.tcl b/test/manual/indent/tcl.tcl
index c3781533ca4..f055be19663 100644
--- a/test/manual/indent/tcl.tcl
+++ b/test/manual/indent/tcl.tcl
@@ -20,3 +20,7 @@ proc foo3 {} {
20 puts a""b"; # And that won't either! 20 puts a""b"; # And that won't either!
21 puts "a""b"; # But this will! 21 puts "a""b"; # But this will!
22} 22}
23
24# FIXME: The [..] interpolation within "..." strings is not properly
25# handled by the current `syntax-propertize-function`!
26set a "Testing: [split "192.168.1.1/24" "/"] address";
diff --git a/test/src/data-tests.el b/test/src/data-tests.el
index ed092039078..1312683c848 100644
--- a/test/src/data-tests.el
+++ b/test/src/data-tests.el
@@ -345,6 +345,25 @@ comparing the subr with a much slower lisp implementation."
345 (setq-default binding-test-some-local 'new-default)) 345 (setq-default binding-test-some-local 'new-default))
346 (should (eq binding-test-some-local 'some)))) 346 (should (eq binding-test-some-local 'some))))
347 347
348(ert-deftest data-tests--let-buffer-local ()
349 (let ((blvar (make-symbol "blvar")))
350 (set-default blvar nil)
351 (make-variable-buffer-local blvar)
352
353 (dolist (var (list blvar 'left-margin))
354 (let ((def (default-value var)))
355 (with-temp-buffer
356 (should (equal def (symbol-value var)))
357 (cl-progv (list var) (list 42)
358 (should (equal (symbol-value var) 42))
359 (should (equal (default-value var) (symbol-value var)))
360 (set var 123)
361 (should (equal (symbol-value var) 123))
362 (should (equal (default-value var) (symbol-value var)))) ;bug#44733
363 (should (equal (symbol-value var) def))
364 (should (equal (default-value var) (symbol-value var))))
365 (should (equal (default-value var) def))))))
366
348(ert-deftest binding-test-makunbound () 367(ert-deftest binding-test-makunbound ()
349 "Tests of makunbound, from the manual." 368 "Tests of makunbound, from the manual."
350 (with-current-buffer binding-test-buffer-B 369 (with-current-buffer binding-test-buffer-B
@@ -381,6 +400,37 @@ comparing the subr with a much slower lisp implementation."
381 "Test setting a keyword to itself" 400 "Test setting a keyword to itself"
382 (with-no-warnings (should (setq :keyword :keyword)))) 401 (with-no-warnings (should (setq :keyword :keyword))))
383 402
403(ert-deftest data-tests--set-default-per-buffer ()
404 :expected-result t ;; Not fixed yet!
405 ;; FIXME: Performance tests are inherently unreliable.
406 ;; Using wall-clock time makes it even worse, so don't bother unless
407 ;; we have the primitive to measure cpu-time.
408 (skip-unless (fboundp 'current-cpu-time))
409 ;; Test performance of set-default on DEFVAR_PER_BUFFER variables.
410 ;; More specifically, test the problem seen in bug#41029 where setting
411 ;; the default value of a variable takes time proportional to the
412 ;; number of buffers.
413 (let* ((fun #'error)
414 (test (lambda ()
415 (with-temp-buffer
416 (let ((st (car (current-cpu-time))))
417 (dotimes (_ 1000)
418 (let ((case-fold-search 'data-test))
419 ;; Use an indirection through a mutable var
420 ;; to try and make sure the byte-compiler
421 ;; doesn't optimize away the let bindings.
422 (funcall fun)))
423 ;; FIXME: Handle the wraparound, if any.
424 (- (car (current-cpu-time)) st)))))
425 (_ (setq fun #'ignore))
426 (time1 (funcall test))
427 (bufs (mapcar (lambda (_) (generate-new-buffer " data-test"))
428 (make-list 1000 nil)))
429 (time2 (funcall test)))
430 (mapc #'kill-buffer bufs)
431 ;; Don't divide one time by the other since they may be 0.
432 (should (< time2 (* time1 5)))))
433
384;; More tests to write - 434;; More tests to write -
385;; kill-local-variable 435;; kill-local-variable
386;; defconst; can modify 436;; defconst; can modify
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el
index d3c22f966e6..86b8d655d26 100644
--- a/test/src/fns-tests.el
+++ b/test/src/fns-tests.el
@@ -938,6 +938,13 @@
938 (should (equal (string-search "\303" "aøb") nil)) 938 (should (equal (string-search "\303" "aøb") nil))
939 (should (equal (string-search "\270" "aøb") nil)) 939 (should (equal (string-search "\270" "aøb") nil))
940 (should (equal (string-search "ø" "\303\270") nil)) 940 (should (equal (string-search "ø" "\303\270") nil))
941 (should (equal (string-search "ø" (make-string 32 ?a)) nil))
942 (should (equal (string-search "ø" (string-to-multibyte (make-string 32 ?a)))
943 nil))
944 (should (equal (string-search "o" (string-to-multibyte
945 (apply #'string
946 (number-sequence ?a ?z))))
947 14))
941 948
942 (should (equal (string-search "a\U00010f98z" "a\U00010f98a\U00010f98z") 2)) 949 (should (equal (string-search "a\U00010f98z" "a\U00010f98a\U00010f98z") 2))
943 950
diff --git a/test/src/keymap-tests.el b/test/src/keymap-tests.el
index e3dd8420d7b..6411cd1f0d4 100644
--- a/test/src/keymap-tests.el
+++ b/test/src/keymap-tests.el
@@ -54,6 +54,15 @@
54(ert-deftest keymap-copy-keymap/is-not-eq () 54(ert-deftest keymap-copy-keymap/is-not-eq ()
55 (should-not (eq (copy-keymap help-mode-map) help-mode-map))) 55 (should-not (eq (copy-keymap help-mode-map) help-mode-map)))
56 56
57(ert-deftest keymap---get-keyelt/runs-menu-item-filter ()
58 (let* (menu-item-filter-ran
59 (object `(menu-item "2" identity
60 :filter ,(lambda (cmd)
61 (setq menu-item-filter-ran t)
62 cmd))))
63 (keymap--get-keyelt object t)
64 (should menu-item-filter-ran)))
65
57(ert-deftest keymap-lookup-key () 66(ert-deftest keymap-lookup-key ()
58 (let ((map (make-keymap))) 67 (let ((map (make-keymap)))
59 (define-key map [?a] 'foo) 68 (define-key map [?a] 'foo)
@@ -72,6 +81,26 @@ https://debbugs.gnu.org/39149#31"
72 (with-temp-buffer 81 (with-temp-buffer
73 (should (eq (describe-buffer-bindings (current-buffer)) nil)))) 82 (should (eq (describe-buffer-bindings (current-buffer)) nil))))
74 83
84(defun keymap-tests--test-menu-item-filter (show filter-fun)
85 (unwind-protect
86 (progn
87 (define-key global-map (kbd "C-c C-l r")
88 `(menu-item "2" identity :filter ,filter-fun))
89 (with-temp-buffer
90 (describe-buffer-bindings (current-buffer))
91 (goto-char (point-min))
92 (if (eq show 'show)
93 (should (search-forward "C-c C-l r" nil t))
94 (should-not (search-forward "C-c C-l r" nil t)))))
95 (define-key global-map (kbd "C-c C-l r") nil)
96 (define-key global-map (kbd "C-c C-l") nil)))
97
98(ert-deftest describe-buffer-bindings/menu-item-filter-show-binding ()
99 (keymap-tests--test-menu-item-filter 'show (lambda (cmd) cmd)))
100
101(ert-deftest describe-buffer-bindings/menu-item-filter-hide-binding ()
102 (keymap-tests--test-menu-item-filter 'hide (lambda (_) nil)))
103
75(ert-deftest keymap-store_in_keymap-XFASTINT-on-non-characters () 104(ert-deftest keymap-store_in_keymap-XFASTINT-on-non-characters ()
76 "Check for bug fixed in \"Fix assertion violation in define-key\", 105 "Check for bug fixed in \"Fix assertion violation in define-key\",
77commit 86c19714b097aa477d339ed99ffb5136c755a046." 106commit 86c19714b097aa477d339ed99ffb5136c755a046."
@@ -170,6 +199,58 @@ commit 86c19714b097aa477d339ed99ffb5136c755a046."
170 (where-is-internal 'execute-extended-command global-map t)) 199 (where-is-internal 'execute-extended-command global-map t))
171 [#x8000078]))) 200 [#x8000078])))
172 201
202
203;;;; describe_vector
204
205(ert-deftest help--describe-vector/bug-9293-one-shadowed-in-range ()
206 "Check that we only show a range if shadowed by the same command."
207 (let ((orig-map (let ((map (make-keymap)))
208 (define-key map "e" 'foo)
209 (define-key map "f" 'foo)
210 (define-key map "g" 'foo)
211 (define-key map "h" 'foo)
212 map))
213 (shadow-map (let ((map (make-keymap)))
214 (define-key map "f" 'bar)
215 map))
216 (text-quoting-style 'grave))
217 (with-temp-buffer
218 (help--describe-vector (cadr orig-map) nil #'help--describe-command
219 t shadow-map orig-map t)
220 (should (equal (buffer-string)
221 "
222e foo
223f foo (currently shadowed by `bar')
224g .. h foo
225")))))
226
227(ert-deftest help--describe-vector/bug-9293-same-command-does-not-shadow ()
228 "Check that a command can't be shadowed by the same command."
229 (let ((range-map
230 (let ((map (make-keymap)))
231 (define-key map "0" 'foo)
232 (define-key map "1" 'foo)
233 (define-key map "2" 'foo)
234 (define-key map "3" 'foo)
235 map))
236 (shadow-map
237 (let ((map (make-keymap)))
238 (define-key map "0" 'foo)
239 (define-key map "1" 'foo)
240 (define-key map "2" 'foo)
241 (define-key map "3" 'foo)
242 map)))
243 (with-temp-buffer
244 (help--describe-vector (cadr range-map) nil #'help--describe-command
245 t shadow-map range-map t)
246 (should (equal (buffer-string)
247 "
2480 .. 3 foo
249")))))
250
251
252;;;; apropos-internal
253
173(ert-deftest keymap-apropos-internal () 254(ert-deftest keymap-apropos-internal ()
174 (should (equal (apropos-internal "^next-line$") '(next-line))) 255 (should (equal (apropos-internal "^next-line$") '(next-line)))
175 (should (>= (length (apropos-internal "^help")) 100)) 256 (should (>= (length (apropos-internal "^help")) 100))
diff --git a/test/src/syntax-resources/syntax-comments.txt b/test/src/syntax-resources/syntax-comments.txt
index 6f595e4d8dc..a292d816b9d 100644
--- a/test/src/syntax-resources/syntax-comments.txt
+++ b/test/src/syntax-resources/syntax-comments.txt
@@ -62,7 +62,33 @@
6233; \ 6233; \
6333 6333
64 64
65/* Lisp comments within lists */
6640)40
6741(;90 comment
6891)41
6942(;92\
7093)42
7143( ;94
7295
73
74/* Nested Lisp comments */
75100|#100
76101#|#
77102#||#102
78103#| Comment |#103
79104#| Comment
80|#104
81105#|#|#105
82106#| #| Comment |# |#106
83107#|#|#|#|#|#|#|#|#| Comment |#|#|#|#|#|#|#|#|#107
84
85/* Mixed Lisp comments */
86110; #|
87110
88111#| ; |#111
89
65Local Variables: 90Local Variables:
66mode: fundamental 91mode: fundamental
67eval: (set-syntax-table (make-syntax-table)) 92eval: (set-syntax-table (make-syntax-table))
68End: 93End:
94999 \ No newline at end of file
diff --git a/test/src/syntax-tests.el b/test/src/syntax-tests.el
index 4b9c3f277aa..edee01ec585 100644
--- a/test/src/syntax-tests.el
+++ b/test/src/syntax-tests.el
@@ -220,7 +220,7 @@ missing or nil, the value of -START- is assumed for it."
220 (cond 220 (cond
221 ((eq -dir- 'forward) t) 221 ((eq -dir- 'forward) t)
222 ((eq -dir- 'backward) nil) 222 ((eq -dir- 'backward) nil)
223 (t (error "Invalid -dir- argument \"%s\" to `syntax-comments'" -dir-)))) 223 (t (error "Invalid -dir- argument \"%s\" to `syntax-br-comments'" -dir-))))
224 (start -start-) 224 (start -start-)
225 (start-str (format "%d" (abs start))) 225 (start-str (format "%d" (abs start)))
226 (type -type-)) 226 (type -type-))
@@ -338,10 +338,14 @@ the `parse-partial-sexp's are expected to stop. See
338 (setq parse-sexp-ignore-comments t) 338 (setq parse-sexp-ignore-comments t)
339 (setq comment-end-can-be-escaped nil) 339 (setq comment-end-can-be-escaped nil)
340 (modify-syntax-entry ?\n ">") 340 (modify-syntax-entry ?\n ">")
341 (modify-syntax-entry ?\; "<")) 341 (modify-syntax-entry ?\; "<")
342 (modify-syntax-entry ?{ ".")
343 (modify-syntax-entry ?} "."))
342(defun \;-out () 344(defun \;-out ()
343 (modify-syntax-entry ?\n " ") 345 (modify-syntax-entry ?\n " ")
344 (modify-syntax-entry ?\; ".")) 346 (modify-syntax-entry ?\; ".")
347 (modify-syntax-entry ?{ "(}")
348 (modify-syntax-entry ?} "){"))
345(eval-and-compile 349(eval-and-compile
346 (setq syntax-comments-section "lisp")) 350 (setq syntax-comments-section "lisp"))
347 351
@@ -353,6 +357,62 @@ the `parse-partial-sexp's are expected to stop. See
353(syntax-comments \; forward t 33) 357(syntax-comments \; forward t 33)
354(syntax-comments \; backward t 33) 358(syntax-comments \; backward t 33)
355 359
360;; "Lisp" style comments inside lists.
361(syntax-br-comments \; backward nil 40)
362(syntax-br-comments \; forward t 41)
363(syntax-br-comments \; backward t 41)
364(syntax-br-comments \; forward t 42)
365(syntax-br-comments \; backward t 42)
366(syntax-br-comments \; forward nil 43)
367
368;; "Lisp" style comments parsed by `parse-partial-sexp'.
369(syntax-pps-comments \; 41 90 91)
370(syntax-pps-comments \; 42 92 93)
371(syntax-pps-comments \; 43 94 95 -999)
372
373;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
374;; "Lisp" style nested comments: between delimiters #| |#.
375;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
376(defun \#|-in ()
377 (setq parse-sexp-ignore-comments t)
378 (modify-syntax-entry ?# ". 14")
379 (modify-syntax-entry ?| ". 23n")
380 (modify-syntax-entry ?\; "< b")
381 (modify-syntax-entry ?\n "> b"))
382(defun \#|-out ()
383 (modify-syntax-entry ?# ".")
384 (modify-syntax-entry ?| ".")
385 (modify-syntax-entry ?\; ".")
386 (modify-syntax-entry ?\n " "))
387(eval-and-compile
388 (setq syntax-comments-section "lisp-n"))
389
390(syntax-comments \#| forward nil 100 0)
391(syntax-comments \#| backward nil 100 0)
392(syntax-comments \#| forward nil 101 -999)
393(syntax-comments \#| forward t 102)
394(syntax-comments \#| backward t 102)
395
396(syntax-comments \#| forward t 103)
397(syntax-comments \#| backward t 103)
398(syntax-comments \#| forward t 104)
399(syntax-comments \#| backward t 104)
400
401(syntax-comments \#| forward nil 105 -999)
402(syntax-comments \#| backward t 105)
403(syntax-comments \#| forward t 106)
404(syntax-comments \#| backward t 106)
405(syntax-comments \#| forward t 107)
406(syntax-comments \#| backward t 107)
407
408;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
409;; Mixed "Lisp" style (nested and unnested) comments.
410;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
411(syntax-comments \#| forward t 110)
412(syntax-comments \#| backward t 110)
413(syntax-comments \#| forward t 111)
414(syntax-comments \#| backward t 111)
415
356;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 416;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
357;; Emacs 27 "C" style comments - `comment-end-can-be-escaped' is non-nil. 417;; Emacs 27 "C" style comments - `comment-end-can-be-escaped' is non-nil.
358;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 418;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;