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 #-}
module Main where
module Example where
import Control.Monad (unless)
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.

View File

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

View File

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