packages feed

hspec-effectful-0.1.0.0: test/Main.hs

{-# OPTIONS_GHC -Wno-missing-local-signatures #-}
{-# OPTIONS_GHC -Wno-monomorphism-restriction #-}
{-# OPTIONS_GHC -Wno-type-defaults #-}

module Main where

import Effectful
import Effectful.Hspec
import Prelude

main :: IO ()
main = runEff . runHspec $ do
    it "shouldBe" $ do
        10 `shouldBe` 10

    it "shouldSatisfy" $ do
        10 `shouldSatisfy` (> 5)

    let xs = [1, 2, 3, 4, 5] :: [Int]
    it "shouldStartWith" $ do
        xs `shouldStartWith` [1, 2]

    it "shouldEndWith" $ do
        xs `shouldEndWith` [4, 5]

    it "shouldContain" $ do
        [1, 2, 3] `shouldContain` [2]

    it "shouldMatchList" $ do
        [1, 2, 3] `shouldMatchList` [3, 2, 1]

    it "shouldReturn" $ do
        let action = pure "hello"
        action `shouldReturn` "hello"

    it "shouldThrow" $ do
        let errorAction = error "boom" :: Eff es ()
        errorAction `shouldThrow` anyException

    it "shouldNotBe" do
        1 `shouldNotBe` 2

    it "shouldNotSatisfy" do
        1 `shouldNotSatisfy` (> 10)

    it "shouldNotContain" do
        [1, 2] `shouldNotContain` [3]

    it "handles shouldNotReturn" $ do
        let action = pure (1 :: Int) :: Eff es Int
        action `shouldNotReturn` 2