-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sync gigasecond tests and stub (#367)
- Loading branch information
Showing
3 changed files
with
26 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,34 @@ | ||
;;; gigasecond-test.el --- ERT tests for gigasecond (exercism) -*- lexical-binding: t; -*- | ||
;;; gigasecond-test.el --- Gigasecond (exercism) -*- lexical-binding: t; -*- | ||
|
||
;;; Commentary: | ||
;; | ||
;; Tests ported from Common Lisp gigasecond: | ||
;; https://github.com/exercism/xlisp/blob/master/gigasecond/gigasecond-test.lisp | ||
;; | ||
;; To run tests individually: M-x eval-buffer RET, M-x ert RET test-name. | ||
;; If you're using helm or something similar, you should get a menu of test names. | ||
;; | ||
;; To run tests in batch mode, from the command line run: | ||
;; emacs -batch -l ert -l gigasecond-test.el -f ert-run-tests-batch-and-exit | ||
|
||
;;; Code: | ||
|
||
|
||
(load-file "gigasecond.el") | ||
(declare-function from "gigasecond.el" (second minute hour day month year)) | ||
(declare-function add "gigasecond.el" (moment)) | ||
|
||
|
||
(ert-deftest date-only-specification-of-time () | ||
(should (equal '(40 46 1 1 1 2043) (add 0 0 0 25 4 2011)))) | ||
|
||
(ert-deftest from-lisp-epoch () | ||
(should | ||
(equal '(40 46 1 10 9 1931) (from 0 0 0 1 1 1900)))) | ||
|
||
(ert-deftest from-unix-epoch () | ||
(should | ||
(equal '(40 46 1 9 9 2001) (from 0 0 0 1 1 1970)))) | ||
(ert-deftest second-test-for-date-only-specification-of-time () | ||
(should (equal '(40 46 1 19 2 2009) (add 0 0 0 13 6 1977)))) | ||
|
||
(ert-deftest from-20110425T120000Z () | ||
(should | ||
(equal '(40 46 13 1 1 2043) (from 0 0 12 25 4 2011)))) | ||
|
||
(ert-deftest from-19770613T235959Z () | ||
(should | ||
(equal '(39 46 1 20 2 2009) (from 59 59 23 13 6 1977)))) | ||
(ert-deftest third-test-for-date-only-specification-of-time () | ||
(should (equal '(40 46 1 27 3 1991) (add 0 0 0 19 7 1959)))) | ||
|
||
(ert-deftest from-19590719T123030Z () | ||
(should | ||
(equal '(10 17 14 27 3 1991) (from 30 30 12 19 7 1959)))) | ||
|
||
; customize this test to test your birthday and find your gigasecond date: | ||
; (ert-deftest your-birthday () | ||
; (should | ||
; (equal '(0 0 0 day2 month2 year2) (from 0 0 0 day1 month1 year1)))) | ||
(ert-deftest full-time-specified () | ||
(should (equal '(40 46 23 2 10 2046) (add 0 0 22 24 1 2015)))) | ||
|
||
|
||
(ert-deftest full-time-with-day-roll-over () | ||
(should (equal '(39 46 1 3 10 2046) (add 59 59 23 24 1 2015)))) | ||
|
||
|
||
(provide 'gigasecond-test) | ||
;;; gigasecond-test.el ends here | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
;;; gigasecond.el --- Gigasecond exercise (exercism) -*- lexical-binding: t; -*- | ||
;;; gigasecond.el --- Gigasecond (exercism) -*- lexical-binding: t; -*- | ||
|
||
;;; Commentary: | ||
;; Calculate the date one gigasecond (10^9 seconds) from the | ||
;; given date. | ||
;; | ||
;; NB: Pay attention to Emacs' handling of time zones and dst | ||
;; in the encode-time and decode-time functions. | ||
|
||
(defun from (second minute hour day month year) | ||
;;; Code: | ||
) | ||
|
||
|
||
(defun add (second minute hour day month year) | ||
(error "Delete this S-Expression and write your own implementation")) | ||
|
||
|
||
(provide 'gigasecond) | ||
;;; gigasecond.el ends here | ||
|