|
1 |
| -;;; gigasecond-test.el --- ERT tests for gigasecond (exercism) -*- lexical-binding: t; -*- |
| 1 | +;;; gigasecond-test.el --- Gigasecond (exercism) -*- lexical-binding: t; -*- |
2 | 2 |
|
3 | 3 | ;;; Commentary:
|
4 |
| -;; |
5 |
| -;; Tests ported from Common Lisp gigasecond: |
6 |
| -;; https://github.com/exercism/xlisp/blob/master/gigasecond/gigasecond-test.lisp |
7 |
| -;; |
8 |
| -;; To run tests individually: M-x eval-buffer RET, M-x ert RET test-name. |
9 |
| -;; If you're using helm or something similar, you should get a menu of test names. |
10 |
| -;; |
11 |
| -;; To run tests in batch mode, from the command line run: |
12 |
| -;; emacs -batch -l ert -l gigasecond-test.el -f ert-run-tests-batch-and-exit |
13 | 4 |
|
14 | 5 | ;;; Code:
|
15 | 6 |
|
| 7 | + |
16 | 8 | (load-file "gigasecond.el")
|
17 |
| -(declare-function from "gigasecond.el" (second minute hour day month year)) |
| 9 | +(declare-function add "gigasecond.el" (moment)) |
| 10 | + |
| 11 | + |
| 12 | +(ert-deftest date-only-specification-of-time () |
| 13 | + (should (equal '(40 46 1 1 1 2043) (add 0 0 0 25 4 2011)))) |
18 | 14 |
|
19 |
| -(ert-deftest from-lisp-epoch () |
20 |
| - (should |
21 |
| - (equal '(40 46 1 10 9 1931) (from 0 0 0 1 1 1900)))) |
22 | 15 |
|
23 |
| -(ert-deftest from-unix-epoch () |
24 |
| - (should |
25 |
| - (equal '(40 46 1 9 9 2001) (from 0 0 0 1 1 1970)))) |
| 16 | +(ert-deftest second-test-for-date-only-specification-of-time () |
| 17 | + (should (equal '(40 46 1 19 2 2009) (add 0 0 0 13 6 1977)))) |
26 | 18 |
|
27 |
| -(ert-deftest from-20110425T120000Z () |
28 |
| - (should |
29 |
| - (equal '(40 46 13 1 1 2043) (from 0 0 12 25 4 2011)))) |
30 | 19 |
|
31 |
| -(ert-deftest from-19770613T235959Z () |
32 |
| - (should |
33 |
| - (equal '(39 46 1 20 2 2009) (from 59 59 23 13 6 1977)))) |
| 20 | +(ert-deftest third-test-for-date-only-specification-of-time () |
| 21 | + (should (equal '(40 46 1 27 3 1991) (add 0 0 0 19 7 1959)))) |
34 | 22 |
|
35 |
| -(ert-deftest from-19590719T123030Z () |
36 |
| - (should |
37 |
| - (equal '(10 17 14 27 3 1991) (from 30 30 12 19 7 1959)))) |
38 | 23 |
|
39 |
| -; customize this test to test your birthday and find your gigasecond date: |
40 |
| -; (ert-deftest your-birthday () |
41 |
| -; (should |
42 |
| -; (equal '(0 0 0 day2 month2 year2) (from 0 0 0 day1 month1 year1)))) |
| 24 | +(ert-deftest full-time-specified () |
| 25 | + (should (equal '(40 46 23 2 10 2046) (add 0 0 22 24 1 2015)))) |
43 | 26 |
|
44 | 27 |
|
| 28 | +(ert-deftest full-time-with-day-roll-over () |
| 29 | + (should (equal '(39 46 1 3 10 2046) (add 59 59 23 24 1 2015)))) |
| 30 | + |
45 | 31 |
|
46 | 32 | (provide 'gigasecond-test)
|
47 | 33 | ;;; gigasecond-test.el ends here
|
| 34 | + |
0 commit comments