[commit: ghc] wip/nfs-locking: #146, add a Test module with selftest (28c706d)

git at git.haskell.org git at git.haskell.org
Thu Oct 26 23:49:24 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/nfs-locking
Link       : http://ghc.haskell.org/trac/ghc/changeset/28c706da832e79687af29b9d64289d6a57b53adf/ghc

>---------------------------------------------------------------

commit 28c706da832e79687af29b9d64289d6a57b53adf
Author: Neil Mitchell <ndmitchell at gmail.com>
Date:   Mon Jan 11 10:47:41 2016 +0000

    #146, add a Test module with selftest


>---------------------------------------------------------------

28c706da832e79687af29b9d64289d6a57b53adf
 shaking-up-ghc.cabal |  3 +++
 src/Main.hs          |  4 +++-
 src/Test.hs          | 19 +++++++++++++++++++
 src/Way.hs           |  2 +-
 4 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/shaking-up-ghc.cabal b/shaking-up-ghc.cabal
index a091020..132e84d 100644
--- a/shaking-up-ghc.cabal
+++ b/shaking-up-ghc.cabal
@@ -100,6 +100,7 @@ executable ghc-shake
                        , Settings.Ways
                        , Stage
                        , Target
+                       , Test
                        , Way
 
     default-extensions:  BangPatterns
@@ -111,6 +112,7 @@ executable ghc-shake
                        , FlexibleInstances
                        , OverloadedStrings
                        , RecordWildCards
+                       , ScopedTypeVariables
     build-depends:       base
                        , ansi-terminal >= 0.6
                        , Cabal >= 1.22
@@ -118,6 +120,7 @@ executable ghc-shake
                        , directory >= 1.2
                        , extra >= 1.4
                        , mtl >= 2.2
+                       , QuickCheck >= 2.6
                        , shake >= 0.15
                        , transformers >= 0.4
                        , unordered-containers >= 0.2
diff --git a/src/Main.hs b/src/Main.hs
index 63dbd7c..dea793e 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -11,6 +11,7 @@ import qualified Rules.Gmp
 import qualified Rules.Libffi
 import qualified Rules.Oracles
 import qualified Rules.Perl
+import qualified Test
 
 main :: IO ()
 main = shakeArgs options rules
@@ -25,7 +26,8 @@ main = shakeArgs options rules
         , Rules.Gmp.gmpRules
         , Rules.Libffi.libffiRules
         , Rules.Oracles.oracleRules
-        , Rules.packageRules ]
+        , Rules.packageRules
+        , Test.testRules ]
     options = shakeOptions
         { shakeFiles    = Base.shakeFilesPath
         , shakeProgress = progressSimple
diff --git a/src/Test.hs b/src/Test.hs
new file mode 100644
index 0000000..75b1b5d
--- /dev/null
+++ b/src/Test.hs
@@ -0,0 +1,19 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+
+module Test (testRules) where
+
+import Way
+import Development.Shake
+import Test.QuickCheck
+
+instance Arbitrary Way where
+    arbitrary = wayFromUnits <$> arbitrary
+
+instance Arbitrary WayUnit where
+    arbitrary = arbitraryBoundedEnum
+
+testRules :: Rules ()
+testRules =
+    phony "selftest" $ do
+        liftIO $ quickCheck $ \(x :: Way) -> read (show x) == x
diff --git a/src/Way.hs b/src/Way.hs
index 3b1f6c0..ba20bd7 100644
--- a/src/Way.hs
+++ b/src/Way.hs
@@ -1,5 +1,5 @@
 module Way (
-    WayUnit (..), Way, wayUnit,
+    WayUnit (..), Way, wayUnit, wayFromUnits,
 
     vanilla, profiling, logging, parallel, granSim,
     threaded, threadedProfiling, threadedLogging,



More information about the ghc-commits mailing list