2015-08-19 22:14:34 +02:00
|
|
|
import Test.Hspec
|
|
|
|
|
2015-08-20 21:44:09 +02:00
|
|
|
import GEval
|
2015-08-19 23:24:19 +02:00
|
|
|
import qualified Test.HUnit as HU
|
2015-08-19 22:14:34 +02:00
|
|
|
|
2015-08-17 23:32:00 +02:00
|
|
|
main :: IO ()
|
2015-08-19 22:14:34 +02:00
|
|
|
main = hspec $ do
|
|
|
|
describe "mean square error" $ do
|
|
|
|
it "simple test" $ do
|
2015-08-21 22:56:32 +02:00
|
|
|
geval (defaultGEvalSpecification {gesExpectedDirectory=Just "test/mse-simple/mse-simple", gesOutDirectory="test/mse-simple/mse-simple-solution"}) `shouldReturnAlmost` 0.64549722436790
|
2015-08-19 23:24:19 +02:00
|
|
|
|
|
|
|
class AEq a where
|
|
|
|
(=~) :: a -> a -> Bool
|
|
|
|
|
|
|
|
instance AEq Double where
|
|
|
|
x =~ y = abs ( x - y ) < (1.0e-8 :: Double)
|
|
|
|
|
|
|
|
(@=~?) :: (Show a, AEq a) => a -> a -> HU.Assertion
|
|
|
|
(@=~?) expected actual = expected =~ actual HU.@? assertionMsg
|
|
|
|
where
|
|
|
|
assertionMsg = "Expected : " ++ show expected ++
|
|
|
|
"\nActual : " ++ show actual
|
|
|
|
|
|
|
|
shouldReturnAlmost :: (AEq a, Show a, Eq a) => IO a -> a -> Expectation
|
|
|
|
shouldReturnAlmost action expected = action >>= (@=~? expected)
|