diff options
author | Vibhav Pant <vibhavp@gmail.com> | 2020-08-21 14:04:35 +0530 |
---|---|---|
committer | Vibhav Pant <vibhavp@gmail.com> | 2020-08-21 14:04:35 +0530 |
commit | f0f8d7b82492e741950c363a03b886965c91b1b0 (patch) | |
tree | 19b716830b1ebabc0d7d75949c4e6800c0f104ad /test/lisp | |
parent | 9e64a087c4d167e7ec1c4e22bea3e6af53b563de (diff) | |
parent | c818c29771d3cb51875643b2f6c894073e429dd2 (diff) | |
download | emacs-feature/native-comp-macos-fixes.tar.gz |
Merge branch 'feature/native-comp' into feature/native-comp-macos-fixesfeature/native-comp-macos-fixes
Diffstat (limited to 'test/lisp')
-rw-r--r-- | test/lisp/cedet/srecode-utest-template.el | 5 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/bytecomp-tests.el | 43 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/cl-lib-tests.el | 16 | ||||
-rw-r--r-- | test/lisp/ffap-tests.el | 40 | ||||
-rw-r--r-- | test/lisp/mail/flow-fill-tests.el | 3 | ||||
-rw-r--r-- | test/lisp/progmodes/compile-tests.el | 4 | ||||
-rw-r--r-- | test/lisp/progmodes/cperl-mode-tests.el | 51 | ||||
-rw-r--r-- | test/lisp/simple-tests.el | 7 | ||||
-rw-r--r-- | test/lisp/textmodes/bibtex-tests.el | 57 | ||||
-rw-r--r-- | test/lisp/textmodes/paragraphs-tests.el | 4 | ||||
-rw-r--r-- | test/lisp/url/url-expand-tests.el | 7 |
11 files changed, 210 insertions, 27 deletions
diff --git a/test/lisp/cedet/srecode-utest-template.el b/test/lisp/cedet/srecode-utest-template.el index 63c33a3c440..7c5bbc599a3 100644 --- a/test/lisp/cedet/srecode-utest-template.el +++ b/test/lisp/cedet/srecode-utest-template.el @@ -323,7 +323,6 @@ INSIDE SECTION: ARG HANDLER ONE") (ert-deftest srecode-utest-project () "Test that project filtering works." - :expected-result (if (getenv "EMACS_HYDRA_CI") :failed :passed) ; fixme (save-excursion (let ((testbuff (find-file-noselect srecode-utest-testfile)) (temp nil)) @@ -347,6 +346,10 @@ INSIDE SECTION: ARG HANDLER ONE") ;; Load the application templates, and make sure we can find them. (srecode-load-tables-for-mode major-mode 'tests) + (dolist (table (oref (srecode-table) tables)) + (when (gethash "test" (oref table contexthash)) + (oset table project default-directory))) + (setq temp (srecode-template-get-table (srecode-table) "test-project" "test" diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index 894914300ae..834e3b6d914 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el @@ -365,24 +365,24 @@ bytecompiled code, and their results compared.") (defun bytecomp-check-1 (pat) "Return non-nil if PAT is the same whether directly evalled or compiled." (let ((warning-minimum-log-level :emergency) - (byte-compile-warnings nil) - (v0 (condition-case nil + (byte-compile-warnings nil) + (v0 (condition-case err (eval pat) - (error 'bytecomp-check-error))) - (v1 (condition-case nil + (error (list 'bytecomp-check-error (car err))))) + (v1 (condition-case err (funcall (byte-compile (list 'lambda nil pat))) - (error 'bytecomp-check-error)))) + (error (list 'bytecomp-check-error (car err)))))) (equal v0 v1))) (put 'bytecomp-check-1 'ert-explainer 'bytecomp-explain-1) (defun bytecomp-explain-1 (pat) - (let ((v0 (condition-case nil + (let ((v0 (condition-case err (eval pat) - (error 'bytecomp-check-error))) - (v1 (condition-case nil + (error (list 'bytecomp-check-error (car err))))) + (v1 (condition-case err (funcall (byte-compile (list 'lambda nil pat))) - (error 'bytecomp-check-error)))) + (error (list 'bytecomp-check-error (car err)))))) (format "Expression `%s' gives `%s' if directly evalled, `%s' if compiled." pat v0 v1))) @@ -405,12 +405,12 @@ Subtests signal errors if something goes wrong." (print-quoted t) v0 v1) (dolist (pat byte-opt-testsuite-arith-data) - (condition-case nil + (condition-case err (setq v0 (eval pat)) - (error (setq v0 'bytecomp-check-error))) - (condition-case nil + (error (setq v0 (list 'bytecomp-check-error (car err))))) + (condition-case err (setq v1 (funcall (byte-compile (list 'lambda nil pat)))) - (error (setq v1 'bytecomp-check-error))) + (error (setq v1 (list 'bytecomp-check-error (car err))))) (insert (format "%s" pat)) (indent-to-column 65) (if (equal v0 v1) @@ -479,6 +479,7 @@ Subtests signal errors if something goes wrong." (ert-deftest bytecomp-tests--warnings () (with-current-buffer (get-buffer-create "*Compile-Log*") (let ((inhibit-read-only t)) (erase-buffer))) + (mapc #'fmakunbound '(my-test0 my--test11 my--test12 my--test2)) (test-byte-comp-compile-and-load t '(progn (defun my-test0 () @@ -564,25 +565,25 @@ bytecompiled code, and their results compared.") "Return non-nil if PAT is the same whether directly evalled or compiled." (let ((warning-minimum-log-level :emergency) (byte-compile-warnings nil) - (v0 (condition-case nil + (v0 (condition-case err (eval pat t) - (error 'bytecomp-check-error))) - (v1 (condition-case nil + (error (list 'bytecomp-check-error (car err))))) + (v1 (condition-case err (funcall (let ((lexical-binding t)) (byte-compile `(lambda nil ,pat)))) - (error 'bytecomp-check-error)))) + (error (list 'bytecomp-check-error (car err)))))) (equal v0 v1))) (put 'bytecomp-lexbind-check-1 'ert-explainer 'bytecomp-lexbind-explain-1) (defun bytecomp-lexbind-explain-1 (pat) - (let ((v0 (condition-case nil + (let ((v0 (condition-case err (eval pat t) - (error 'bytecomp-check-error))) - (v1 (condition-case nil + (error (list 'bytecomp-check-error (car err))))) + (v1 (condition-case err (funcall (let ((lexical-binding t)) (byte-compile (list 'lambda nil pat)))) - (error 'bytecomp-check-error)))) + (error (list 'bytecomp-check-error (car err)))))) (format "Expression `%s' gives `%s' if directly evalled, `%s' if compiled." pat v0 v1))) diff --git a/test/lisp/emacs-lisp/cl-lib-tests.el b/test/lisp/emacs-lisp/cl-lib-tests.el index 57b9d23efb0..40dd7e4eeb0 100644 --- a/test/lisp/emacs-lisp/cl-lib-tests.el +++ b/test/lisp/emacs-lisp/cl-lib-tests.el @@ -242,6 +242,22 @@ (should (= (cl-the integer (cl-incf side-effect)) 1)) (should (= side-effect 1)))) +(ert-deftest cl-lib-test-incf () + (let ((var 0)) + (should (= (cl-incf var) 1)) + (should (= var 1))) + (let ((alist)) + (should (= (cl-incf (alist-get 'a alist 0)) 1)) + (should (= (alist-get 'a alist 0) 1)))) + +(ert-deftest cl-lib-test-decf () + (let ((var 1)) + (should (= (cl-decf var) 0)) + (should (= var 0))) + (let ((alist)) + (should (= (cl-decf (alist-get 'a alist 0)) -1)) + (should (= (alist-get 'a alist 0) -1)))) + (ert-deftest cl-lib-test-plusp () (should-not (cl-plusp -1.0e+INF)) (should-not (cl-plusp -1.5e2)) diff --git a/test/lisp/ffap-tests.el b/test/lisp/ffap-tests.el index 30c8f794577..e8c12669c1a 100644 --- a/test/lisp/ffap-tests.el +++ b/test/lisp/ffap-tests.el @@ -77,6 +77,46 @@ left alone when opening a URL in an external browser." (should (compare-window-configurations (current-window-configuration) old)) (should (equal urls '("https://www.gnu.org"))))) +(defun ffap-test-string (space string) + (let ((ffap-file-name-with-spaces space)) + (with-temp-buffer + (insert string) + (goto-char (point-min)) + (forward-char 10) + (ffap-string-at-point)))) + +(ert-deftest ffap-test-with-spaces () + (should + (equal + (ffap-test-string + t "c:/Program Files/Open Text Evaluation Media/Open Text Exceed 14 x86/Program here.txt") + "/Program Files/Open Text Evaluation Media/Open Text Exceed 14 x86/Program here.txt")) + (should + (equal + (ffap-test-string + nil "c:/Program Files/Open Text Evaluation Media/Open Text Exceed 14 x86/Program here.txt") + "c:/Program")) + (should + (equal + (ffap-test-string + t "c:/Program Files/Open Text Evaluation Media/Open Text Exceed 14 x86/Program Files/Hummingbird/") + "/Program Files/Open Text Evaluation Media/Open Text Exceed 14 x86/Program Files/Hummingbird/")) + (should + (equal + (ffap-test-string + t "c:\\Program Files\\Open Text Evaluation Media\\Open Text Exceed 14 x86\\Program Files\\Hummingbird\\") + "\\Program Files\\Open Text Evaluation Media\\Open Text Exceed 14 x86\\Program Files\\Hummingbird\\")) + (should + (equal + (ffap-test-string + t "c:\\Program Files\\Freescale\\CW for MPC55xx and MPC56xx 2.10\\PowerPC_EABI_Tools\\Command_Line_Tools\\CLT_Usage_Notes.txt") + "\\Program Files\\Freescale\\CW for MPC55xx and MPC56xx 2.10\\PowerPC_EABI_Tools\\Command_Line_Tools\\CLT_Usage_Notes.txt")) + (should + (equal + (ffap-test-string + t "C:\\temp\\program.log on Windows or /var/log/program.log on Unix.") + "\\temp\\program.log"))) + (provide 'ffap-tests) ;;; ffap-tests.el ends here diff --git a/test/lisp/mail/flow-fill-tests.el b/test/lisp/mail/flow-fill-tests.el index 4d435aeda71..c2e4178b7d4 100644 --- a/test/lisp/mail/flow-fill-tests.el +++ b/test/lisp/mail/flow-fill-tests.el @@ -35,7 +35,8 @@ ">>> unmuzzled ratsbane!\n" ">>>> Henceforth, the coding style is to be strictly \n" ">>>> enforced, including the use of only upper case.\n" - ">>>>> I've noticed a lack of adherence to the coding \n" + ">>>>> I've noticed a lack of adherence to \n" + ">>>>> the coding \n" ">>>>> styles, of late.\n" ">>>>>> Any complaints?\n")) (output diff --git a/test/lisp/progmodes/compile-tests.el b/test/lisp/progmodes/compile-tests.el index cd736497e66..d566e7dd862 100644 --- a/test/lisp/progmodes/compile-tests.el +++ b/test/lisp/progmodes/compile-tests.el @@ -435,8 +435,8 @@ The test data is in `compile-tests--test-regexps-data'." (compilation-num-infos-found 0)) (mapc #'compile--test-error-line compile-tests--test-regexps-data) (should (eq compilation-num-errors-found 94)) - (should (eq compilation-num-warnings-found 37)) - (should (eq compilation-num-infos-found 26))))) + (should (eq compilation-num-warnings-found 35)) + (should (eq compilation-num-infos-found 28))))) (ert-deftest compile-test-grep-regexps () "Test the `grep-regexp-alist' regexps. diff --git a/test/lisp/progmodes/cperl-mode-tests.el b/test/lisp/progmodes/cperl-mode-tests.el new file mode 100644 index 00000000000..be8b42d99a8 --- /dev/null +++ b/test/lisp/progmodes/cperl-mode-tests.el @@ -0,0 +1,51 @@ +;;; cperl-mode-tests --- Test for cperl-mode -*- lexical-binding: t -*- + +;; Copyright (C) 2020 Free Software Foundation, Inc. + +;; Author: Harald Jörg <haj@posteo.de> +;; Maintainer: Harald Jörg +;; Keywords: internal +;; Homepage: https://github.com/HaraldJoerg/cperl-mode + +;;; Commentary: + +;; This is a collection of tests for the fontification of CPerl-mode. + +;; Run these tests interactively: +;; (ert-run-tests-interactively '(tag :fontification)) + +;;; Code: + +(defvar cperl-test-mode #'cperl-mode) + +(defun cperl-test-ppss (text regexp) + "Return the `syntax-ppss' of the first character matched by REGEXP in TEXT." + (interactive) + (with-temp-buffer + (insert text) + (funcall cperl-test-mode) + (goto-char (point-min)) + (re-search-forward regexp) + (syntax-ppss))) + +(ert-deftest cperl-mode-test-bug-42168 () + "Verify that '/' is a division after ++ or --, not a regexp. +Reported in https://github.com/jrockway/cperl-mode/issues/45. +If seen as regular expression, then the slash is displayed using +font-lock-constant-face. If seen as a division, then it doesn't +have a face property." + :tags '(:fontification) + ;; The next two Perl expressions have divisions. Perl "punctuation" + ;; operators don't get a face. + (let ((code "{ $a++ / $b }")) + (should (equal (nth 8 (cperl-test-ppss code "/")) nil))) + (let ((code "{ $a-- / $b }")) + (should (equal (nth 8 (cperl-test-ppss code "/")) nil))) + ;; The next two Perl expressions have regular expressions. The + ;; delimiter of a RE is fontified with font-lock-constant-face. + (let ((code "{ $a+ / $b } # /")) + (should (equal (nth 8 (cperl-test-ppss code "/")) 7))) + (let ((code "{ $a- / $b } # /")) + (should (equal (nth 8 (cperl-test-ppss code "/")) 7)))) + +;;; cperl-mode-tests.el ends here diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el index 4adcacb279b..63e504bbe17 100644 --- a/test/lisp/simple-tests.el +++ b/test/lisp/simple-tests.el @@ -39,6 +39,13 @@ (with-no-warnings (simple-test--buffer-substrings)))) +;;; `count-words' +(ert-deftest simple-test-count-words-bug-41761 () + (with-temp-buffer + (dotimes (i 10) (insert (propertize "test " 'field (cons nil nil)))) + (should (= (count-words (point-min) (point-max)) 10)))) + + ;;; `transpose-sexps' (defmacro simple-test--transpositions (&rest body) (declare (indent 0) diff --git a/test/lisp/textmodes/bibtex-tests.el b/test/lisp/textmodes/bibtex-tests.el new file mode 100644 index 00000000000..b3858de9e61 --- /dev/null +++ b/test/lisp/textmodes/bibtex-tests.el @@ -0,0 +1,57 @@ +;;; bibtex-tests.el --- Test suite for bibtex. + +;; Copyright (C) 2013-2020 Free Software Foundation, Inc. + +;; Keywords: bibtex + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. + +;;; Commentary: + +;;; Code: + +(require 'ert) +(require 'bibtex) + +(ert-deftest bibtex-test-set-dialect () + "Tests if `bibtex-set-dialect' is executed." + (with-temp-buffer + (insert "@article{someID, + author = {some author}, + title = {some title}, +}") + (bibtex-mode) + (should-not (null bibtex-dialect)) + (should-not (null bibtex-entry-type)) + (should-not (null bibtex-entry-head)) + (should-not (null bibtex-reference-key)) + (should-not (null bibtex-entry-head)) + (should-not (null bibtex-entry-maybe-empty-head)) + (should-not (null bibtex-any-valid-entry-type)))) + +(ert-deftest bibtex-test-parse-buffers-stealthily () + "Tests if `bibtex-parse-buffers-stealthily' can be executed." + (with-temp-buffer + (insert "@article{someID, + author = {some author}, + title = {some title}, +}") + (bibtex-mode) + (should (progn (bibtex-parse-buffers-stealthily) t)))) + +(provide 'bibtex-tests) + +;;; bibtex-tests.el ends here diff --git a/test/lisp/textmodes/paragraphs-tests.el b/test/lisp/textmodes/paragraphs-tests.el index fc839fe7d95..0b264e7e184 100644 --- a/test/lisp/textmodes/paragraphs-tests.el +++ b/test/lisp/textmodes/paragraphs-tests.el @@ -50,8 +50,8 @@ (goto-char (point-min)) (mark-paragraph) (should mark-active) - (should (equal (mark) 7))) - (should-error (mark-paragraph 0))) + (should (equal (mark) 7)))) +;;; (should-error (mark-paragraph 0))) (ert-deftest paragraphs-tests-kill-paragraph () (with-temp-buffer diff --git a/test/lisp/url/url-expand-tests.el b/test/lisp/url/url-expand-tests.el index 6e0ce869502..3b0b6fbd41a 100644 --- a/test/lisp/url/url-expand-tests.el +++ b/test/lisp/url/url-expand-tests.el @@ -100,6 +100,13 @@ (should (equal (url-expand-file-name "foo#bar" "http://host/foobar") "http://host/foo#bar")) (should (equal (url-expand-file-name "foo#bar" "http://host/foobar/") "http://host/foobar/foo#bar"))) +(ert-deftest url-expand-file-name/relative-resolution-file-url () + "RFC 3986, Section 5.4 Reference Resolution Examples / Section 5.4.1. Normal Examples" + (should (equal (url-expand-file-name "bar.html" "file:///a/b/c/foo.html") "file:///a/b/c/bar.html")) + (should (equal (url-expand-file-name "bar.html" "file:///a/b/c/") "file:///a/b/c/bar.html")) + (should (equal (url-expand-file-name "../d/bar.html" "file:///a/b/c/") "file:///a/b/d/bar.html")) + (should (equal (url-expand-file-name "../d/bar.html" "file:///a/b/c/foo.html") "file:///a/b/d/bar.html"))) + (provide 'url-expand-tests) ;;; url-expand-tests.el ends here |