emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/compat 639d03eed7 04/13: Restore date tests


From: ELPA Syncer
Subject: [elpa] externals/compat 639d03eed7 04/13: Restore date tests
Date: Wed, 4 Jan 2023 11:57:31 -0500 (EST)

branch: externals/compat
commit 639d03eed7cf0e0b59fbc803b83e0ca479b07653
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Restore date tests
---
 compat-tests.el | 113 ++++++++++++++++++++++++++++----------------------------
 1 file changed, 57 insertions(+), 56 deletions(-)

diff --git a/compat-tests.el b/compat-tests.el
index d17d397cca..92120da912 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -39,6 +39,7 @@
 (require 'ert)
 (require 'compat)
 (require 'subr-x)
+(require 'time-date)
 (require 'text-property-search nil t)
 (setq ert-quiet t)
 
@@ -1514,6 +1515,62 @@
   (should-not (time-equal-p '(1 2 3 4) '(2 2 3 4)))
   (should-not (time-equal-p '(2 2 3 4) '(1 2 3 4))))
 
+(ert-deftest decoded-time-period ()
+  (should-equal 0 (decoded-time-period '()))
+  (should-equal 0 (decoded-time-period '(0)))
+  (should-equal 1 (decoded-time-period '(1)))
+  (should-equal 0.125 (decoded-time-period '((1 . 8))))
+
+  (should-equal 60 (decoded-time-period '(0 1)))
+  (should-equal 61 (decoded-time-period '(1 1)))
+  (should-equal -59 (decoded-time-period '(1 -1)))
+
+  (should-equal (* 60 60) (decoded-time-period '(0 0 1)))
+  (should-equal (+ (* 60 60) 60) (decoded-time-period '(0 1 1)))
+  (should-equal (+ (* 60 60) 120 1) (decoded-time-period '(1 2 1)))
+
+  (should-equal (* 60 60 24) (decoded-time-period '(0 0 0 1)))
+  (should-equal (+ (* 60 60 24) 1) (decoded-time-period '(1 0 0 1)))
+  (should-equal (+ (* 60 60 24) (* 60 60) 60 1) (decoded-time-period '(1 1 1 
1)))
+  (should-equal (+ (* 60 60 24) (* 60 60) 120 1) (decoded-time-period '(1 2 1 
1)))
+
+  (should-equal (* 60 60 24 30) (decoded-time-period '(0 0 0 0 1)))
+  (should-equal (+ (* 60 60 24 30) 1) (decoded-time-period '(1 0 0 0 1)))
+  (should-equal (+ (* 60 60 24 30) 60 1) (decoded-time-period '(1 1 0 0 1)))
+  (should-equal (+ (* 60 60 24 30) (* 60 60) 60 1)
+         (decoded-time-period '(1 1 1 0 1)))
+  (should-equal (+ (* 60 60 24 30) (* 60 60 24) (* 60 60) 120 1)
+         (decoded-time-period '(1 2 1 1 1)))
+
+  (should-equal (* 60 60 24 365) (decoded-time-period '(0 0 0 0 0 1)))
+  (should-equal (+ (* 60 60 24 365) 1)
+         (decoded-time-period '(1 0 0 0 0 1)))
+  (should-equal (+ (* 60 60 24 365) 60 1)
+         (decoded-time-period '(1 1 0 0 0 1)))
+  (should-equal (+ (* 60 60 24 365) (* 60 60) 60 1)
+         (decoded-time-period '(1 1 1 0 0 1)))
+  (should-equal (+ (* 60 60 24 365) (* 60 60 24) (* 60 60) 60 1)
+         (decoded-time-period '(1 1 1 1 0 1)))
+  (should-equal (+ (* 60 60 24 365)
+            (* 60 60 24 30)
+            (* 60 60 24)
+            (* 60 60)
+            120 1)
+         (decoded-time-period '(1 2 1 1 1 1)))
+
+  (should-error (decoded-time-period 'a) :type 'wrong-type-argument)
+  (should-error (decoded-time-period '(0 a)) :type 'wrong-type-argument)
+  (should-error (decoded-time-period '(0 0 a)) :type 'wrong-type-argument)
+  (should-error (decoded-time-period '(0 0 0 a)) :type 'wrong-type-argument)
+  (should-error (decoded-time-period '(0 0 0 0 a)) :type 'wrong-type-argument)
+  (should-error (decoded-time-period '(0 0 0 0 0 a)) :type 
'wrong-type-argument))
+
+(ert-deftest date-days-in-month ()
+  (should-equal 31 (date-days-in-month 2020 1))
+  (should-equal 30 (date-days-in-month 2020 4))
+  (should-equal 29 (date-days-in-month 2020 2))
+  (should-equal 28 (date-days-in-month 2021 2)))
+
 ;; (ert-deftest regexp-opt ()
 ;;   ;; Ensure `regexp-opt' doesn't change the existing
 ;;   ;; behaviour:
@@ -1584,62 +1641,6 @@
 ;;     (when (boundp 'regexp-unmatchable)
 ;;       (should-not (string-match-p regexp-unmatchable str)))))
 
-;; (ert-deftest date-days-in-month
-;;   (should-equal 31 2020 1)
-;;   (should-equal 30 2020 4)
-;;   (should-equal 29 2020 2)
-;;   (should-equal 28 2021 2))
-
-;; (ert-deftest decoded-time-period
-;;   (should-equal 0 '())
-;;   (should-equal 0 '(0))
-;;   (should-equal 1 '(1))
-;;   (should-equal 0.125 '((1 . 8)))
-
-;;   (should-equal 60 '(0 1))
-;;   (should-equal 61 '(1 1))
-;;   (should-equal -59 '(1 -1))
-
-;;   (should-equal (* 60 60) '(0 0 1))
-;;   (should-equal (+ (* 60 60) 60) '(0 1 1))
-;;   (should-equal (+ (* 60 60) 120 1) '(1 2 1))
-
-;;   (should-equal (* 60 60 24) '(0 0 0 1))
-;;   (should-equal (+ (* 60 60 24) 1) '(1 0 0 1))
-;;   (should-equal (+ (* 60 60 24) (* 60 60) 60 1) '(1 1 1 1))
-;;   (should-equal (+ (* 60 60 24) (* 60 60) 120 1) '(1 2 1 1))
-
-;;   (should-equal (* 60 60 24 30) '(0 0 0 0 1))
-;;   (should-equal (+ (* 60 60 24 30) 1) '(1 0 0 0 1))
-;;   (should-equal (+ (* 60 60 24 30) 60 1) '(1 1 0 0 1))
-;;   (should-equal (+ (* 60 60 24 30) (* 60 60) 60 1)
-;;          '(1 1 1 0 1))
-;;   (should-equal (+ (* 60 60 24 30) (* 60 60 24) (* 60 60) 120 1)
-;;          '(1 2 1 1 1))
-
-;;   (should-equal (* 60 60 24 365) '(0 0 0 0 0 1))
-;;   (should-equal (+ (* 60 60 24 365) 1)
-;;          '(1 0 0 0 0 1))
-;;   (should-equal (+ (* 60 60 24 365) 60 1)
-;;          '(1 1 0 0 0 1))
-;;   (should-equal (+ (* 60 60 24 365) (* 60 60) 60 1)
-;;          '(1 1 1 0 0 1))
-;;   (should-equal (+ (* 60 60 24 365) (* 60 60 24) (* 60 60) 60 1)
-;;          '(1 1 1 1 0 1))
-;;   (should-equal (+ (* 60 60 24 365)
-;;             (* 60 60 24 30)
-;;             (* 60 60 24)
-;;             (* 60 60)
-;;             120 1)
-;;          '(1 2 1 1 1 1))
-
-;;   (should-error wrong-type-argument 'a)
-;;   (should-error wrong-type-argument '(0 a))
-;;   (should-error wrong-type-argument '(0 0 a))
-;;   (should-error wrong-type-argument '(0 0 0 a))
-;;   (should-error wrong-type-argument '(0 0 0 0 a))
-;;   (should-error wrong-type-argument '(0 0 0 0 0 a)))
-
 ;; TODO func-arity seems broken
 ;; (ert-deftest func-arity
 ;;   (should-equal '(0 . 0) (func-arity (lambda ()))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]