-
Notifications
You must be signed in to change notification settings - Fork 16
/
Test.hs
43 lines (35 loc) · 1.23 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
37
38
39
40
41
42
43
{-# LANGUAGE NoMonomorphismRestriction #-}
module Numeric.Units.Dimensional.DK.Test where
import Numeric.Units.Dimensional.DK.Prelude
import qualified Prelude
import Data.AEq
import Test.HUnit
import Test.QuickCheck
testPower = TestLabel "Power test" $ TestList
[ TestCase $ (9 *~ one) @=? (3 *~ one) ^ pos2
, TestCase $ (1 *~ one) @=? (12.1231 *~ one) ^ zero
, TestCase $ (0.25 *~ one) @=? (2 *~ one) ^ neg2
]
testDimensionless = TestLabel "Dimensionless test" $ TestList
[ TestCase $ (3 Prelude.** 2) *~ one @=? (3 *~ one) ** (2 *~ one)
]
testShow = TestLabel "Test 'Show' instance" $ TestList
[ TestCase $ show (1 *~ one) @?= "1"
, TestCase $ show (2 *~ meter) @?= "2 m"
, TestCase $ show (2.0 *~ (meter / second)) @?= "2.0 m s^-1"
, TestCase $ show (2.0 *~ (meter ^ pos2 / second ^ pos2)) @?= "2.0 m^2 s^-2"
--, TestCase $ show (undefined :: DimRep DVelocity) @?= "m s^-1"
]
-- Collect the test cases.
tests = TestList
[ testPower
, testDimensionless
, testShow
]
prop_fromEnumTo x0 x1 xf = let
xs = enumFromThenTo (x0::Double) x1 xf
ys = fromThenTo (x0*~one) (x1*~one) (xf*~one) /~~ one
in take 100 xs ~== take 100 ys
main = do
runTestTT tests
quickCheck prop_fromEnumTo