diff options
| author | Simen Heggestøyl | 2020-05-18 17:54:05 +0200 |
|---|---|---|
| committer | Simen Heggestøyl | 2020-05-18 17:58:01 +0200 |
| commit | b2e2128745a00e06cb714bb3f47829f036a9caf9 (patch) | |
| tree | 5d38f1af82ea4542f42752f2722c019efad1290d | |
| parent | b1fe27d77db8f819641231ca46725f3eed0b4d9b (diff) | |
| download | emacs-b2e2128745a00e06cb714bb3f47829f036a9caf9.tar.gz emacs-b2e2128745a00e06cb714bb3f47829f036a9caf9.zip | |
Use lexical-binding in webjump.el and add tests
* lisp/net/webjump.el: Use lexical-binding.
(webjump-read-url-choice): Remove redundant 'function' around lambda.
* test/lisp/net/webjump-tests.el: New file with tests for webjump.el.
| -rw-r--r-- | lisp/net/webjump.el | 5 | ||||
| -rw-r--r-- | test/lisp/net/webjump-tests.el | 73 |
2 files changed, 75 insertions, 3 deletions
diff --git a/lisp/net/webjump.el b/lisp/net/webjump.el index 6edd03c39cc..8bb156199c5 100644 --- a/lisp/net/webjump.el +++ b/lisp/net/webjump.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; webjump.el --- programmable Web hotlist | 1 | ;;; webjump.el --- programmable Web hotlist -*- lexical-binding: t; -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1996-1997, 2001-2020 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1996-1997, 2001-2020 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -323,8 +323,7 @@ Please submit bug reports and other feedback to the author, Neil W. Van Dyke | |||
| 323 | 323 | ||
| 324 | (defun webjump-read-url-choice (what urls &optional default) | 324 | (defun webjump-read-url-choice (what urls &optional default) |
| 325 | ;; Note: Convert this to use `webjump-read-choice' someday. | 325 | ;; Note: Convert this to use `webjump-read-choice' someday. |
| 326 | (let* ((completions (mapcar (function (lambda (n) (cons n n))) | 326 | (let* ((completions (mapcar (lambda (n) (cons n n)) urls)) |
| 327 | urls)) | ||
| 328 | (input (completing-read (concat what | 327 | (input (completing-read (concat what |
| 329 | ;;(if default " (RET for default)" "") | 328 | ;;(if default " (RET for default)" "") |
| 330 | ": ") | 329 | ": ") |
diff --git a/test/lisp/net/webjump-tests.el b/test/lisp/net/webjump-tests.el new file mode 100644 index 00000000000..47569c948f5 --- /dev/null +++ b/test/lisp/net/webjump-tests.el | |||
| @@ -0,0 +1,73 @@ | |||
| 1 | ;;; webjump-tests.el --- Tests for webjump.el -*- lexical-binding: t; -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2020 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Simen Heggestøyl <simenheg@gmail.com> | ||
| 6 | ;; Keywords: | ||
| 7 | |||
| 8 | ;; This file is part of GNU Emacs. | ||
| 9 | |||
| 10 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 11 | ;; it under the terms of the GNU General Public License as published by | ||
| 12 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 13 | ;; (at your option) any later version. | ||
| 14 | |||
| 15 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | ;; GNU General Public License for more details. | ||
| 19 | |||
| 20 | ;; You should have received a copy of the GNU General Public License | ||
| 21 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | ||
| 22 | |||
| 23 | ;;; Commentary: | ||
| 24 | |||
| 25 | ;; | ||
| 26 | |||
| 27 | ;;; Code: | ||
| 28 | |||
| 29 | (require 'ert) | ||
| 30 | (require 'webjump) | ||
| 31 | |||
| 32 | (ert-deftest webjump-tests-builtin () | ||
| 33 | (should (equal (webjump-builtin '[name] "gnu.org") "gnu.org"))) | ||
| 34 | |||
| 35 | (ert-deftest webjump-tests-builtin-check-args () | ||
| 36 | (should (webjump-builtin-check-args [1 2 3] "Foo" 2)) | ||
| 37 | (should-error (webjump-builtin-check-args [1 2 3] "Foo" 3))) | ||
| 38 | |||
| 39 | (ert-deftest webjump-tests-mirror-default () | ||
| 40 | (should (equal (webjump-mirror-default | ||
| 41 | '("https://ftp.gnu.org/pub/gnu/" | ||
| 42 | "https://ftpmirror.gnu.org")) | ||
| 43 | "https://ftp.gnu.org/pub/gnu/"))) | ||
| 44 | |||
| 45 | (ert-deftest webjump-tests-null-or-blank-string-p () | ||
| 46 | (should (webjump-null-or-blank-string-p nil)) | ||
| 47 | (should (webjump-null-or-blank-string-p "")) | ||
| 48 | (should (webjump-null-or-blank-string-p " ")) | ||
| 49 | (should-not (webjump-null-or-blank-string-p " . "))) | ||
| 50 | |||
| 51 | (ert-deftest webjump-tests-url-encode () | ||
| 52 | (should (equal (webjump-url-encode "") "")) | ||
| 53 | (should (equal (webjump-url-encode "a b c") "a+b+c")) | ||
| 54 | (should (equal (webjump-url-encode "foo?") "foo%3F")) | ||
| 55 | (should (equal (webjump-url-encode "/foo\\") "/foo%5C")) | ||
| 56 | (should (equal (webjump-url-encode "f&o") "f%26o"))) | ||
| 57 | |||
| 58 | (ert-deftest webjump-tests-url-fix () | ||
| 59 | (should (equal (webjump-url-fix nil) "")) | ||
| 60 | (should (equal (webjump-url-fix "/tmp/") "file:///tmp/")) | ||
| 61 | (should (equal (webjump-url-fix "gnu.org") "http://gnu.org/")) | ||
| 62 | (should (equal (webjump-url-fix "ftp.x.org") "ftp://ftp.x.org/")) | ||
| 63 | (should (equal (webjump-url-fix "https://gnu.org") | ||
| 64 | "https://gnu.org/"))) | ||
| 65 | |||
| 66 | (ert-deftest webjump-tests-url-fix-trailing-slash () | ||
| 67 | (should (equal (webjump-url-fix-trailing-slash "https://gnu.org") | ||
| 68 | "https://gnu.org/")) | ||
| 69 | (should (equal (webjump-url-fix-trailing-slash "https://gnu.org/") | ||
| 70 | "https://gnu.org/"))) | ||
| 71 | |||
| 72 | (provide 'webjump-tests) | ||
| 73 | ;;; webjump-tests.el ends here | ||