locale-dependent test failure for day-of-week
dilbernd opened this issue · 4 comments
Building 707f16daf19e04cf182cc532a2cce8db170ea178 using Leiningen, I get a test failure:
FAIL in (constructors) (java_time_test.clj:61)
enums
expected: (= (j/day-of-week 4) (j/day-of-week :thursday) (j/day-of-week (j/local-date clock)) (j/day-of-week "ee" "05"))
actual: (not (= #object[java.time.DayOfWeek 0x9d818b5 "THURSDAY"] #object[java.time.DayOfWeek 0x9d818b5 "THURSDAY"] #object[java.time.DayOfWeek 0x9d818b5 "THURSDAY"] #object[java.time.DayOfWeek 0x4f8e6101 "FRIDAY"]))
This is a locale issue. In a REPL with my system locale (English in Austria):
(ns jt-test (:require [java-time :as jt] [java-time.format :as jtf]))
=> nil
(jt/day-of-week (jtf/parse "ee" "05"))
=> #object[java.time.DayOfWeek 0x6ab351fe "FRIDAY"]
In a REPL with -Duser.country=US set on the JVM:
(ns jt-test (:require [java-time :as jt] [java-time.format :as jtf]))
=> nil
(jt/day-of-week (jtf/parse "ee" "05"))
=> #object[java.time.DayOfWeek 0x67860a8c "THURSDAY"]
This is consistent with the expected first DoW being Sunday in the US, but Monday in (at least continental) Europe.
Thanks for the report! What would you think would be the right solution for the issue?
No idea, sorry.
(Thought about it a bit when I discovered it; really drove home the value of explicit parameter (or closure/partials) dependencies, this is errno all over.)
The solution for this issue - make the tests locale-independent. Easiest - remove the offender identified in this issue from the tests. Harder - set the default TZ to the known value during test execution and revert to the previous value afterwards.
Removed the locale-dependent test.