@@ -163,12 +163,18 @@ instance LogItem ExampleCtx where
163163typeAnnotatedTests :: TestTree
164164typeAnnotatedTests = testGroup "TypeAnnotated"
165165 [
166− testCase "annotates values on toJSON" $ do
166+ testCase "annotates values on toJSON" $
167167 toJSON (TypeAnnotated exampleValue) @?= annotatedExampleValue
168− , testCase "deannotates on parseJSON" $ do
168+
169+ , testCase "annotates values on toObject" $
170+ toObject (TypeAnnotated exampleObject) @?= annotatedExampleObject
171+
172+ , testCase "deannotates on parseJSON" $
169173 parseEither parseJSON (toJSON exampleValue) @?= Right exampleValue
174+
170175 , testProperty "roundtrips the same as raw" $ \(v :: Value) ->
171− let res = typeAnnotatedValue <$> (parseEither parseJSON (toJSON (TypeAnnotated v)))
176+ let res = typeAnnotatedValue
177+ <$> parseEither parseJSON (toJSON (TypeAnnotated v))
172178 in res === Right v
173179 ]
174180
@@ -187,33 +193,41 @@ roundToSundayTests = testGroup "roundToSunday"
187193 where
188194 getDOW = view _3 . toWeekDate
189195
196+
197+-------------------------------------------------------------------------------
198+exampleObject :: Object
199+exampleObject = HM.fromList
200+ [ ("a bool", Bool False)
201+ , ("a long", Number 24)
202+ , ("a double", Number 52.3)
203+ , ("a string", String "s")
204+ , ("a null", Null)
205+ , ("a map", Object (HM.singleton "baz" (Bool True)))
206+ ]
207+
208+
209+-------------------------------------------------------------------------------
210+annotatedExampleObject :: Object
211+annotatedExampleObject = HM.fromList
212+ [ ("a map",Object $ HM.fromList [("baz::b", Bool True)])
213+ , ("a bool::b", Bool False)
214+ , ("a null::n", Null)
215+ , ("a string::s", String "s")
216+ , ("a double::d", Number 52.3)
217+ , ("a long::l", Number 24.0)
218+ ]
219+
220+
190221-------------------------------------------------------------------------------
191222exampleValue :: Value
192−exampleValue = Array $ V.fromList [Null, Object ob]
193− where
194− ob = HM.fromList [ ("a bool", Bool False)
195− , ("a long", Number 24)
196− , ("a double", Number 52.3)
197− , ("a string", String "s")
198− , ("a null", Null)
199− , ("a map", Object (HM.singleton "baz" (Bool True)))
200− ]
223+exampleValue = Array $ V.fromList [Null, Object exampleObject]
201224
202225
203226-------------------------------------------------------------------------------
204227annotatedExampleValue :: Value
205228annotatedExampleValue = Array $ V.fromList
206− [
207− Null
208− , Object $ HM.fromList
209− [
210− ("a map",Object $ HM.fromList [("baz::b", Bool True)])
211− , ("a bool::b", Bool False)
212− , ("a null::n", Null)
213− , ("a string::s", String "s")
214− , ("a double::d", Number 52.3)
215− , ("a long::l", Number 24.0)
216− ]
229+ [ Null
230+ , Object annotatedExampleObject
217231 ]
218232
219233