Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests #3

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ concurrency:
jobs:
test:
runs-on: ${{ matrix.os }}
env:
TZ: "-9:30"
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -51,4 +53,5 @@ jobs:
run: |
eask package
eask install
eask test ert datetime-format-test.el
eask compile
1 change: 1 addition & 0 deletions Eask
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
(source 'melpa)

(depends-on "emacs" "26.1")
(depends-on "compat" "29")

(setq network-security-level 'low) ; see https://github.com/jcs090218/setup-emacs-windows/issues/156#issuecomment-932956432
72 changes: 72 additions & 0 deletions datetime-format-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
;;; datetime-format-test.el --- Test for datetime-format -*- lexical-binding: t; -*-

;; Copyright (C) 2024 Friends of Emacs-PHP development

;; Author: USAMI Kenta <[email protected]>
;; Created: 18 May 2016
;; Version: 0.0.1
;; Package-Requires: ((emacs "26.3"))
;; Keywords: lisp, datetime, calendar
;; Homepage: https://github.com/zonuexe/emacs-datetime

;; This file is NOT part of GNU Emacs.

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

;;; Commentary:

;; Test codes for datetime-format.

;;; Code:
(require 'ert)
(require 'datetime-format)
(require 'timecop)

(eval-when-compile
(require 'compat-28))

(defvar datetime-format-original-tz (getenv "TZ"))

(defmacro datetime-format--map (list function)
"Apply FUNCTION to each element of LIST.
This macro helps with expression expansion at compile time."
(declare (indent 1))
(let ((sequence (eval list)))
`(prog1 (quote ,sequence)
,@(mapcar function sequence))))

(ert-deftest datetime-format-test-env-tz ()
(should (string= datetime-format-original-tz "-9:30")))

(ert-deftest datetime-format-test-format ()
(with-environment-variables (("TZ" "-9:30")) ;; Australia/Darwin
(datetime-format--map '(("2009-02-14T09:01:30+09:30" (datetime-format 'atom))
("2009-02-14T09:01:30+09:30" (datetime-format 'atom (current-time)))
("1970-01-01T09:30:00+09:30" (datetime-format 'atom 0))
("1970-01-01T00:00:00+00:00" (datetime-format 'atom 0 :timezone "UTC"))
("2015-01-12T02:31:11+09:30" (datetime-format 'atom "2015-01-12 02:01:11"))
("2015-01-12T02:01:11+02:00" (datetime-format 'atom "2015-01-12 02:01:11"
:timezone "Europe/Kiev"))
("2015-01-11T17:01:11Z" (datetime-format 'atom-utc "2015-01-12 02:01:11"))
("2009-02-13T18:31:30-05:00" (datetime-format 'atom nil
:timezone "America/New_York")))
(lambda (pair)
(cl-destructuring-bind (expected expr) pair
`(timecop 1234567890 (should (string= ,expected (eval ,expr))))))))
(setenv "TZ" datetime-format-original-tz))

(provide 'datetime-format-test)
;;; datetime-format-test.el ends here
2 changes: 1 addition & 1 deletion datetime-format.el
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
;; Author: USAMI Kenta <[email protected]>
;; Created: 16 May 2016
;; Version: 0.0.1
;; Package-Requires: ((emacs "26.3"))
;; Package-Requires: ((emacs "26.3") (compat "29"))
;; Keywords: lisp, datetime, calendar
;; Homepage: https://github.com/emacs-php/emacs-datetime

Expand Down
47 changes: 0 additions & 47 deletions test-datetime-format.el

This file was deleted.

Loading