diff options
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/data-tests.el | 50 | ||||
| -rw-r--r-- | test/src/fns-tests.el | 7 | ||||
| -rw-r--r-- | test/src/keymap-tests.el | 81 | ||||
| -rw-r--r-- | test/src/syntax-resources/syntax-comments.txt | 26 | ||||
| -rw-r--r-- | test/src/syntax-tests.el | 66 |
5 files changed, 227 insertions, 3 deletions
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\", |
| 77 | commit 86c19714b097aa477d339ed99ffb5136c755a046." | 106 | commit 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 | " | ||
| 222 | e foo | ||
| 223 | f foo (currently shadowed by `bar') | ||
| 224 | g .. 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 | " | ||
| 248 | 0 .. 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 @@ | |||
| 62 | 33; \ | 62 | 33; \ |
| 63 | 33 | 63 | 33 |
| 64 | 64 | ||
| 65 | /* Lisp comments within lists */ | ||
| 66 | 40)40 | ||
| 67 | 41(;90 comment | ||
| 68 | 91)41 | ||
| 69 | 42(;92\ | ||
| 70 | 93)42 | ||
| 71 | 43( ;94 | ||
| 72 | 95 | ||
| 73 | |||
| 74 | /* Nested Lisp comments */ | ||
| 75 | 100|#100 | ||
| 76 | 101#|# | ||
| 77 | 102#||#102 | ||
| 78 | 103#| Comment |#103 | ||
| 79 | 104#| Comment | ||
| 80 | |#104 | ||
| 81 | 105#|#|#105 | ||
| 82 | 106#| #| Comment |# |#106 | ||
| 83 | 107#|#|#|#|#|#|#|#|#| Comment |#|#|#|#|#|#|#|#|#107 | ||
| 84 | |||
| 85 | /* Mixed Lisp comments */ | ||
| 86 | 110; #| | ||
| 87 | 110 | ||
| 88 | 111#| ; |#111 | ||
| 89 | |||
| 65 | Local Variables: | 90 | Local Variables: |
| 66 | mode: fundamental | 91 | mode: fundamental |
| 67 | eval: (set-syntax-table (make-syntax-table)) | 92 | eval: (set-syntax-table (make-syntax-table)) |
| 68 | End: | 93 | End: |
| 94 | 999 \ 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 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |