@@ -13,6 +13,7 @@ import Control.Applicative (Const)
1313import Data.Aeson (eitherDecode, encode)
1414import Data.Aeson.Encoding (encodingToLazyByteString)
1515import Data.Aeson.Internal (IResult(..), formatError, ifromJSON, iparse)
16+import qualified Data.Aeson.Internal as I
1617import Data.Aeson.Parser (value)
1718import Data.Aeson.Types
1819import Data.DList (DList)
@@ -121,14 +122,20 @@ parserThrowErrorProp msg =
121122 result :: Result ()
122123 result = parse parser ()
123124
124−parserCatchErrorProp :: String -> Property
125−parserCatchErrorProp msg =
126− result === Success msg
125+-- | Tests (also) that we catch the JSONPath and it has elements in the right order.
126+parserCatchErrorProp :: [String] -> String -> Property
127+parserCatchErrorProp path msg =
128+ result === Success ([I.Key "outer", I.Key "inner"] ++ jsonPath, msg)
127129 where
128− -- Fail, catch, use error message as a successful parse
129− parser = const $ parserCatchError (fail msg) (\_ err -> pure err)
130− result :: Result String
131− result = parse parser ()
130+ parser = parserCatchError outer (\p err -> pure (p, err))
131+
132+ outer = inner I.<?> I.Key "outer"
133+ inner = parserThrowError jsonPath msg I.<?> I.Key "inner"
134+
135+ result :: Result (I.JSONPath, String)
136+ result = parse (const parser) ()
137+
138+ jsonPath = map (I.Key . T.pack) path
132139
133140-- | Perform a structural comparison of the results of two encoding
134141-- methods. Compares decoded values to account for HashMap-driven