File: Main.hs

package info (click to toggle)
haskell-bitvec 1.1.5.0-4
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 332 kB
  • sloc: haskell: 3,408; ansic: 397; makefile: 5
file content (61 lines) | stat: -rw-r--r-- 1,579 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{-# LANGUAGE CPP       #-}
{-# LANGUAGE MagicHash #-}

module Main where

import Control.Exception
import Data.Bit
import Test.Tasty
import Test.Tasty.QuickCheck

#ifdef MIN_VERSION_quickcheck_classes_base
import Data.Proxy
import Test.QuickCheck.Classes.Base
import Support
#endif

import Tests.Conc (concTests)
import Tests.F2Poly (f2polyTests)
import Tests.MVector (mvectorTests)
import qualified Tests.MVectorTS as TS (mvectorTests)
import Tests.SetOps (setOpTests)
import qualified Tests.SetOpsTS as TS (setOpTests)
import Tests.Vector (vectorTests)

main :: IO ()
main = defaultMain $ testGroup "All"
  [ lawsTests
  , f2polyTests
  , mvectorTests
  , TS.mvectorTests
  , setOpTests
  , TS.setOpTests
  , vectorTests
  , concTests
  ]

lawsTests :: TestTree
lawsTests = adjustOption (const $ QuickCheckTests 100)
  $ testGroup "Bit"
#ifdef MIN_VERSION_quickcheck_classes_base
  $ map lawsToTest
  [ bitsLaws        (Proxy :: Proxy Bit)
  , eqLaws          (Proxy :: Proxy Bit)
  , ordLaws         (Proxy :: Proxy Bit)
  , boundedEnumLaws (Proxy :: Proxy Bit)
  , showLaws        (Proxy :: Proxy Bit)
  , showReadLaws    (Proxy :: Proxy Bit)
  , numLaws         (Proxy :: Proxy Bit)
  , integralLaws    (Proxy :: Proxy Bit)
  ] ++
#endif
  [ testProperty "divideByZero" prop_bitDivideByZero
  , testProperty "toRational"   prop_bitToRational
  ]

prop_bitToRational :: Bit -> Property
prop_bitToRational x = fromRational (toRational x) === x

prop_bitDivideByZero :: Bit -> Property
prop_bitDivideByZero x =
  ioProperty ((=== Left DivideByZero) <$> try (evaluate (x / 0)))