Skip to content

Commit

Permalink
Merge pull request #3 from shayne-fletcher/some-tests
Browse files Browse the repository at this point in the history
get tests going
  • Loading branch information
ekmett committed Mar 29, 2024
2 parents 54f77b1 + 589297c commit 865f853
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ jobs:
with:
ghc-version: ${{ matrix.ghc }}
- run: cabal new-build all
- run: cabal new-test --test-option=--color=always --test-show-details=always test:placeholder-test
9 changes: 9 additions & 0 deletions placeholder.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,12 @@ library
import: base
hs-source-dirs: src
exposed-modules: Control.Placeholder

test-suite placeholder-test
import: base
type: exitcode-stdio-1.0
main-is:
Test.hs
hs-source-dirs:
test
build-depends: placeholder, tasty >= 1.2, tasty-hunit >= 0.10.0
34 changes: 34 additions & 0 deletions test/Test.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{-# OPTIONS_GHC -Wno-deprecations #-}

import Test.Tasty
import Test.Tasty.HUnit

import Control.Exception
import Control.Placeholder

import Data.List

main :: IO ()
main = defaultMain tests

tests :: TestTree
tests = testGroup " All tests" [
basic
]

basic :: TestTree
basic = testGroup "Basic" [
testCase "todo" $ todoTest
]

todoTest :: IO ()
todoTest = do
result <- try (evaluate $ todo) :: IO (Either TodoException Int)
case result of
Left ex -> do
let msg = show ex
assertBool "todo(1)" $ all (flip isInfixOf msg) [
"Control.Placeholder.todo: not yet implemented"
, "test/Test.hs:26:29"
]
_ -> assertBool "todo (1)" False

0 comments on commit 865f853

Please sign in to comment.