Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 44 lines (36 sloc) 1.111 kb
2d7f85b @clanehin implemented the SegHopList and optimized Grids with caching
authored
1
eb4b7b8 @clanehin Package move to Roguestar.Lib.
authored
2 module Roguestar.Lib.Tests
583286a @clanehin creatures can be in planes, with line of sight rules
authored
3 (TestResult(..),
4 TestCase,
5 test,
6 runAllTests,
7 sampleTestCase)
c6eaa50 @clanehin initial import
authored
8 where
9
10 data TestResult = Passed String | Failed String deriving Show
11
12 type TestCase = IO TestResult
13
fea145b @clanehin integrated HopList into the grid system
authored
14 -- |
c6eaa50 @clanehin initial import
authored
15 -- Sample test case that always passes.
16 --
17 sampleTestCase :: IO TestResult
18 sampleTestCase = do return (Passed "sampleTestCase")
19
fea145b @clanehin integrated HopList into the grid system
authored
20 -- |
c6eaa50 @clanehin initial import
authored
21 -- True if the TestResult is Passed, False otherwise
22 --
23 testResultToBool :: TestResult -> Bool
24 testResultToBool (Passed _) = True
25 testResultToBool (Failed _) = False
26
fea145b @clanehin integrated HopList into the grid system
authored
27 -- |
28 -- Simple way to generate a TestResult based on a boolean test result.
c6eaa50 @clanehin initial import
authored
29 --
fea145b @clanehin integrated HopList into the grid system
authored
30 test :: String -> Bool -> TestCase
31 test str True = return $ Passed str
32 test str False = return $ Failed str
33
34 -- |
c6eaa50 @clanehin initial import
authored
35 -- Runs every specified test case, returning True iff all tests pass.
36 -- Results from the tests are printed.
37 --
38 runAllTests :: [TestCase] -> IO Bool
39 runAllTests [] = do return True
40 runAllTests (testCase:testCases) = do testResult <- testCase
41 putStrLn (show testResult)
42 testResults <- runAllTests testCases
164aa68 @clanehin Upgrade license to GPLv3.
authored
43 return (testResults && testResultToBool testResult)
Something went wrong with that request. Please try again.