Skip to content

Commit

Permalink
Fix test suite and include test for issue #5
Browse files Browse the repository at this point in the history
  • Loading branch information
IagoAbal committed Jul 18, 2015
1 parent b0b3700 commit 1466299
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
12 changes: 11 additions & 1 deletion test/Spec.hs
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}

import Test.Hspec

import qualified Z3.Base.Spec

main :: IO ()
main = hspec spec

spec :: Spec
spec = do
describe "Z3.Base" Z3.Base.Spec.spec
18 changes: 15 additions & 3 deletions test/Z3/Base/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ withContext k = do
ctx <- Z3.withConfig Z3.mkContext
k ctx

anyZ3Error :: Selector Z3.Z3Error
anyZ3Error = const True

spec :: Spec
spec = around withContext $ do

Expand All @@ -24,14 +27,23 @@ spec = around withContext $ do
monadicIO $ do
x::Maybe Bool <- run $ do
ast <- Z3.mkBool ctx b
Z3.getBool ctx ast
Z3.getBoolValue ctx ast
assert $ x == Just b

context "Numerals" $ do

specify "mkInt" $ \ctx -> property $ \(i :: Integer) ->
monadicIO $ do
x::Integer <- run $ do
ast <- Z3.mkInt ctx i;
ast <- Z3.mkInteger ctx i;
Z3.getInt ctx ast;
assert $ x == i
assert $ x == i

context "Bit-vectors" $ do

specify "mkBvmul" $ \ctx ->
let bad = do
x <- Z3.mkFreshIntVar ctx "x";
Z3.mkBvmul ctx x x
in bad `shouldThrow` anyZ3Error

2 changes: 2 additions & 0 deletions z3.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ Test-suite spec

Main-is: Spec.hs

Other-modules: Z3.Base.Spec

Build-depends: base >= 4.5,
z3 == 4.*,
hspec >= 2.1,
Expand Down

0 comments on commit 1466299

Please sign in to comment.