git.iko.soy/typeable/hjsonpointer
on master help sign in
1.0.0.1: Remove HUnit dep.
4cf8c6fIan Grant Jeffries
MIT-LICENSE.txt+1−1
@@ -1,5 +1,5 @@
1The MIT License (MIT)
1The MIT License (MIT)
2−Copyright (c) 2015 Ian Grant Jeffries
2+Copyright (c) 2016 Ian Grant Jeffries
3
3
4Permission is hereby granted, free of charge, to any person obtaining a copy
4Permission is hereby granted, free of charge, to any person obtaining a copy
5of this software and associated documentation files (the "Software"), to deal
5of this software and associated documentation files (the "Software"), to deal
changelog.md+4
@@ -1,3 +1,7 @@
1+# 1.0.0.1
2+
3++ Remove HUnit dep.
4+
1# 1.0.0.0
5# 1.0.0.0
2
6
3+ Bump aeson.
7+ Bump aeson.
hjsonpointer.cabal+3−5
@@ -1,5 +1,5 @@
1name: hjsonpointer
1name: hjsonpointer
2−version: 1.0.0.0
2+version: 1.0.0.1
3synopsis: JSON Pointer library
3synopsis: JSON Pointer library
4homepage: https://github.com/seagreen/hjsonpointer
4homepage: https://github.com/seagreen/hjsonpointer
5license: MIT
5license: MIT
@@ -9,7 +9,6 @@ maintainer: ian@housejeffries.com
9category: Data
9category: Data
10build-type: Simple
10build-type: Simple
11cabal-version: >=1.10
11cabal-version: >=1.10
12−tested-with: GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.1
13extra-source-files:
12extra-source-files:
14 changelog.md
13 changelog.md
15 README.md
14 README.md
@@ -38,13 +37,13 @@ test-suite unit
38 hs-source-dirs:
37 hs-source-dirs:
39 test
38 test
40 ./
39 ./
40+ main-is: Unit.hs
41 default-language: Haskell2010
41 default-language: Haskell2010
42+ type: exitcode-stdio-1.0
42 default-extensions:
43 default-extensions:
43 OverloadedStrings
44 OverloadedStrings
44 ghc-options:
45 ghc-options:
45 -Wall
46 -Wall
46− type: exitcode-stdio-1.0
47− main-is: Unit.hs
48 other-modules: Example
47 other-modules: Example
49 build-depends:
48 build-depends:
50 aeson
49 aeson
@@ -56,7 +55,6 @@ test-suite unit
56 , vector
55 , vector
57 , hspec >= 2.2 && < 2.3
56 , hspec >= 2.2 && < 2.3
58 , http-types >= 0.8 && < 0.10
57 , http-types >= 0.8 && < 0.10
59− , HUnit >= 1.2 && < 1.4
60
58
61source-repository head
59source-repository head
62 type: git
60 type: git
test/Unit.hs+11−16
@@ -3,17 +3,15 @@ module Main where
3
3
4import Control.Arrow
4import Control.Arrow
5import Data.Aeson
5import Data.Aeson
6−import qualified Data.Aeson.Pointer as P
6+import qualified Data.Aeson.Pointer as P
7−import Data.Text (Text)
7+import Data.Text (Text)
8−import qualified Data.Text as T
8+import qualified Data.Text as T
9import Data.Text.Encoding
9import Data.Text.Encoding
10−import qualified Data.Vector as V
10+import qualified Data.Vector as V
11−import Network.HTTP.Types.URI (urlDecode)
11+import Network.HTTP.Types.URI (urlDecode)
12
12
13import Test.Hspec
13import Test.Hspec
14−import Test.QuickCheck (property)
14+import Test.QuickCheck (property)
15−
16−import Test.HUnit hiding (Test)
17
15
18-- For GHCs before 7.10:
16-- For GHCs before 7.10:
19import Control.Applicative
17import Control.Applicative
@@ -34,7 +32,7 @@ main = hspec $ do
34roundtrip :: P.Pointer -> Bool
32roundtrip :: P.Pointer -> Bool
35roundtrip a = Just a == decode (encode a)
33roundtrip a = Just a == decode (encode a)
36
34
37−jsonString :: Assertion
35+jsonString :: Expectation
38jsonString = traverse_ resolvesTo
36jsonString = traverse_ resolvesTo
39 [ ("" , specExample)
37 [ ("" , specExample)
40 , ("/foo" , Array $ V.fromList ["bar", "baz"])
38 , ("/foo" , Array $ V.fromList ["bar", "baz"])
@@ -50,7 +48,7 @@ jsonString = traverse_ resolvesTo
50 , ("/m~0n" , Number 8)
48 , ("/m~0n" , Number 8)
51 ]
49 ]
52
50
53−uriFragment :: Assertion
51+uriFragment :: Expectation
54uriFragment = traverse_ resolvesTo . fmap (first decodeFragment) $
52uriFragment = traverse_ resolvesTo . fmap (first decodeFragment) $
55 [ ("#" , specExample)
53 [ ("#" , specExample)
56 , ("#/foo" , Array $ V.fromList ["bar", "baz"])
54 , ("#/foo" , Array $ V.fromList ["bar", "baz"])
@@ -69,14 +67,11 @@ uriFragment = traverse_ resolvesTo . fmap (first decodeFragment) $
69 decodeFragment :: Text -> Text
67 decodeFragment :: Text -> Text
70 decodeFragment = T.drop 1 . decodeUtf8 . urlDecode True . encodeUtf8
68 decodeFragment = T.drop 1 . decodeUtf8 . urlDecode True . encodeUtf8
71
69
72−resolvesTo :: (Text, Value) -> Assertion
70+resolvesTo :: (Text, Value) -> Expectation
73resolvesTo (t, expected) =
71resolvesTo (t, expected) =
74 case P.unescape t of
72 case P.unescape t of
75− Left e -> assertFailure (show e <> " error for pointer: " <> show t)
73+ Left e -> expectationFailure (show e <> " error for pointer: " <> show t)
76− Right p -> assertEqual
77− ("Resolved value for pointer: " <> show t)
78− (Right expected)
79− (P.resolve p specExample)
74+ Right p -> P.resolve p specExample `shouldBe` Right expected
80
75
81specExample :: Value
76specExample :: Value
82specExample = object
77specExample = object