0.3.0.2. Switch to hspec for tests.

This commit is contained in:
Ian Grant Jeffries 2016-07-11 10:39:15 -04:00
parent 3389617148
commit 92621b1d6e
4 changed files with 32 additions and 28 deletions

View File

@ -1,6 +1,6 @@
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
module Main where module Example where
import Control.Monad (unless) import Control.Monad (unless)
import Data.Aeson import Data.Aeson

View File

@ -1,4 +1,12 @@
# 0.3 # 0.3.0.2
+ Switch to hspec for tests.
# 0.3.0.1
+ Enable GHC 8.
# 0.3.0.0
+ Rewrite. + Rewrite.

View File

@ -1,5 +1,5 @@
name: hjsonpointer name: hjsonpointer
version: 0.3.0.1 version: 0.3.0.2
synopsis: JSON Pointer library synopsis: JSON Pointer library
homepage: https://github.com/seagreen/hjsonpointer homepage: https://github.com/seagreen/hjsonpointer
license: MIT license: MIT
@ -22,37 +22,30 @@ library
ghc-options: -Wall ghc-options: -Wall
build-depends: aeson >= 0.7 && < 0.12 build-depends: aeson >= 0.7 && < 0.12
, base >= 4.6 && < 4.10 , base >= 4.6 && < 4.10
, QuickCheck >= 2.8 && < 2.9 , QuickCheck >= 2.8 && < 2.10
, unordered-containers >= 0.2 && < 0.3 , unordered-containers >= 0.2 && < 0.3
, text >= 1.2 && < 1.3 , text >= 1.2 && < 1.3
, vector >= 0.10 && < 0.12 , vector >= 0.10 && < 0.12
test-suite unit test-suite unit
type: exitcode-stdio-1.0 type: exitcode-stdio-1.0
hs-source-dirs: tests hs-source-dirs: test
./
main-is: Unit.hs main-is: Unit.hs
other-modules: Example
default-language: Haskell2010 default-language: Haskell2010
ghc-options: -Wall ghc-options: -Wall
default-extensions: OverloadedStrings default-extensions: OverloadedStrings
build-depends: aeson build-depends: aeson
, base , base
, hjsonpointer , hjsonpointer
, QuickCheck
, unordered-containers , unordered-containers
, text , text
, vector , vector
, http-types >= 0.8 && < 0.10 , hspec >= 2.2 && < 2.3
, HUnit >= 1.2 && < 1.4 , http-types >= 0.8 && < 0.10
, test-framework >= 0.8 && < 0.9 , HUnit >= 1.2 && < 1.4
, test-framework-hunit >= 0.3 && < 0.4
, test-framework-quickcheck2 >= 0.3 && < 0.4
executable example
main-is: Example.hs
default-language: Haskell2010
ghc-options: -Wall
build-depends: aeson
, base
, hjsonpointer
source-repository head source-repository head
type: git type: git

View File

@ -9,9 +9,10 @@ import qualified Data.Text as T
import Data.Text.Encoding import Data.Text.Encoding
import qualified Data.Vector as V import qualified Data.Vector as V
import Network.HTTP.Types.URI (urlDecode) import Network.HTTP.Types.URI (urlDecode)
import Test.Framework (defaultMain, testGroup)
import Test.Framework.Providers.HUnit (testCase) import Test.Hspec
import Test.Framework.Providers.QuickCheck2 (testProperty) import Test.QuickCheck (property)
import Test.HUnit hiding (Test) import Test.HUnit hiding (Test)
-- For GHCs before 7.10: -- For GHCs before 7.10:
@ -19,14 +20,16 @@ import Control.Applicative
import Data.Foldable import Data.Foldable
import Data.Monoid import Data.Monoid
import qualified Example
main :: IO () main :: IO ()
main = defaultMain main = hspec $ do
[ testGroup "unit" describe "example" $ do
[ testProperty "Storing a Pointer as JSON doesn't change its value" roundtrip it "compiles and runs without errors" Example.main
, testCase "Can be represented in a JSON string value" jsonString describe "pointers" $ do
, testCase "Can be represented in a URI fragment identifier" uriFragment it "can be stored as JSON without changing its value" (property roundtrip)
] it "can be represented in a JSON string value" jsonString
] it "can be represented in a URI fragment identifier" uriFragment
roundtrip :: P.Pointer -> Bool roundtrip :: P.Pointer -> Bool
roundtrip a = Just a == decode (encode a) roundtrip a = Just a == decode (encode a)