From 56b6707befc933508c95911ed0da58f7113f0e68 Mon Sep 17 00:00:00 2001 From: Ricardo Henrique Gracini Guiraldelli Date: Tue, 12 Jul 2016 07:26:55 +0200 Subject: [PATCH] - reorganization of tests; - inclusion of first property tests. --- billy.cabal | 7 +++-- stack.yaml | 2 +- tests/Billy/Test/Property.hs | 30 +++++++++++++++++++ .../{unit-test.hs => Billy/Test/UnitTest.hs} | 9 ++---- tests/tests.hs | 11 +++++++ 5 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 tests/Billy/Test/Property.hs rename tests/{unit-test.hs => Billy/Test/UnitTest.hs} (97%) create mode 100644 tests/tests.hs diff --git a/billy.cabal b/billy.cabal index 3848068..3bd2b21 100644 --- a/billy.cabal +++ b/billy.cabal @@ -24,14 +24,15 @@ library , text >= 1.2.1 , time >= 1.5 -test-suite unit-test +test-suite tests hs-source-dirs: tests default-language: Haskell2010 type: exitcode-stdio-1.0 - main-is: unit-test.hs + main-is: tests.hs build-depends: base >= 4.7 && < 5 , billy , tasty >= 0.10 - , tasty-smallcheck >= 0.3 , tasty-hunit >= 0.9 + , tasty-quickcheck >= 0.8 + , quickcheck-instances >= 0.3 , time >= 1.5 diff --git a/stack.yaml b/stack.yaml index a5c34f0..b7d03be 100644 --- a/stack.yaml +++ b/stack.yaml @@ -1,7 +1,7 @@ # For more information, see: https://github.com/commercialhaskell/stack/blob/master/doc/yaml_configuration.md # Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2) -resolver: lts-3.7 +resolver: lts-6.7 # Local packages, usually specified by relative directory name packages: diff --git a/tests/Billy/Test/Property.hs b/tests/Billy/Test/Property.hs new file mode 100644 index 0000000..b707bde --- /dev/null +++ b/tests/Billy/Test/Property.hs @@ -0,0 +1,30 @@ +module Billy.Test.Property where + +import qualified Billy.Bill as B +import qualified Billy.Interval as I +import qualified Billy.Payer as P +import qualified Billy.Split as S +import qualified Data.Time.Calendar as D +import Test.QuickCheck.Instances as QCI +import Test.Tasty +import Test.Tasty.QuickCheck as QC + +propertiesTest :: TestTree +propertiesTest = testGroup "Properties Test" [intervalProperties] + +intervalProperties :: TestTree +intervalProperties = testGroup "Properties Test for Billy.Interval" + [ testProperty "Interval always start with smaller date" $ + \d1 d2 -> let interval = I.new d1 d2 in + if d1 < d2 + then [d1, d2] == I.toEndpoints interval + else [d2, d1] == I.toEndpoints interval + , testProperty "Interval is Closed by default" $ + \d1 d2 -> let interval = I.new d1 d2 in + d1 `I.belongsTo` interval + && d2 `I.belongsTo` interval + , testProperty "In Open Interval, border-dates are not in it" $ + \d1 d2 -> let interval = I.open $ I.new d1 d2 in + not (d1 `I.belongsTo` interval) + && not (d2 `I.belongsTo` interval) + ] diff --git a/tests/unit-test.hs b/tests/Billy/Test/UnitTest.hs similarity index 97% rename from tests/unit-test.hs rename to tests/Billy/Test/UnitTest.hs index 0221eaf..5f7ef83 100644 --- a/tests/unit-test.hs +++ b/tests/Billy/Test/UnitTest.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} -module Main where +module Billy.Test.UnitTest where import qualified Billy.Bill as B import qualified Billy.Interval as I @@ -10,11 +10,8 @@ import qualified Data.Time.Calendar as D import Test.Tasty import Test.Tasty.HUnit -main :: IO () -main = defaultMain tests - -tests :: TestTree -tests = testGroup "Tests" [intervalUnitTests, splitUnitTests] +unitTests :: TestTree +unitTests = testGroup "Unit Tests" [intervalUnitTests, splitUnitTests] intervalUnitTests :: TestTree intervalUnitTests = testGroup "Unit Tests for Billy.Interval" diff --git a/tests/tests.hs b/tests/tests.hs new file mode 100644 index 0000000..8dcaa97 --- /dev/null +++ b/tests/tests.hs @@ -0,0 +1,11 @@ +module Main where + +import Billy.Test.Property +import Billy.Test.UnitTest +import Test.Tasty + +main :: IO () +main = defaultMain tests + +tests :: TestTree +tests = testGroup "Tests" [unitTests, propertiesTest]