From: Stefan Kangas Date: Sun, 26 Sep 2021 18:34:34 +0000 (+0200) Subject: Move two incorrectly named test files X-Git-Tag: emacs-28.0.90~591 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=c00785cbabe34619c50415ddf2c8dcbfc8b02d5e;p=emacs.git Move two incorrectly named test files * test/lisp/emacs-lisp/tabulated-list-test.el: Move from here... * test/lisp/emacs-lisp/tabulated-list-tests.el: ...to here. * test/lisp/url/url-handlers-test.el: Move from here... * test/lisp/url/url-handlers-tests.el: ...to here. --- diff --git a/test/lisp/emacs-lisp/tabulated-list-test.el b/test/lisp/emacs-lisp/tabulated-list-test.el deleted file mode 100644 index 7cac254ac40..00000000000 --- a/test/lisp/emacs-lisp/tabulated-list-test.el +++ /dev/null @@ -1,119 +0,0 @@ -;;; tabulated-list-test.el --- Tests for emacs-lisp/tabulated-list.el -*- lexical-binding: t; -*- - -;; Copyright (C) 2015-2021 Free Software Foundation, Inc. - -;; Author: Artur Malabarba - -;; 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 . - -;;; Code: - -(require 'tabulated-list) -(require 'ert) - -(defconst tabulated-list--test-entries - '(("zzzz-game" ["zzzz-game" "zzzz-game" "2113" "installed" " play zzzz in Emacs"]) - ("4clojure" ["4clojure" "4clojure" "1507" "obsolete" " Open and evaluate 4clojure.com questions"]) - ("abc-mode" ["abc-mode" "abc-mode" "944" "available" " Major mode for editing abc music files"]) - ("mode" ["mode" "mode" "1128" "installed" " A simple mode for editing Actionscript 3 files"]))) - -(defun tabulated-list--test-sort-car (a b) - (string< (car a) (car b))) - -(defconst tabulated-list--test-format - [("name" 10 tabulated-list--test-sort-car) - ("name-2" 10 t) - ("Version" 9 nil) - ("Status" 10 ) - ("Description" 0 nil)]) - -(defmacro tabulated-list--test-with-buffer (&rest body) - `(with-temp-buffer - (tabulated-list-mode) - (setq tabulated-list-entries (copy-alist tabulated-list--test-entries)) - (setq tabulated-list-format tabulated-list--test-format) - (setq tabulated-list-padding 7) - (tabulated-list-init-header) - (tabulated-list-print) - ,@body)) - - -;;; Tests -(ert-deftest tabulated-list-print () - (tabulated-list--test-with-buffer - ;; Basic printing. - (should (string= (buffer-substring-no-properties (point-min) (point-max)) - " zzzz-game zzzz-game 2113 installed play zzzz in Emacs - 4clojure 4clojure 1507 obsolete Open and evaluate 4clojure.com questions - abc-mode abc-mode 944 available Major mode for editing abc music files - mode mode 1128 installed A simple mode for editing Actionscript 3 files\n")) - ;; Preserve position. - (forward-line 3) - (let ((pos (thing-at-point 'line))) - (pop tabulated-list-entries) - (tabulated-list-print t) - (should (equal (thing-at-point 'line) pos)) - (should (string= (buffer-substring-no-properties (point-min) (point-max)) - " 4clojure 4clojure 1507 obsolete Open and evaluate 4clojure.com questions - abc-mode abc-mode 944 available Major mode for editing abc music files - mode mode 1128 installed A simple mode for editing Actionscript 3 files\n")) - ;; Check the UPDATE argument - (pop tabulated-list-entries) - (setf (cdr (car tabulated-list-entries)) (list ["x" "x" "944" "available" " XX"])) - (tabulated-list-print t t) - (should (string= (buffer-substring-no-properties (point-min) (point-max)) - " x x 944 available XX - mode mode 1128 installed A simple mode for editing Actionscript 3 files\n")) - (should (equal (thing-at-point 'line) pos))))) - -(ert-deftest tabulated-list-sort () - (tabulated-list--test-with-buffer - ;; Basic sorting - (goto-char (point-min)) - (skip-chars-forward "[:blank:]") - (tabulated-list-sort) - (let ((text (buffer-substring-no-properties (point-min) (point-max)))) - (should (string= text - " 4clojure 4clojure 1507 obsolete Open and evaluate 4clojure.com questions - abc-mode abc-mode 944 available Major mode for editing abc music files - mode mode 1128 installed A simple mode for editing Actionscript 3 files - zzzz-game zzzz-game 2113 installed play zzzz in Emacs\n")) - - (skip-chars-forward "^[:blank:]") - (skip-chars-forward "[:blank:]") - (should (equal (get-text-property (point) 'tabulated-list-column-name) - "name-2")) - (tabulated-list-sort) - ;; Check a t as the sorting predicate. - (should (string= text (buffer-substring-no-properties (point-min) (point-max)))) - ;; Invert. - (tabulated-list-sort 1) - (should (string= (buffer-substring-no-properties (point-min) (point-max)) - " zzzz-game zzzz-game 2113 installed play zzzz in Emacs - mode mode 1128 installed A simple mode for editing Actionscript 3 files - abc-mode abc-mode 944 available Major mode for editing abc music files - 4clojure 4clojure 1507 obsolete Open and evaluate 4clojure.com questions\n")) - ;; Again - (tabulated-list-sort 1) - (should (string= text (buffer-substring-no-properties (point-min) (point-max))))) - ;; Check that you can't sort some cols. - (skip-chars-forward "^[:blank:]") - (skip-chars-forward "[:blank:]") - (should-error (tabulated-list-sort) :type 'user-error) - (should-error (tabulated-list-sort 4) :type 'user-error))) - -(provide 'tabulated-list-test) -;;; tabulated-list-test.el ends here diff --git a/test/lisp/emacs-lisp/tabulated-list-tests.el b/test/lisp/emacs-lisp/tabulated-list-tests.el new file mode 100644 index 00000000000..e376d2f328d --- /dev/null +++ b/test/lisp/emacs-lisp/tabulated-list-tests.el @@ -0,0 +1,118 @@ +;;; tabulated-list-tests.el --- Tests for emacs-lisp/tabulated-list.el -*- lexical-binding: t; -*- + +;; Copyright (C) 2015-2021 Free Software Foundation, Inc. + +;; Author: Artur Malabarba + +;; 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 . + +;;; Code: + +(require 'tabulated-list) +(require 'ert) + +(defconst tabulated-list--test-entries + '(("zzzz-game" ["zzzz-game" "zzzz-game" "2113" "installed" " play zzzz in Emacs"]) + ("4clojure" ["4clojure" "4clojure" "1507" "obsolete" " Open and evaluate 4clojure.com questions"]) + ("abc-mode" ["abc-mode" "abc-mode" "944" "available" " Major mode for editing abc music files"]) + ("mode" ["mode" "mode" "1128" "installed" " A simple mode for editing Actionscript 3 files"]))) + +(defun tabulated-list--test-sort-car (a b) + (string< (car a) (car b))) + +(defconst tabulated-list--test-format + [("name" 10 tabulated-list--test-sort-car) + ("name-2" 10 t) + ("Version" 9 nil) + ("Status" 10 ) + ("Description" 0 nil)]) + +(defmacro tabulated-list--test-with-buffer (&rest body) + `(with-temp-buffer + (tabulated-list-mode) + (setq tabulated-list-entries (copy-alist tabulated-list--test-entries)) + (setq tabulated-list-format tabulated-list--test-format) + (setq tabulated-list-padding 7) + (tabulated-list-init-header) + (tabulated-list-print) + ,@body)) + + +;;; Tests +(ert-deftest tabulated-list-print () + (tabulated-list--test-with-buffer + ;; Basic printing. + (should (string= (buffer-substring-no-properties (point-min) (point-max)) + " zzzz-game zzzz-game 2113 installed play zzzz in Emacs + 4clojure 4clojure 1507 obsolete Open and evaluate 4clojure.com questions + abc-mode abc-mode 944 available Major mode for editing abc music files + mode mode 1128 installed A simple mode for editing Actionscript 3 files\n")) + ;; Preserve position. + (forward-line 3) + (let ((pos (thing-at-point 'line))) + (pop tabulated-list-entries) + (tabulated-list-print t) + (should (equal (thing-at-point 'line) pos)) + (should (string= (buffer-substring-no-properties (point-min) (point-max)) + " 4clojure 4clojure 1507 obsolete Open and evaluate 4clojure.com questions + abc-mode abc-mode 944 available Major mode for editing abc music files + mode mode 1128 installed A simple mode for editing Actionscript 3 files\n")) + ;; Check the UPDATE argument + (pop tabulated-list-entries) + (setf (cdr (car tabulated-list-entries)) (list ["x" "x" "944" "available" " XX"])) + (tabulated-list-print t t) + (should (string= (buffer-substring-no-properties (point-min) (point-max)) + " x x 944 available XX + mode mode 1128 installed A simple mode for editing Actionscript 3 files\n")) + (should (equal (thing-at-point 'line) pos))))) + +(ert-deftest tabulated-list-sort () + (tabulated-list--test-with-buffer + ;; Basic sorting + (goto-char (point-min)) + (skip-chars-forward "[:blank:]") + (tabulated-list-sort) + (let ((text (buffer-substring-no-properties (point-min) (point-max)))) + (should (string= text + " 4clojure 4clojure 1507 obsolete Open and evaluate 4clojure.com questions + abc-mode abc-mode 944 available Major mode for editing abc music files + mode mode 1128 installed A simple mode for editing Actionscript 3 files + zzzz-game zzzz-game 2113 installed play zzzz in Emacs\n")) + + (skip-chars-forward "^[:blank:]") + (skip-chars-forward "[:blank:]") + (should (equal (get-text-property (point) 'tabulated-list-column-name) + "name-2")) + (tabulated-list-sort) + ;; Check a t as the sorting predicate. + (should (string= text (buffer-substring-no-properties (point-min) (point-max)))) + ;; Invert. + (tabulated-list-sort 1) + (should (string= (buffer-substring-no-properties (point-min) (point-max)) + " zzzz-game zzzz-game 2113 installed play zzzz in Emacs + mode mode 1128 installed A simple mode for editing Actionscript 3 files + abc-mode abc-mode 944 available Major mode for editing abc music files + 4clojure 4clojure 1507 obsolete Open and evaluate 4clojure.com questions\n")) + ;; Again + (tabulated-list-sort 1) + (should (string= text (buffer-substring-no-properties (point-min) (point-max))))) + ;; Check that you can't sort some cols. + (skip-chars-forward "^[:blank:]") + (skip-chars-forward "[:blank:]") + (should-error (tabulated-list-sort) :type 'user-error) + (should-error (tabulated-list-sort 4) :type 'user-error))) + +;;; tabulated-list-tests.el ends here diff --git a/test/lisp/url/url-handlers-test.el b/test/lisp/url/url-handlers-test.el deleted file mode 100644 index 7e5a60363da..00000000000 --- a/test/lisp/url/url-handlers-test.el +++ /dev/null @@ -1,77 +0,0 @@ -;;; url-handlers-test.el --- Test suite for url-handlers.el -*- lexical-binding: t; -*- - -;; Copyright (C) 2018-2021 Free Software Foundation, Inc. - -;; Author: Nicolas Petton - -;; 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 . - -;;; Commentary: - -;;; Code: - -(require 'ert) -(require 'url-handlers) - -(defmacro with-url-handler-mode (&rest body) - "Evaluate BODY with `url-handler-mode' turned on." - (declare (indent 0) (debug t)) - (let ((url-handler-mode-active (make-symbol "url-handler-mode-active"))) - `(let ((,url-handler-mode-active url-handler-mode)) - (unwind-protect - (progn - (unless ,url-handler-mode-active - (url-handler-mode)) - ,@body) - (unless ,url-handler-mode-active - (url-handler-mode -1)))))) - -(ert-deftest url-handlers-file-name-directory/preserve-url-types () - (with-url-handler-mode - (should (equal (file-name-directory "https://gnu.org/index.html") - "https://gnu.org/")) - (should (equal (file-name-directory "http://gnu.org/index.html") - "http://gnu.org/")) - (should (equal (file-name-directory "ftp://gnu.org/index.html") - "ftp://gnu.org/")))) - -(ert-deftest url-handlers-file-name-directory/should-not-handle-non-url-file-names () - (with-url-handler-mode - (should-not (equal (file-name-directory "not-uri://gnu.org") - "not-uri://gnu.org/")))) - -(ert-deftest url-handlers-file-name-directory/sub-directories () - (with-url-handler-mode - (should (equal (file-name-directory "https://foo/bar/baz/index.html") - "https://foo/bar/baz/")))) - -(ert-deftest url-handlers-file-name-directory/file-urls () - (with-url-handler-mode - (should (equal (file-name-directory "file:///foo/bar/baz.txt") - "file:///foo/bar/")) - (should (equal (file-name-directory "file:///") - "file:///")))) - -;; Regression test for bug#30444 -(ert-deftest url-handlers-file-name-directory/no-filename () - (with-url-handler-mode - (should (equal (file-name-directory "https://foo.org") - "https://foo.org/")) - (should (equal (file-name-directory "https://foo.org/") - "https://foo.org/")))) - -(provide 'url-handlers-test) -;;; url-handlers-test.el ends here diff --git a/test/lisp/url/url-handlers-tests.el b/test/lisp/url/url-handlers-tests.el new file mode 100644 index 00000000000..71e054b1287 --- /dev/null +++ b/test/lisp/url/url-handlers-tests.el @@ -0,0 +1,76 @@ +;;; url-handlers-tests.el --- Test suite for url-handlers.el -*- lexical-binding: t; -*- + +;; Copyright (C) 2018-2021 Free Software Foundation, Inc. + +;; Author: Nicolas Petton + +;; 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 . + +;;; Commentary: + +;;; Code: + +(require 'ert) +(require 'url-handlers) + +(defmacro with-url-handler-mode (&rest body) + "Evaluate BODY with `url-handler-mode' turned on." + (declare (indent 0) (debug t)) + (let ((url-handler-mode-active (make-symbol "url-handler-mode-active"))) + `(let ((,url-handler-mode-active url-handler-mode)) + (unwind-protect + (progn + (unless ,url-handler-mode-active + (url-handler-mode)) + ,@body) + (unless ,url-handler-mode-active + (url-handler-mode -1)))))) + +(ert-deftest url-handlers-file-name-directory/preserve-url-types () + (with-url-handler-mode + (should (equal (file-name-directory "https://gnu.org/index.html") + "https://gnu.org/")) + (should (equal (file-name-directory "http://gnu.org/index.html") + "http://gnu.org/")) + (should (equal (file-name-directory "ftp://gnu.org/index.html") + "ftp://gnu.org/")))) + +(ert-deftest url-handlers-file-name-directory/should-not-handle-non-url-file-names () + (with-url-handler-mode + (should-not (equal (file-name-directory "not-uri://gnu.org") + "not-uri://gnu.org/")))) + +(ert-deftest url-handlers-file-name-directory/sub-directories () + (with-url-handler-mode + (should (equal (file-name-directory "https://foo/bar/baz/index.html") + "https://foo/bar/baz/")))) + +(ert-deftest url-handlers-file-name-directory/file-urls () + (with-url-handler-mode + (should (equal (file-name-directory "file:///foo/bar/baz.txt") + "file:///foo/bar/")) + (should (equal (file-name-directory "file:///") + "file:///")))) + +;; Regression test for bug#30444 +(ert-deftest url-handlers-file-name-directory/no-filename () + (with-url-handler-mode + (should (equal (file-name-directory "https://foo.org") + "https://foo.org/")) + (should (equal (file-name-directory "https://foo.org/") + "https://foo.org/")))) + +;;; url-handlers-tests.el ends here