Sha256: 79e99031048a4574c27e4ec98da324f50030824f1901852f6233bad5ac40a728

Contents?: true

Size: 1.98 KB

Versions: 229

Compression:

Stored size: 1.98 KB

Contents

import Data.Char          (toUpper)
import Data.Time.Calendar (fromGregorian)
import Test.Hspec         (Spec, it, shouldBe)
import Test.Hspec.Runner  (configFastFail, defaultConfig, hspecWith)

import Person
  ( Address (..)
  , Born    (..)
  , Name    (..)
  , Person  (..)
  , bornStreet
  , renameStreets
  , setBirthMonth
  , setCurrentStreet
  )

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

specs :: Spec
specs = do

    it "bornStreet" $
      (bornStreet . _born) testPerson
      `shouldBe` "Longway"

    it "setCurrentStreet" $
      (_street . _address . setCurrentStreet "Middleroad") testPerson
      `shouldBe` "Middleroad"

    it "setBirthMonth" $
      (_bornOn . _born . setBirthMonth 9) testPerson
      `shouldBe` fromGregorian 1984 9 12

    it "renameStreets birth" $
      (_street . _bornAt . _born . renameStreets (map toUpper)) testPerson
      `shouldBe` "LONGWAY"

    it "renameStreets current" $
      (_street . _address . renameStreets (map toUpper)) testPerson
      `shouldBe` "SHORTLANE"

testPerson :: Person
testPerson = Person {
               _name = Name {
                         _foreNames = "Jane Joanna",
                         _surName   = "Doe"
                       },
               _born = Born {
                         _bornAt = Address {
                                     _street      = "Longway"      ,
                                     _houseNumber = 1024           ,
                                     _place       = "Springfield"  ,
                                     _country     = "United States"
                                   },
                         _bornOn = fromGregorian 1984 4 12
                       },
               _address = Address {
                            _street      = "Shortlane" ,
                            _houseNumber = 2           ,
                            _place       = "Fallmeadow",
                            _country     = "Canada"
                          }
             }

Version data entries

229 entries across 229 versions & 1 rubygems

Version Path
trackler-2.2.1.159 tracks/haskell/exercises/lens-person/test/Tests.hs
trackler-2.2.1.158 tracks/haskell/exercises/lens-person/test/Tests.hs
trackler-2.2.1.157 tracks/haskell/exercises/lens-person/test/Tests.hs
trackler-2.2.1.156 tracks/haskell/exercises/lens-person/test/Tests.hs
trackler-2.2.1.155 tracks/haskell/exercises/lens-person/test/Tests.hs
trackler-2.2.1.154 tracks/haskell/exercises/lens-person/test/Tests.hs
trackler-2.2.1.153 tracks/haskell/exercises/lens-person/test/Tests.hs
trackler-2.2.1.152 tracks/haskell/exercises/lens-person/test/Tests.hs
trackler-2.2.1.151 tracks/haskell/exercises/lens-person/test/Tests.hs
trackler-2.2.1.150 tracks/haskell/exercises/lens-person/test/Tests.hs
trackler-2.2.1.149 tracks/haskell/exercises/lens-person/test/Tests.hs
trackler-2.2.1.148 tracks/haskell/exercises/lens-person/test/Tests.hs
trackler-2.2.1.147 tracks/haskell/exercises/lens-person/test/Tests.hs
trackler-2.2.1.146 tracks/haskell/exercises/lens-person/test/Tests.hs
trackler-2.2.1.145 tracks/haskell/exercises/lens-person/test/Tests.hs
trackler-2.2.1.144 tracks/haskell/exercises/lens-person/test/Tests.hs
trackler-2.2.1.143 tracks/haskell/exercises/lens-person/test/Tests.hs
trackler-2.2.1.142 tracks/haskell/exercises/lens-person/test/Tests.hs
trackler-2.2.1.141 tracks/haskell/exercises/lens-person/test/Tests.hs
trackler-2.2.1.140 tracks/haskell/exercises/lens-person/test/Tests.hs