aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kangas2020-05-13 01:30:51 +0200
committerStefan Kangas2020-05-13 01:34:22 +0200
commitcf453495898a5f67d4d02e6d8980f148ee87c37f (patch)
treed36906cfec5973a7d94667b24bcf2c63688e8b9c
parenta87cd10935b03e3db713a73ddcfa13e51d0a964c (diff)
downloademacs-cf453495898a5f67d4d02e6d8980f148ee87c37f.tar.gz
emacs-cf453495898a5f67d4d02e6d8980f148ee87c37f.zip
Use lexical-binding in cal-julian.el and add tests
* lisp/calendar/cal-julian.el: Use lexical-binding. * test/lisp/calendar/cal-julian-tests.el: New file.
-rw-r--r--lisp/calendar/cal-julian.el2
-rw-r--r--test/lisp/calendar/cal-julian-tests.el72
2 files changed, 73 insertions, 1 deletions
diff --git a/lisp/calendar/cal-julian.el b/lisp/calendar/cal-julian.el
index 1c741317803..0458c11920e 100644
--- a/lisp/calendar/cal-julian.el
+++ b/lisp/calendar/cal-julian.el
@@ -1,4 +1,4 @@
1;;; cal-julian.el --- calendar functions for the Julian calendar 1;;; cal-julian.el --- calendar functions for the Julian calendar -*- lexical-binding:t -*-
2 2
3;; Copyright (C) 1995, 1997, 2001-2020 Free Software Foundation, Inc. 3;; Copyright (C) 1995, 1997, 2001-2020 Free Software Foundation, Inc.
4 4
diff --git a/test/lisp/calendar/cal-julian-tests.el b/test/lisp/calendar/cal-julian-tests.el
new file mode 100644
index 00000000000..76118b3d7f5
--- /dev/null
+++ b/test/lisp/calendar/cal-julian-tests.el
@@ -0,0 +1,72 @@
1;;; cal-julian-tests.el --- tests for calendar/cal-julian.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 'cal-julian)
26
27(ert-deftest cal-julian-test-to-absolute ()
28 (should (equal (calendar-gregorian-from-absolute
29 (calendar-julian-to-absolute
30 '(10 25 1917)))
31 '(11 7 1917))))
32
33(ert-deftest cal-julian-test-from-absolute ()
34 (should (equal (calendar-julian-from-absolute
35 (calendar-absolute-from-gregorian
36 '(11 7 1917)))
37 '(10 25 1917))))
38
39(ert-deftest cal-julian-test-date-string ()
40 (should (equal (let ((calendar-date-display-form calendar-iso-date-display-form))
41 (calendar-julian-date-string '(11 7 1917)))
42 "1917-10-25")))
43
44(defmacro with-cal-julian-test (&rest body)
45 `(save-window-excursion
46 (unwind-protect
47 (progn
48 (calendar)
49 ,@body)
50 (kill-buffer "*Calendar*"))))
51
52(ert-deftest cal-julian-test-goto-date ()
53 (with-cal-julian-test
54 (calendar-julian-goto-date '(10 25 1917))
55 (should (looking-at "7"))))
56
57(ert-deftest cal-julian-test-astro-to-and-from-absolute ()
58 (should (= (+ (calendar-astro-to-absolute 0.0)
59 (calendar-astro-from-absolute 0.0))
60 0.0)))
61
62(ert-deftest cal-julian-calendar-astro-date-string ()
63 (should (equal (calendar-astro-date-string '(10 25 1917)) "2421527")))
64
65(ert-deftest calendar-astro-goto-day-number ()
66 (with-cal-julian-test
67 (calendar-astro-goto-day-number 2421527)
68 (backward-char)
69 (should (looking-at "25"))))
70
71(provide 'cal-julian-tests)
72;;; cal-julian-tests.el ends here