on master help sign in
Get ready for some unit tests
commit229cda79e2a053d4641792c92d1f13e38972a586 authorBryan O'Sullivan <bos@serpentine.com> dateThu 9 Jul 2015, 16:32 (11 years ago) parent7ea614a
3 files changed+13−6
aeson.cabal+2−1 tests/Properties.hs+2−5 tests/Tests.hs+9
aeson.cabal+2−1
@@ -135,12 +135,13 @@ library
135135test-suite tests
136136 type: exitcode-stdio-1.0
137137 hs-source-dirs: tests
138− main-is: Properties.hs
138+ main-is: Tests.hs
139139 other-modules:
140140 Encoders
141141 Functions
142142 Instances
143143 Options
144+ Properties
144145 Properties.ZonedTime
145146 Types
146147
tests/Properties.hs+2−5
@@ -1,5 +1,7 @@
11{-# LANGUAGE OverloadedStrings, RecordWildCards, ScopedTypeVariables #-}
22
3+module Properties (encoderComparisonTests, tests) where
4+
35import Control.Monad (forM)
46import Data.Aeson (eitherDecode)
57import Data.Aeson.Encode
@@ -90,11 +92,6 @@ sameAsV :: (a -> Value) -> (a -> Encoding) -> a -> Property
9092sameAsV toVal toEnc v =
9193 eitherDecode (toLazyByteString (fromEncoding (toEnc v))) === Right (toVal v)
9294
93−main :: IO ()
94−main = do
95− comparisonTest <- encoderComparisonTests
96− defaultMain (comparisonTest : tests)
97−
9895type P6 = Product6 Int Bool String (Approx Double) (Int, Approx Double) ()
9996type S4 = Sum4 Int8 ZonedTime T.Text (Map.Map String Int)
10097
tests/Tests.hsnew file+9
@@ -0,0 +1,9 @@
1+module Main (main) where
2+
3+import Test.Framework (defaultMain)
4+import qualified Properties
5+
6+main :: IO ()
7+main = do
8+ comparisonTests <- Properties.encoderComparisonTests
9+ defaultMain (comparisonTests : Properties.tests)