git.iko.soy/purescript-intl
on master help sign in
update tests
commite4f44f3b30f2a444bd77dd84e67de9cac736e41e authorMarcin Szamotulski <mszamot@gmail.com> dateSat 17 Jun 2017, 14:36 (9 years ago) parent6d536b8
1 file changed+38−20
test/Test/Main.purs+38−20
test/Test/Main.purs+38−20
@@ -3,7 +3,7 @@ module Test.Main where
33import Prelude
44
55import Control.Monad.Eff (Eff)
6−import Control.Monad.Eff.Console (CONSOLE, log)
6+import Control.Monad.Eff.Console (CONSOLE)
77import Data.DateTime (Date, DateTime(..), Month(..), canonicalDate)
88import Data.Enum (toEnum)
99import Data.Generic.Rep (class Generic)
@@ -15,7 +15,7 @@ import Data.Symbol (SProxy(..))
1515import Data.Time (Time(..))
1616import Data.Variant (inj)
1717import Partial.Unsafe (unsafeCrashWith)
18−import Test.Assert (ASSERT, assert)
18+import Test.Assert (ASSERT, assert')
1919
2020type Tests = Eff (console :: CONSOLE, assert :: ASSERT) Unit
2121
@@ -258,21 +258,39 @@ main = do
258258 case jsDate of
259259 Nothing -> unsafeCrashWith "jsDate not parsed"
260260 Just d -> do
261− log "fmtWeekdayYearMonthDayHourMinuteSecond"
262− assert $ formatJSDate fmtWeekdayYearMonthDayHourMinuteSecond d == "Tue, 2 January 2018, 12:00:00 pm"
263− log "fmtWeekdayYearMonthDay"
264− assert $ formatJSDate fmtWeekdayYearMonthDay d == "Tuesday, 02 Jan 18"
265− log "fmtYearMonthDay"
266− assert $ formatJSDate fmtYearMonthDay d == "02 J 18"
267− log "fmtYearMonth"
268− assert $ formatJSDate fmtYearMonth d == "01/2018"
269− log "fmtMonthDay"
270− assert $ formatJSDate fmtMonthDay d == "02/01"
271− log "fmtHourMinuteSecond"
272− assert $ formatJSDate fmtHourMinuteSecond d == "12:00:00"
273− log "fmtHourMinute"
274− assert $ formatJSDate fmtHourMinute d == "12:00"
275− log "fmtEraYear"
276− assert $ formatJSDate fmtEraYear d == "2018 Anno Domini"
277− log "fmtEra"
278− assert $ formatJSDate fmtEra d == "2 1 2018 AD"
261+ let fmtDate1 = formatJSDate fmtWeekdayYearMonthDayHourMinuteSecond d
262+ fmtDate1Expected = "Tue, 2 January 2018, 12:00:00 pm"
263+ assert' ("fmtWeekdayYearMonthDayHourMinuteSecond: got: '" <> fmtDate1 <> "' expected: '" <> fmtDate1Expected <> "'")
264+ $ fmtDate1 == fmtDate1Expected
265+ let fmtDate2 = formatJSDate fmtWeekdayYearMonthDay d
266+ fmtDate2Expected = "Tuesday, 02 Jan 18"
267+ assert' ("fmtWeekdayYearMonthDayString: got '" <> fmtDate2 <> "' expected: '" <> fmtDate2Expected <> "'")
268+ $ fmtDate2 == fmtDate2Expected
269+ let fmtDate3 = formatJSDate fmtYearMonthDay d
270+ fmtDate3Expected = "02 J 18"
271+ assert' ("fmtYearMonthDayString: got '" <> fmtDate3 <> "' expected: '" <> fmtDate3Expected <> "'")
272+ $ fmtDate3 == fmtDate3Expected
273+ let fmtDate4 = formatJSDate fmtYearMonth d
274+ fmtDate4Expected = "01/2018"
275+ assert' ("fmtYearMonthString: got '" <> fmtDate4 <> "' expected: '" <> fmtDate4Expected <> "'")
276+ $ fmtDate4 == fmtDate4Expected
277+ let fmtDate5 = formatJSDate fmtMonthDay d
278+ fmtDate5Expected = "02/01"
279+ assert' ("fmtMonthDayString: got '" <> fmtDate5 <> "' expected: '" <> fmtDate5Expected <> "'")
280+ $ fmtDate5 == fmtDate5Expected
281+ let fmtDate6 = formatJSDate fmtHourMinuteSecond d
282+ fmtDate6Expected = "12:00:00"
283+ assert' ("fmtHourMinuteSecondString: got '" <> fmtDate6 <> "' expected: '" <> fmtDate6Expected <> "'")
284+ $ fmtDate6 == fmtDate6Expected
285+ let fmtDate7 = formatJSDate fmtHourMinute d
286+ fmtDate7Expected = "12:00"
287+ assert' ("fmtHourMinuteString: got '" <> fmtDate7 <> "' expected: '" <> fmtDate7Expected <> "'")
288+ $ fmtDate7 == fmtDate7Expected
289+ let fmtDate8 = formatJSDate fmtEraYear d
290+ fmtDate8Expected = "2018 Anno Domini"
291+ assert' ("fmtEraYear: got '" <> fmtDate8 <> "' expected: '" <> fmtDate8Expected <> "'")
292+ $ fmtDate8 == fmtDate8Expected
293+ let fmtDate9 = formatJSDate fmtEra d
294+ fmtDate9Expected = "2 1 2018 AD"
295+ assert' ("fmtEra: got '" <> fmtDate9 <> "' expected: '" <> fmtDate9Expected <> "'")
296+ $ fmtDate9 == fmtDate9Expected