diff options
| author | Andrea Corallo | 2020-09-26 15:31:50 +0200 |
|---|---|---|
| committer | Andrea Corallo | 2020-09-26 15:31:50 +0200 |
| commit | 06acf681d6fd8e2c5c6a9584b5df6b98eccda20b (patch) | |
| tree | 5cc7132156db6b77599a86072de21a036828bcf4 /test/src | |
| parent | e5b052d60d905209c6cefcf18c620167ed946301 (diff) | |
| parent | e00936bf9f10cf44e1df71a7a11afd770e8a122a (diff) | |
| download | emacs-06acf681d6fd8e2c5c6a9584b5df6b98eccda20b.tar.gz emacs-06acf681d6fd8e2c5c6a9584b5df6b98eccda20b.zip | |
Merge remote-tracking branch 'savannah/master' into HEAD
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/fns-tests.el | 59 | ||||
| -rw-r--r-- | test/src/xdisp-tests.el | 52 | ||||
| -rw-r--r-- | test/src/xml-tests.el | 21 |
3 files changed, 109 insertions, 23 deletions
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el index b9a7d29895a..f2e1a268b08 100644 --- a/test/src/fns-tests.el +++ b/test/src/fns-tests.el | |||
| @@ -166,6 +166,8 @@ | |||
| 166 | (should (equal (should-error (sort "cba" #'<) :type 'wrong-type-argument) | 166 | (should (equal (should-error (sort "cba" #'<) :type 'wrong-type-argument) |
| 167 | '(wrong-type-argument list-or-vector-p "cba")))) | 167 | '(wrong-type-argument list-or-vector-p "cba")))) |
| 168 | 168 | ||
| 169 | (defvar w32-collate-ignore-punctuation) | ||
| 170 | |||
| 169 | (ert-deftest fns-tests-collate-sort () | 171 | (ert-deftest fns-tests-collate-sort () |
| 170 | (skip-unless (fns-tests--collate-enabled-p)) | 172 | (skip-unless (fns-tests--collate-enabled-p)) |
| 171 | 173 | ||
| @@ -228,9 +230,9 @@ | |||
| 228 | (should (equal (func-arity 'format) '(1 . many))) | 230 | (should (equal (func-arity 'format) '(1 . many))) |
| 229 | (require 'info) | 231 | (require 'info) |
| 230 | (should (equal (func-arity 'Info-goto-node) '(1 . 3))) | 232 | (should (equal (func-arity 'Info-goto-node) '(1 . 3))) |
| 231 | (should (equal (func-arity (lambda (&rest x))) '(0 . many))) | 233 | (should (equal (func-arity (lambda (&rest _x))) '(0 . many))) |
| 232 | (should (equal (func-arity (eval '(lambda (x &optional y)) nil)) '(1 . 2))) | 234 | (should (equal (func-arity (eval '(lambda (_x &optional y)) nil)) '(1 . 2))) |
| 233 | (should (equal (func-arity (eval '(lambda (x &optional y)) t)) '(1 . 2))) | 235 | (should (equal (func-arity (eval '(lambda (_x &optional y)) t)) '(1 . 2))) |
| 234 | (should (equal (func-arity 'let) '(1 . unevalled)))) | 236 | (should (equal (func-arity 'let) '(1 . unevalled)))) |
| 235 | 237 | ||
| 236 | (defun fns-tests--string-repeat (s o) | 238 | (defun fns-tests--string-repeat (s o) |
| @@ -901,3 +903,54 @@ | |||
| 901 | (should (equal (delete t [nil t]) [nil])) | 903 | (should (equal (delete t [nil t]) [nil])) |
| 902 | (should (equal (delete 1 v1) (vector))) | 904 | (should (equal (delete 1 v1) (vector))) |
| 903 | (should (equal (delete 2 v1) v1)))) | 905 | (should (equal (delete 2 v1) v1)))) |
| 906 | |||
| 907 | (ert-deftest string-search () | ||
| 908 | (should (equal (string-search "zot" "foobarzot") 6)) | ||
| 909 | (should (equal (string-search "foo" "foobarzot") 0)) | ||
| 910 | (should (not (string-search "fooz" "foobarzot"))) | ||
| 911 | (should (not (string-search "zot" "foobarzo"))) | ||
| 912 | (should (equal (string-search "ab" "ab") 0)) | ||
| 913 | (should (equal (string-search "ab\0" "ab") nil)) | ||
| 914 | (should (equal (string-search "ab" "abababab" 3) 4)) | ||
| 915 | (should (equal (string-search "ab" "ababac" 3) nil)) | ||
| 916 | (let ((case-fold-search t)) | ||
| 917 | (should (equal (string-search "ab" "AB") nil))) | ||
| 918 | |||
| 919 | (should (equal | ||
| 920 | (string-search (make-string 2 130) | ||
| 921 | (concat "helló" (make-string 5 130 t) "bár")) | ||
| 922 | 5)) | ||
| 923 | (should (equal | ||
| 924 | (string-search (make-string 2 127) | ||
| 925 | (concat "helló" (make-string 5 127 t) "bár")) | ||
| 926 | 5)) | ||
| 927 | |||
| 928 | (should (equal (string-search "\377" "a\377ø") 1)) | ||
| 929 | (should (equal (string-search "\377" "a\377a") 1)) | ||
| 930 | |||
| 931 | (should (not (string-search (make-string 1 255) "a\377ø"))) | ||
| 932 | (should (not (string-search (make-string 1 255) "a\377a"))) | ||
| 933 | |||
| 934 | (should (equal (string-search "fóo" "zotfóo") 3)) | ||
| 935 | |||
| 936 | (should (equal (string-search (string-to-multibyte "\377") "ab\377c") 2)) | ||
| 937 | (should (equal (string-search "\303" "aøb") nil)) | ||
| 938 | (should (equal (string-search "\270" "aøb") nil)) | ||
| 939 | ;; This test currently fails, but it shouldn't! | ||
| 940 | ;;(should (equal (string-search "ø" "\303\270") nil)) | ||
| 941 | |||
| 942 | (should-error (string-search "a" "abc" -1)) | ||
| 943 | (should-error (string-search "a" "abc" 4)) | ||
| 944 | (should-error (string-search "a" "abc" 100000000000)) | ||
| 945 | |||
| 946 | (should (equal (string-search "a" "aaa" 3) nil)) | ||
| 947 | (should (equal (string-search "\0" "") nil)) | ||
| 948 | |||
| 949 | (should (equal (string-search "" "") 0)) | ||
| 950 | (should-error (string-search "" "" 1)) | ||
| 951 | (should (equal (string-search "" "abc") 0)) | ||
| 952 | (should (equal (string-search "" "abc" 2) 2)) | ||
| 953 | (should (equal (string-search "" "abc" 3) 3)) | ||
| 954 | (should-error (string-search "" "abc" 4)) | ||
| 955 | (should-error (string-search "" "abc" -1)) | ||
| 956 | ) | ||
diff --git a/test/src/xdisp-tests.el b/test/src/xdisp-tests.el new file mode 100644 index 00000000000..3d0d0f58302 --- /dev/null +++ b/test/src/xdisp-tests.el | |||
| @@ -0,0 +1,52 @@ | |||
| 1 | ;;; xdisp-tests.el --- tests for xdisp.c functions -*- 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 | ;;; Code: | ||
| 21 | |||
| 22 | (require 'ert) | ||
| 23 | |||
| 24 | (ert-deftest xdisp-tests--minibuffer-resizing () ;; bug#43519 | ||
| 25 | ;; FIXME: This test returns success when run in batch but | ||
| 26 | ;; it's only a lucky accident: it also returned success | ||
| 27 | ;; when bug#43519 was not fixed. | ||
| 28 | (should | ||
| 29 | (equal | ||
| 30 | t | ||
| 31 | (catch 'result | ||
| 32 | (minibuffer-with-setup-hook | ||
| 33 | (lambda () | ||
| 34 | (insert "hello") | ||
| 35 | (let ((ol (make-overlay (point) (point))) | ||
| 36 | (max-mini-window-height 1) | ||
| 37 | (text "askdjfhaklsjdfhlkasjdfhklasdhflkasdhflkajsdhflkashdfkljahsdlfkjahsdlfkjhasldkfhalskdjfhalskdfhlaksdhfklasdhflkasdhflkasdhflkajsdhklajsdgh")) | ||
| 38 | ;; (save-excursion (insert text)) | ||
| 39 | ;; (sit-for 2) | ||
| 40 | ;; (delete-region (point) (point-max)) | ||
| 41 | (put-text-property 0 1 'cursor t text) | ||
| 42 | (overlay-put ol 'after-string text) | ||
| 43 | (redisplay 'force) | ||
| 44 | (throw 'result | ||
| 45 | ;; Make sure we do the see "hello" text. | ||
| 46 | (prog1 (equal (window-start) (point-min)) | ||
| 47 | ;; (list (window-start) (window-end) (window-width)) | ||
| 48 | (delete-overlay ol))))) | ||
| 49 | (let ((executing-kbd-macro t)) ;Force real minibuffer in `read-string'. | ||
| 50 | (read-string "toto: "))))))) | ||
| 51 | |||
| 52 | ;;; xdisp-tests.el ends here | ||
diff --git a/test/src/xml-tests.el b/test/src/xml-tests.el index d758c8868cf..800f400b3ca 100644 --- a/test/src/xml-tests.el +++ b/test/src/xml-tests.el | |||
| @@ -42,20 +42,6 @@ | |||
| 42 | (comment nil "comment-b") (comment nil "comment-c")))) | 42 | (comment nil "comment-b") (comment nil "comment-c")))) |
| 43 | "Alist of XML strings and their expected parse trees for preserved comments.") | 43 | "Alist of XML strings and their expected parse trees for preserved comments.") |
| 44 | 44 | ||
| 45 | (defvar libxml-tests--data-comments-discarded | ||
| 46 | `(;; simple case | ||
| 47 | ("<?xml version=\"1.0\"?><foo baz=\"true\">bar</foo>" | ||
| 48 | . (foo ((baz . "true")) "bar")) | ||
| 49 | ;; toplevel comments -- first document child must not get lost | ||
| 50 | (,(concat "<?xml version=\"1.0\"?><foo>bar</foo><!--comment-1-->" | ||
| 51 | "<!--comment-2-->") | ||
| 52 | . (foo nil "bar")) | ||
| 53 | (,(concat "<?xml version=\"1.0\"?><!--comment-a--><foo a=\"b\">" | ||
| 54 | "<bar>blub</bar></foo><!--comment-b--><!--comment-c-->") | ||
| 55 | . (foo ((a . "b")) (bar nil "blub")))) | ||
| 56 | "Alist of XML strings and their expected parse trees for discarded comments.") | ||
| 57 | |||
| 58 | |||
| 59 | (ert-deftest libxml-tests () | 45 | (ert-deftest libxml-tests () |
| 60 | "Test libxml." | 46 | "Test libxml." |
| 61 | (when (fboundp 'libxml-parse-xml-region) | 47 | (when (fboundp 'libxml-parse-xml-region) |
| @@ -64,11 +50,6 @@ | |||
| 64 | (erase-buffer) | 50 | (erase-buffer) |
| 65 | (insert (car test)) | 51 | (insert (car test)) |
| 66 | (should (equal (cdr test) | 52 | (should (equal (cdr test) |
| 67 | (libxml-parse-xml-region (point-min) (point-max))))) | 53 | (libxml-parse-xml-region (point-min) (point-max)))))))) |
| 68 | (dolist (test libxml-tests--data-comments-discarded) | ||
| 69 | (erase-buffer) | ||
| 70 | (insert (car test)) | ||
| 71 | (should (equal (cdr test) | ||
| 72 | (libxml-parse-xml-region (point-min) (point-max) nil t))))))) | ||
| 73 | 54 | ||
| 74 | ;;; libxml-tests.el ends here | 55 | ;;; libxml-tests.el ends here |