{-# OPTIONS_GHC -Wno-missing-local-signatures #-}
{-# OPTIONS_GHC -Wno-monomorphism-restriction #-}
{-# OPTIONS_GHC -Wno-name-shadowing #-}
{-# OPTIONS_GHC -Wno-type-defaults #-}
{- HLINT ignore "Redundant reverse" -}
module Main where
import Effectful
import Effectful.Hspec
import Effectful.QuickCheck ((.&&.), (===))
import Effectful.State.Static.Local (evalState, get, modify)
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
prop "pure prop" \(xs :: [Int]) ->
(reverse . reverse) xs == xs
prop "eff prop" \(n :: Int) ->
evalState n do
modify @Int (+ 1)
x <- get
pure $ (x === n + 1) .&&. (x > n)