diff --git a/src/M.hs b/src/M.hs index 99e9a06..3c817e8 100644 --- a/src/M.hs +++ b/src/M.hs @@ -1,2 +1,9 @@ module M where +add :: + Int + -> Int + -> Int +add = + (+) + diff --git a/test/.ghci b/test/.ghci new file mode 100644 index 0000000..7dddf76 --- /dev/null +++ b/test/.ghci @@ -0,0 +1,6 @@ +:set -i../src -isrc +:m + Test.QuickCheck +:l Main +:set prompt "test>> " +:set -Wall + diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 0000000..e4a098b --- /dev/null +++ b/test/.gitignore @@ -0,0 +1,3 @@ +dist +*.pix +.hpc diff --git a/test/Package-Test.cabal b/test/Package-Test.cabal new file mode 100644 index 0000000..9d96b0b --- /dev/null +++ b/test/Package-Test.cabal @@ -0,0 +1,39 @@ +Name: Haskell-Package-Test +Version: 0.0.1 +Author: Tony Morris <ʇǝu˙sıɹɹoɯʇ@ןןǝʞsɐɥ> +Maintainer: Tony Morris +Copyright: Tony Morris +Synopsis: A skeleton for testing haskell packages +Category: Development +Description: A skeleton for testing haskell packages +Homepage: https://github.com/tonymorris/haskell-package +Cabal-Version: >= 1.6 +Build-Type: Simple + +Source-Repository head + Type: git + Location: git@github.com:tonymorris/haskell-package.git + +Flag small_base + Description: Choose the new, split-up base package. + +Executable package-test + Hs-Source-Dirs: + ../src src + + Main-Is: + Main.hs + + Ghc-Options: + -O2 + -Wall + -fhpc + -fwarn-tabs + + Build-Depends: + base < 5 && >= 3 + , QuickCheck + , test-framework + , test-framework-quickcheck2 + , test-framework-hunit + diff --git a/test/package-test.tix b/test/package-test.tix new file mode 100644 index 0000000..1bfa9da --- /dev/null +++ b/test/package-test.tix @@ -0,0 +1 @@ +Tix [ TixModule "Main" 2831685652 9 [1,1,1,1,1,1,1,1,1], TixModule "M.Tests" 2707333672 17 [100,1,100,100,100,100,1,1,1,1,1,1,1,0,0,0,0], TixModule "M" 1390508605 2 [100,100]] diff --git a/test/src/M/Tests.hs b/test/src/M/Tests.hs new file mode 100644 index 0000000..3d4f3ae --- /dev/null +++ b/test/src/M/Tests.hs @@ -0,0 +1,29 @@ +module M.Tests + ( + main + , test + ) where + +import Test.Framework +import Test.Framework.Providers.QuickCheck2 (testProperty) +import M + +main :: + IO () +main = + defaultMain [test] + +test :: + Test +test = + testGroup "M" + [ + testProperty "Right Identity" prop_right_identity + ] + +prop_right_identity :: + Int + -> Bool +prop_right_identity n = + n `add` 0 == n + diff --git a/test/src/Main.hs b/test/src/Main.hs new file mode 100644 index 0000000..942fda8 --- /dev/null +++ b/test/src/Main.hs @@ -0,0 +1,20 @@ +module Main where + +import qualified M.Tests +import Test.Framework + +main :: + IO () +main = + defaultMain tests + +tests :: + [Test] +tests = + [ + testGroup "Tests" + [ + M.Tests.test + ] + ] +