diff options
| author | Stefan Kangas | 2020-06-07 19:57:45 +0200 |
|---|---|---|
| committer | Stefan Kangas | 2020-06-07 19:57:45 +0200 |
| commit | 80abaea1d9c6f1e53fe88befe16de3b219cdd919 (patch) | |
| tree | a4d5a8f708714b4143333954bfc00468f68998f7 /test | |
| parent | 53fba73ff2599d2e5f06927d474311dc987a4c4d (diff) | |
| download | emacs-80abaea1d9c6f1e53fe88befe16de3b219cdd919.tar.gz emacs-80abaea1d9c6f1e53fe88befe16de3b219cdd919.zip | |
Use lexical-binding in lunar.el and add tests
* lisp/calendar/lunar.el: Use lexical-binding.
(lunar-phases, diary-lunar-phases): Silence byte-compiler.
* test/lisp/calendar/lunar-tests.el: New file.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/calendar/lunar-tests.el | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/test/lisp/calendar/lunar-tests.el b/test/lisp/calendar/lunar-tests.el new file mode 100644 index 00000000000..8d8a988e503 --- /dev/null +++ b/test/lisp/calendar/lunar-tests.el | |||
| @@ -0,0 +1,70 @@ | |||
| 1 | ;;; lunar-tests.el --- tests for calendar/lunar.el -*- lexical-binding:t -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2020 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Stefan Kangas <stefankangas@gmail.com> | ||
| 6 | |||
| 7 | ;; This file is part of GNU Emacs. | ||
| 8 | |||
| 9 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 10 | ;; it under the terms of the GNU General Public License as published by | ||
| 11 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 12 | ;; (at your option) any later version. | ||
| 13 | |||
| 14 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 15 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | ;; GNU General Public License for more details. | ||
| 18 | |||
| 19 | ;; You should have received a copy of the GNU General Public License | ||
| 20 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | ||
| 21 | |||
| 22 | ;;; Code: | ||
| 23 | |||
| 24 | (require 'ert) | ||
| 25 | (require 'lunar) | ||
| 26 | |||
| 27 | (defmacro with-lunar-test (&rest body) | ||
| 28 | `(let ((calendar-latitude 40.1) | ||
| 29 | (calendar-longitude -88.2) | ||
| 30 | (calendar-location-name "Urbana, IL") | ||
| 31 | (calendar-time-zone -360) | ||
| 32 | (calendar-standard-time-zone-name "CST") | ||
| 33 | (calendar-time-display-form '(12-hours ":" minutes am-pm))) | ||
| 34 | ,@body)) | ||
| 35 | |||
| 36 | (ert-deftest lunar-test-phase () | ||
| 37 | (with-lunar-test | ||
| 38 | (should (equal (lunar-phase 1) | ||
| 39 | '((1 7 1900) "11:40pm" 1 ""))))) | ||
| 40 | |||
| 41 | (ert-deftest lunar-test-eclipse-check () | ||
| 42 | (with-lunar-test | ||
| 43 | (should (equal (eclipse-check 1 1) "** Eclipse **")))) | ||
| 44 | |||
| 45 | (ert-deftest lunar-test-phase-list () | ||
| 46 | (with-lunar-test | ||
| 47 | (should (equal (lunar-phase-list 3 1871) | ||
| 48 | '(((3 20 1871) "11:03pm" 0 "") | ||
| 49 | ((3 29 1871) "1:46am" 1 "** Eclipse **") | ||
| 50 | ((4 5 1871) "9:20am" 2 "") | ||
| 51 | ((4 12 1871) "12:57am" 3 "** Eclipse possible **") | ||
| 52 | ((4 19 1871) "2:06pm" 0 "") | ||
| 53 | ((4 27 1871) "6:49pm" 1 "") | ||
| 54 | ((5 4 1871) "5:57pm" 2 "") | ||
| 55 | ((5 11 1871) "9:29am" 3 "") | ||
| 56 | ((5 19 1871) "5:46am" 0 "") | ||
| 57 | ((5 27 1871) "8:02am" 1 "")))))) | ||
| 58 | |||
| 59 | (ert-deftest lunar-test-new-moon-time () | ||
| 60 | (with-lunar-test | ||
| 61 | (should (= (round (lunar-new-moon-time 1)) | ||
| 62 | 2451580)))) | ||
| 63 | |||
| 64 | (ert-deftest lunar-test-new-moon-on-or-after () | ||
| 65 | (with-lunar-test | ||
| 66 | (should (= (round (lunar-new-moon-on-or-after (calendar-absolute-from-gregorian '(5 5 1818)))) | ||
| 67 | 664525)))) | ||
| 68 | |||
| 69 | (provide 'lunar-tests) | ||
| 70 | ;;; lunar-tests.el ends here | ||