summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2011-12-14 13:48:17 +0100
committerAlberto Ruiz <aruiz@um.es>2011-12-14 13:48:17 +0100
commite09160be46b10c0e6137ce9b5e1e879e73c88c3a (patch)
tree1ed4b5c41a73cb36fff4239ba0523aa120a09ca3
parent77552d080e88fc70312f55fd3303fac3464ab46e (diff)
test suite configured for hmatrix-tests
-rw-r--r--Setup.lhs3
-rw-r--r--packages/tests/Setup.lhs1
-rw-r--r--packages/tests/hmatrix-tests.cabal5
-rw-r--r--packages/tests/src/Numeric/LinearAlgebra/Tests.hs13
4 files changed, 15 insertions, 7 deletions
diff --git a/Setup.lhs b/Setup.lhs
index ba435f0..6f71194 100644
--- a/Setup.lhs
+++ b/Setup.lhs
@@ -8,7 +8,7 @@
8> import System.Process(system) 8> import System.Process(system)
9> import Config(config) 9> import Config(config)
10 10
11> main = defaultMainWithHooks simpleUserHooks { confHook = c, runTests = t } 11> main = defaultMainWithHooks simpleUserHooks { confHook = c }
12 12
13> c x y = do 13> c x y = do
14> binfo <- confHook simpleUserHooks x y 14> binfo <- confHook simpleUserHooks x y
@@ -16,5 +16,4 @@
16> let pkg_descr = localPkgDescr binfo 16> let pkg_descr = localPkgDescr binfo
17> return $ binfo { localPkgDescr = updatePackageDescription pbi pkg_descr } 17> return $ binfo { localPkgDescr = updatePackageDescription pbi pkg_descr }
18 18
19> t _ _ _ _ = system ( "runhaskell examples/tests.hs") >> return()
20 19
diff --git a/packages/tests/Setup.lhs b/packages/tests/Setup.lhs
index 6b32049..4b19c19 100644
--- a/packages/tests/Setup.lhs
+++ b/packages/tests/Setup.lhs
@@ -2,3 +2,4 @@
2 2
3> import Distribution.Simple 3> import Distribution.Simple
4> main = defaultMain 4> main = defaultMain
5
diff --git a/packages/tests/hmatrix-tests.cabal b/packages/tests/hmatrix-tests.cabal
index cd32a4e..9f7bcdc 100644
--- a/packages/tests/hmatrix-tests.cabal
+++ b/packages/tests/hmatrix-tests.cabal
@@ -11,7 +11,7 @@ Description: Tests for hmatrix
11Category: Math 11Category: Math
12tested-with: GHC==7.0.4 12tested-with: GHC==7.0.4
13 13
14cabal-version: >=1.6 14cabal-version: >=1.8
15 15
16build-type: Simple 16build-type: Simple
17 17
@@ -38,7 +38,8 @@ source-repository head
38 type: git 38 type: git
39 location: https://github.com/AlbertoRuiz/hmatrix 39 location: https://github.com/AlbertoRuiz/hmatrix
40 40
41Test-Suite tests 41Test-Suite basic
42 Build-Depends: base, hmatrix-tests
42 type: exitcode-stdio-1.0 43 type: exitcode-stdio-1.0
43 main-is: src/tests.hs 44 main-is: src/tests.hs
44 45
diff --git a/packages/tests/src/Numeric/LinearAlgebra/Tests.hs b/packages/tests/src/Numeric/LinearAlgebra/Tests.hs
index 69ef1b3..8d402d0 100644
--- a/packages/tests/src/Numeric/LinearAlgebra/Tests.hs
+++ b/packages/tests/src/Numeric/LinearAlgebra/Tests.hs
@@ -36,16 +36,22 @@ import Numeric.GSL
36import Prelude hiding ((^)) 36import Prelude hiding ((^))
37import qualified Prelude 37import qualified Prelude
38import System.CPUTime 38import System.CPUTime
39import System.Exit
39import Text.Printf 40import Text.Printf
40import Data.Packed.Development(unsafeFromForeignPtr,unsafeToForeignPtr) 41import Data.Packed.Development(unsafeFromForeignPtr,unsafeToForeignPtr)
41import Control.Arrow((***)) 42import Control.Arrow((***))
42import Debug.Trace 43import Debug.Trace
44import Control.Monad(when)
43 45
44import Test.QuickCheck(Arbitrary,arbitrary,coarbitrary,choose,vector 46import Test.QuickCheck(Arbitrary,arbitrary,coarbitrary,choose,vector
45 ,sized,classify,Testable,Property 47 ,sized,classify,Testable,Property
46 ,quickCheckWith,maxSize,stdArgs,shrink) 48 ,quickCheckWithResult,maxSize,stdArgs,shrink)
47 49
48qCheck n = quickCheckWith stdArgs {maxSize = n} 50import Test.QuickCheck.Test(isSuccess)
51
52qCheck n x = do
53 r <- quickCheckWithResult stdArgs {maxSize = n} x
54 when (not $ isSuccess r) (exitFailure)
49 55
50a ^ b = a Prelude.^ (b :: Int) 56a ^ b = a Prelude.^ (b :: Int)
51 57
@@ -546,7 +552,7 @@ runTests n = do
546 test (\m -> toRows (m::FM) == read (show (toRows m))) 552 test (\m -> toRows (m::FM) == read (show (toRows m)))
547 test (\m -> toRows (m::ZM) == read (show (toRows m))) 553 test (\m -> toRows (m::ZM) == read (show (toRows m)))
548 putStrLn "------ some unit tests" 554 putStrLn "------ some unit tests"
549 _ <- runTestTT $ TestList 555 c <- runTestTT $ TestList
550 [ utest "1E5 rots" rotTest 556 [ utest "1E5 rots" rotTest
551 , utest "det1" detTest1 557 , utest "det1" detTest1
552 , utest "invlndet" detTest2 558 , utest "invlndet" detTest2
@@ -586,6 +592,7 @@ runTests n = do
586 , conformTest 592 , conformTest
587 , accumTest 593 , accumTest
588 ] 594 ]
595 when (errors c + failures c > 0) exitFailure
589 return () 596 return ()
590 597
591 598