diff options
author | Alberto Ruiz <aruiz@um.es> | 2011-12-14 13:48:17 +0100 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2011-12-14 13:48:17 +0100 |
commit | e09160be46b10c0e6137ce9b5e1e879e73c88c3a (patch) | |
tree | 1ed4b5c41a73cb36fff4239ba0523aa120a09ca3 | |
parent | 77552d080e88fc70312f55fd3303fac3464ab46e (diff) |
test suite configured for hmatrix-tests
-rw-r--r-- | Setup.lhs | 3 | ||||
-rw-r--r-- | packages/tests/Setup.lhs | 1 | ||||
-rw-r--r-- | packages/tests/hmatrix-tests.cabal | 5 | ||||
-rw-r--r-- | packages/tests/src/Numeric/LinearAlgebra/Tests.hs | 13 |
4 files changed, 15 insertions, 7 deletions
@@ -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 | |||
11 | Category: Math | 11 | Category: Math |
12 | tested-with: GHC==7.0.4 | 12 | tested-with: GHC==7.0.4 |
13 | 13 | ||
14 | cabal-version: >=1.6 | 14 | cabal-version: >=1.8 |
15 | 15 | ||
16 | build-type: Simple | 16 | build-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 | ||
41 | Test-Suite tests | 41 | Test-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 | |||
36 | import Prelude hiding ((^)) | 36 | import Prelude hiding ((^)) |
37 | import qualified Prelude | 37 | import qualified Prelude |
38 | import System.CPUTime | 38 | import System.CPUTime |
39 | import System.Exit | ||
39 | import Text.Printf | 40 | import Text.Printf |
40 | import Data.Packed.Development(unsafeFromForeignPtr,unsafeToForeignPtr) | 41 | import Data.Packed.Development(unsafeFromForeignPtr,unsafeToForeignPtr) |
41 | import Control.Arrow((***)) | 42 | import Control.Arrow((***)) |
42 | import Debug.Trace | 43 | import Debug.Trace |
44 | import Control.Monad(when) | ||
43 | 45 | ||
44 | import Test.QuickCheck(Arbitrary,arbitrary,coarbitrary,choose,vector | 46 | import 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 | ||
48 | qCheck n = quickCheckWith stdArgs {maxSize = n} | 50 | import Test.QuickCheck.Test(isSuccess) |
51 | |||
52 | qCheck n x = do | ||
53 | r <- quickCheckWithResult stdArgs {maxSize = n} x | ||
54 | when (not $ isSuccess r) (exitFailure) | ||
49 | 55 | ||
50 | a ^ b = a Prelude.^ (b :: Int) | 56 | a ^ 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 | ||