on master help sign in
Get ready for some unit tests
229cda7Bryan O'Sullivan
aeson.cabal+2−1
@@ -135,12 +135,13 @@ library
135test-suite tests
135test-suite tests
136 type: exitcode-stdio-1.0
136 type: exitcode-stdio-1.0
137 hs-source-dirs: tests
137 hs-source-dirs: tests
138− main-is: Properties.hs
138+ main-is: Tests.hs
139 other-modules:
139 other-modules:
140 Encoders
140 Encoders
141 Functions
141 Functions
142 Instances
142 Instances
143 Options
143 Options
144+ Properties
144 Properties.ZonedTime
145 Properties.ZonedTime
145 Types
146 Types
146
147
tests/Properties.hs+2−5
@@ -1,5 +1,7 @@
1{-# LANGUAGE OverloadedStrings, RecordWildCards, ScopedTypeVariables #-}
1{-# LANGUAGE OverloadedStrings, RecordWildCards, ScopedTypeVariables #-}
2
2
3+module Properties (encoderComparisonTests, tests) where
4+
3import Control.Monad (forM)
5import Control.Monad (forM)
4import Data.Aeson (eitherDecode)
6import Data.Aeson (eitherDecode)
5import Data.Aeson.Encode
7import Data.Aeson.Encode
@@ -90,11 +92,6 @@ sameAsV :: (a -> Value) -> (a -> Encoding) -> a -> Property
90sameAsV toVal toEnc v =
92sameAsV toVal toEnc v =
91 eitherDecode (toLazyByteString (fromEncoding (toEnc v))) === Right (toVal v)
93 eitherDecode (toLazyByteString (fromEncoding (toEnc v))) === Right (toVal v)
92
94
93−main :: IO ()
94−main = do
95− comparisonTest <- encoderComparisonTests
96− defaultMain (comparisonTest : tests)
97−
98type P6 = Product6 Int Bool String (Approx Double) (Int, Approx Double) ()
95type P6 = Product6 Int Bool String (Approx Double) (Int, Approx Double) ()
99type S4 = Sum4 Int8 ZonedTime T.Text (Map.Map String Int)
96type S4 = Sum4 Int8 ZonedTime T.Text (Map.Map String Int)
100
97
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)