-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathTest.hs
37 lines (31 loc) · 1.17 KB
/
Test.hs
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
{- The Test module provides an interface to test-framework. It is called when --tests
- is supplied on the command line. This file only gathers together various test suites
- from all over the rest of the code and then executes them via test-framework.
-}
module Test (runTests) where
import System.Environment ( getArgs )
import Test.Framework
import Test.Framework.Providers.QuickCheck2
import qualified Data.PieceSet (testSuite)
import qualified Data.Queue (testSuite)
import qualified Protocol.BCode (testSuite)
import qualified Protocol.Wire (testSuite)
import qualified Process.Peer (testSuite)
runTests :: IO ()
runTests =
do args <- filter (/= "--tests") `fmap` getArgs
flip defaultMainWithArgs args
[ testSuite
, Data.Queue.testSuite
, Data.PieceSet.testSuite
, Protocol.BCode.testSuite
, Protocol.Wire.testSuite
, Process.Peer.testSuite
]
testSuite :: Test
testSuite = testGroup "Test test-framework"
[ testProperty "reverse-reverse/id" prop_reversereverse ]
-- reversing twice a finite list, is the same as identity
prop_reversereverse :: [Int] -> Bool
prop_reversereverse s = (reverse . reverse) s == id s
where _ = s :: [Int]