can-i-haz-0.1.0.0: test/Spec.hs
import Test.Hspec
import Test.ShouldNotTypecheck
import Control.Monad.Reader.Has
import Common
import TypecheckFailures
main :: IO ()
main = hspec $ do
let baseFooEnv = FooEnv 10 "meh"
let baseBarEnv = BarEnv 4.2 [1, 2, 3]
describe "Basic Has instance" $
it "any type Has itself" $ do
let exFoo = extract baseFooEnv
exFoo `shouldBe` baseFooEnv
describe "Generic Has instances" $ do
it "envs have their components" $ do
let exFoo = extract $ AppEnv baseFooEnv baseBarEnv
exFoo `shouldBe` baseFooEnv
let exBar = extract $ AppEnv baseFooEnv baseBarEnv
exBar `shouldBe` baseBarEnv
it "tuples have their components" $ do
let exFoo = extract (baseFooEnv, baseBarEnv)
exFoo `shouldBe` baseFooEnv
let exBar = extract (baseFooEnv, baseBarEnv)
exBar `shouldBe` baseBarEnv
describe "Should not typecheck" $ do
it "if there is no such type in the hierarchy" $ shouldNotTypecheck extractMissing
it "if there is more than one such type in the hierarchy" $ shouldNotTypecheck extractMultiple