flake: Attempt to run doctests
Reviewed-by: Alexander Kobjolke <me@failco.de>
This commit is contained in:
parent
64cdbc9bce
commit
8f76ec738e
6 changed files with 26 additions and 14 deletions
27
test/spec/HCatSpec.hs
Normal file
27
test/spec/HCatSpec.hs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
-- {-# LANGUAGE GHC2021 #-}
|
||||
|
||||
module HCatSpec (spec) where
|
||||
|
||||
import HCat.Internal (chunksOf, parseArgs)
|
||||
|
||||
import Test.Hspec
|
||||
import Test.Hspec.QuickCheck (prop)
|
||||
import Test.QuickCheck (Positive (getPositive))
|
||||
|
||||
spec :: Spec
|
||||
spec = do
|
||||
describe "parseArgs" do
|
||||
it "returns the filename if given a single argument" do
|
||||
parseArgs ["foo"] `shouldBe` Right "foo"
|
||||
parseArgs [] `shouldBe` Left "No filename given!"
|
||||
parseArgs ["foo", "bar"] `shouldBe` Left "Only a single file is supported"
|
||||
describe "chunksOf" $ do
|
||||
prop "each chunk contains at most N items" $ \n xs ->
|
||||
let chunkLengths = length <$> chunksOf n (xs :: [Int])
|
||||
in case chunkLengths of
|
||||
[] -> pure ()
|
||||
ns -> maximum ns `shouldSatisfy` (<= n)
|
||||
|
||||
prop "the sum of all lengths is equal to the length of the input" $ \n xs ->
|
||||
let chunkLengths = length <$> chunksOf (getPositive n) (xs :: [Int])
|
||||
in sum chunkLengths `shouldBe` length xs
|
||||
1
test/spec/Spec.hs
Normal file
1
test/spec/Spec.hs
Normal file
|
|
@ -0,0 +1 @@
|
|||
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
|
||||
Loading…
Add table
Add a link
Reference in a new issue