Sha256: 769974c1390395eb47515efd0c37164c90118ab46e487d17ac120e10090db883

Contents?: true

Size: 1.19 KB

Versions: 165

Compression:

Stored size: 1.19 KB

Contents

import Data.Time.Clock   (UTCTime)
import Test.Hspec        (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)

import Gigasecond (fromDay)

import Data.Time.Format
  ( ParseTime
  , TimeLocale
  , defaultTimeLocale
  , iso8601DateFormat
  , parseTimeOrError
  )

readTime :: ParseTime t => TimeLocale -> String -> String -> t
readTime = parseTimeOrError True

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs

specs :: Spec
specs = describe "gigasecond" $
          describe "fromDay" $ do

            -- Test cases loosely based on reference file
            -- at `exercism/x-common/gigasecond.json`.

            let dt = readTime defaultTimeLocale
                     (iso8601DateFormat (Just "%T%Z")) :: String -> UTCTime

            it "from apr 25 2011" $
              fromDay (dt "2011-04-25T00:00:00Z")
              `shouldBe` dt "2043-01-01T01:46:40Z"

            it "from jun 13 1977" $
              fromDay (dt "1977-06-13T00:00:00Z")
              `shouldBe` dt "2009-02-19T01:46:40Z"

            it "from jul 19 1959" $
              fromDay (dt "1959-07-19T00:00:00Z")
              `shouldBe` dt "1991-03-27T01:46:40Z"

Version data entries

165 entries across 165 versions & 1 rubygems

Version Path
trackler-2.0.8.45 tracks/haskell/exercises/gigasecond/test/Tests.hs
trackler-2.0.8.44 tracks/haskell/exercises/gigasecond/test/Tests.hs
trackler-2.0.8.43 tracks/haskell/exercises/gigasecond/test/Tests.hs
trackler-2.0.8.42 tracks/haskell/exercises/gigasecond/test/Tests.hs
trackler-2.0.8.41 tracks/haskell/exercises/gigasecond/test/Tests.hs
trackler-2.0.8.40 tracks/haskell/exercises/gigasecond/test/Tests.hs
trackler-2.0.8.39 tracks/haskell/exercises/gigasecond/test/Tests.hs
trackler-2.0.8.38 tracks/haskell/exercises/gigasecond/test/Tests.hs
trackler-2.0.8.37 tracks/haskell/exercises/gigasecond/test/Tests.hs
trackler-2.0.8.36 tracks/haskell/exercises/gigasecond/test/Tests.hs
trackler-2.0.8.35 tracks/haskell/exercises/gigasecond/test/Tests.hs
trackler-2.0.8.34 tracks/haskell/exercises/gigasecond/test/Tests.hs
trackler-2.0.8.33 tracks/haskell/exercises/gigasecond/test/Tests.hs
trackler-2.0.8.32 tracks/haskell/exercises/gigasecond/test/Tests.hs
trackler-2.0.8.31 tracks/haskell/exercises/gigasecond/test/Tests.hs
trackler-2.0.8.30 tracks/haskell/exercises/gigasecond/test/Tests.hs
trackler-2.0.8.29 tracks/haskell/exercises/gigasecond/test/Tests.hs
trackler-2.0.8.28 tracks/haskell/exercises/gigasecond/test/Tests.hs
trackler-2.0.8.27 tracks/haskell/exercises/gigasecond/test/Tests.hs
trackler-2.0.8.26 tracks/haskell/exercises/gigasecond/test/Tests.hs