Skip to content

Commit 546963b

Browse files
committed
coercion tests
1 parent 96f4aa0 commit 546963b

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

test/java_time/api_test.clj

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,23 @@
438438
(is (= j/plus j/+))
439439
(is (= j/minus j/-)))
440440

441+
(defmacro is-<-coerce
442+
[a b c a' b' c']
443+
(assert ((every-pred symbol?) a b c))
444+
(assert ((every-pred (some-fn number? keyword?)) a' b' c'))
445+
`(do (is (j/> ~b ~a'))
446+
(is (not (j/> ~a ~b')))
447+
(is (j/< ~b ~c'))
448+
(is (not (j/< ~c ~b')))
449+
(is (j/<= ~b ~c'))
450+
;;FIXME https://github.com/dm3/clojure.java-time/issues/105
451+
;;(is (j/<= ~b ~b'))
452+
(is (not (j/<= ~c ~b')))
453+
;;FIXME https://github.com/dm3/clojure.java-time/issues/105
454+
;;(is (j/>= ~b ~b'))
455+
(is (j/>= ~b ~a'))
456+
(is (not (j/>= ~a ~b')))))
457+
441458
(defmacro is-< [a b c]
442459
(assert ((every-pred symbol?) a b c))
443460
`(do (is (j/> ~a))
@@ -504,34 +521,22 @@
504521
(let [thursday (j/day-of-week :thursday)
505522
saturday (j/day-of-week :saturday)
506523
sunday (j/day-of-week :sunday)]
507-
;; no properties
508-
(is (j/after? saturday :thursday))
509-
(is (not (j/after? thursday :saturday)))
510-
(is (j/before? saturday :sunday))
511-
(is (not (j/before? sunday :saturday)))
512-
;; has properties
524+
(is-<-coerce thursday saturday sunday
525+
:thursday :saturday :sunday)
513526
(is-< thursday saturday sunday))
514527

515528
(let [january (j/month :january)
516529
february (j/month :february)
517530
march (j/month :march)]
518-
;; no properties
519-
(is (j/after? february :january))
520-
(is (not (j/after? january :february)))
521-
(is (j/before? february :march))
522-
(is (not (j/before? march :february)))
523-
;; has properties
531+
(is-<-coerce january february march
532+
:january :february :march)
524533
(is-< january february march))
525534

526535
(let [year-2009 (j/year 2009)
527536
year-2010 (j/year 2010)
528537
year-2011 (j/year 2011)]
529-
;; no properties
530-
(is (j/after? year-2010 2009))
531-
(is (not (j/after? year-2009 2010)))
532-
(is (j/before? year-2009 2010))
533-
(is (not (j/before? year-2010 2009)))
534-
;; has properties
538+
(is-<-coerce year-2009 year-2010 year-2011
539+
2009 2010 2011)
535540
(is-< year-2009 year-2010 year-2011))
536541

537542
(let [jan-1 (j/month-day 1 1)

0 commit comments

Comments
 (0)