From: Michael Orlitzky Date: Tue, 4 Jun 2013 15:16:19 +0000 (-0400) Subject: Bump dependencies, and move some Arbitrary code from Values.hs to Grid.hs to avoid... X-Git-Tag: 0.0.1~27 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=fd3d394c27e3a90de8238b98bd112c4fe3468ee0;p=spline3.git Bump dependencies, and move some Arbitrary code from Values.hs to Grid.hs to avoid an instance collision. --- diff --git a/spline3.cabal b/spline3.cabal index 4646863..b0dc602 100644 --- a/spline3.cabal +++ b/spline3.cabal @@ -39,9 +39,9 @@ executable spline3 -- Additional test dependencies. HUnit == 1.2.*, QuickCheck == 2.*, - test-framework == 0.6.*, - test-framework-hunit == 0.2.*, - test-framework-quickcheck2 == 0.2.* + test-framework == 0.8.*, + test-framework-hunit == 0.3.*, + test-framework-quickcheck2 == 0.3.* main-is: Main.hs @@ -92,9 +92,9 @@ test-suite doctests hs-source-dirs: test main-is: Doctests.hs build-depends: - base == 4.5.*, + base == 4.6.*, -- Additional test dependencies. - doctest == 0.7.* + doctest == 0.9.* -- It's not entirely clear to me why I have to reproduce all of this. ghc-options: @@ -121,20 +121,20 @@ test-suite testsuite hs-source-dirs: src test main-is: TestSuite.hs build-depends: - base == 4.5.*, + base == 4.6.*, cmdargs == 0.10.*, filepath == 1.*, - MissingH == 1.1.*, + MissingH == 1.2.*, repa == 3.2.*, repa-algorithms == 3.2.*, repa-io == 3.2.*, - vector == 0.9.*, + vector == 0.10.*, -- Additional test dependencies. HUnit == 1.2.*, QuickCheck == 2.*, - test-framework == 0.6.*, - test-framework-hunit == 0.2.*, - test-framework-quickcheck2 == 0.2.* + test-framework == 0.8.*, + test-framework-hunit == 0.3.*, + test-framework-quickcheck2 == 0.3.* -- It's not entirely clear to me why I have to reproduce all of this. ghc-options: diff --git a/src/Grid.hs b/src/Grid.hs index 953c6a3..269b37c 100644 --- a/src/Grid.hs +++ b/src/Grid.hs @@ -19,7 +19,8 @@ import Test.QuickCheck ((==>), Arbitrary(..), Gen, Property, - choose) + choose, + vectorOf) import Assertions (assertAlmostEqual, assertTrue) import Comparisons ((~=)) import Cube (Cube(Cube), @@ -49,7 +50,12 @@ data Grid = Grid { function_values :: Values3D } instance Arbitrary Grid where arbitrary = do - fvs <- arbitrary :: Gen Values3D + x_dim <- choose (1, 27) + y_dim <- choose (1, 27) + z_dim <- choose (1, 27) + elements <- vectorOf (x_dim * y_dim * z_dim) (arbitrary :: Gen Double) + let new_shape = (R.Z R.:. x_dim R.:. y_dim R.:. z_dim) + let fvs = R.fromListUnboxed new_shape elements return $ Grid fvs diff --git a/src/Values.hs b/src/Values.hs index b5dc15a..7fc5775 100644 --- a/src/Values.hs +++ b/src/Values.hs @@ -23,8 +23,6 @@ import Data.Array.Repa ( ) import System.FilePath () -import Test.QuickCheck (Arbitrary(..), Gen, choose, vectorOf) - import ScaleFactor (ScaleFactor) @@ -34,18 +32,6 @@ type Values2D = Values DIM2 type Values3D = Values DIM3 -instance Arbitrary Values3D where - arbitrary = do - -- I declare not to care about empty lists. - x_dim <- choose (1, 27) - y_dim <- choose (1, 27) - z_dim <- choose (1, 27) - elements <- vectorOf (x_dim * y_dim * z_dim) (arbitrary :: Gen Double) - let new_shape = (Z :. x_dim :. y_dim :. z_dim) - let three_d = Data.Array.Repa.fromListUnboxed new_shape elements - return three_d - - empty3d :: Values3D empty3d = Data.Array.Repa.fromListUnboxed (Z :. 0 :. 0 :. 0) [] diff --git a/test/TestSuite.hs b/test/TestSuite.hs index 4a0b405..bac18ec 100644 --- a/test/TestSuite.hs +++ b/test/TestSuite.hs @@ -40,16 +40,6 @@ main = do defaultMainWithOpts tests my_runner_opts --- | Defined so that my test names fit on one line. -tc :: Test.Framework.Providers.API.TestName -> Test.HUnit.Assertion -> Test.Framework.Test -tc = testCase - - --- | Defined so that my test names fit on one line. -tp :: Test.QuickCheck.Testable a => Test.Framework.TestName -> a -> Test.Framework.Test -tp = testProperty - - tests :: [Test.Framework.Test] tests = [ cardinal_tests, function_values_tests, @@ -58,6 +48,6 @@ tests = [ cardinal_tests, tetrahedron_tests, cube_properties, tetrahedron_properties, - misc_properties, + misc_properties, cardinal_properties, slow_tests ]