commit 0be9bdbbbba83fdd6434cd1e1b1d8cf8902c4667
parent 455fc005f4c78c67957fa7c0530c98f2eb39da17
Author: Jared Tobin <jared@jtobin.io>
Date: Tue, 10 Sep 2019 13:38:55 -0230
tests: use hspec
Brings in hspec as a dependency and rewrites the test suites to use it.
Diffstat:
3 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/test/Med.hs b/test/Med.hs
@@ -3,7 +3,7 @@ module Main where
import Control.Monad (unless)
import Data.List (nub, foldl')
import Prelude hiding (tail)
-import System.Exit (exitSuccess, exitFailure)
+import Test.Hspec
import qualified Urbit.Ob.Ob as Ob
a, b, c :: Int
@@ -58,14 +58,15 @@ main = do
inv = fmap tail perm
distincts = nub perm
- let distinctElems = length distincts == length perm
- unless distinctElems exitFailure
+ hspec $ do
+ describe "feis" $ do
+ it "produces distinct elements" $
+ length distincts `shouldBe` length perm
- let permuteSuccessful = foldl' (\acc x -> x `elem` emm && acc) True perm
- unless permuteSuccessful exitFailure
+ it "permutes successfully" $
+ foldl' (\acc x -> x `elem` emm && acc) True perm `shouldBe` True
- let tailInvertsFeis = emm == inv
- unless tailInvertsFeis exitFailure
-
- exitSuccess
+ describe "tail" $
+ it "inverts feis" $
+ emm `shouldBe` inv
diff --git a/test/Small.hs b/test/Small.hs
@@ -3,7 +3,7 @@ module Main where
import Control.Monad (unless)
import Data.List (nub, foldl')
import Prelude hiding (tail)
-import System.Exit (exitSuccess, exitFailure)
+import Test.Hspec
import qualified Urbit.Ob.Ob as Ob
a, b, c :: Int
@@ -34,14 +34,15 @@ main = do
inv = fmap tail perm
distincts = nub perm
- let distinctElems = length distincts == length perm
- unless distinctElems exitFailure
+ hspec $ do
+ describe "feis" $ do
+ it "produces distinct elements" $
+ length distincts `shouldBe` length perm
- let permuteSuccessful = foldl' (\acc x -> x `elem` emm && acc) True perm
- unless permuteSuccessful exitFailure
+ it "permutes successfully" $
+ foldl' (\acc x -> x `elem` emm && acc) True perm `shouldBe` True
- let tailInvertsFeis = emm == inv
- unless tailInvertsFeis exitFailure
-
- exitSuccess
+ describe "tail" $
+ it "inverts feis" $
+ emm `shouldBe` inv
diff --git a/urbit-hob.cabal b/urbit-hob.cabal
@@ -73,6 +73,7 @@ Test-suite small
-rtsopts
build-depends:
base
+ , hspec
, urbit-hob
Test-suite medium
@@ -84,5 +85,6 @@ Test-suite medium
-rtsopts
build-depends:
base
+ , hspec
, urbit-hob