From 92621b1d6ea83e0aea10a2fdfdb0c8122ef64c72 Mon Sep 17 00:00:00 2001 From: Ian Grant Jeffries Date: Mon, 11 Jul 2016 10:39:15 -0400 Subject: [PATCH] 0.3.0.2. Switch to hspec for tests. --- Example.hs | 2 +- changelog.md | 10 +++++++++- hjsonpointer.cabal | 25 +++++++++---------------- {tests => test}/Unit.hs | 23 +++++++++++++---------- 4 files changed, 32 insertions(+), 28 deletions(-) rename {tests => test}/Unit.hs (82%) diff --git a/Example.hs b/Example.hs index b606133..466a223 100644 --- a/Example.hs +++ b/Example.hs @@ -1,6 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} -module Main where +module Example where import Control.Monad (unless) import Data.Aeson diff --git a/changelog.md b/changelog.md index f688c21..f2b0524 100644 --- a/changelog.md +++ b/changelog.md @@ -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. diff --git a/hjsonpointer.cabal b/hjsonpointer.cabal index aea161b..77c5658 100644 --- a/hjsonpointer.cabal +++ b/hjsonpointer.cabal @@ -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 diff --git a/tests/Unit.hs b/test/Unit.hs similarity index 82% rename from tests/Unit.hs rename to test/Unit.hs index b0a440e..4ff7fde 100644 --- a/tests/Unit.hs +++ b/test/Unit.hs @@ -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)