@@ -163,12 +163,18 @@ instance LogItem ExampleCtx where
163typeAnnotatedTests :: TestTree
163typeAnnotatedTests :: TestTree
164typeAnnotatedTests = testGroup "TypeAnnotated"
164typeAnnotatedTests = testGroup "TypeAnnotated"
166− testCase "annotates values on toJSON" $ do
166+ testCase "annotates values on toJSON" $
167 toJSON (TypeAnnotated exampleValue) @?= annotatedExampleValue
167 toJSON (TypeAnnotated exampleValue) @?= annotatedExampleValue
169+ , testCase "annotates values on toObject" $
170+ toObject (TypeAnnotated exampleObject) @?= annotatedExampleObject
168− , testCase "deannotates on parseJSON" $ do
172+ , testCase "deannotates on parseJSON" $
169 parseEither parseJSON (toJSON exampleValue) @?= Right exampleValue
173 parseEither parseJSON (toJSON exampleValue) @?= Right exampleValue
170 , testProperty "roundtrips the same as raw" $ \(v :: Value) ->
175 , testProperty "roundtrips the same as raw" $ \(v :: Value) ->
176+ let res = typeAnnotatedValue
171− let res = typeAnnotatedValue <$> (parseEither parseJSON (toJSON (TypeAnnotated v)))
177+ <$> parseEither parseJSON (toJSON (TypeAnnotated v))
172 in res === Right v
178 in res === Right v
@@ -187,33 +193,41 @@ roundToSundayTests = testGroup "roundToSunday"
188 getDOW = view _3 . toWeekDate
194 getDOW = view _3 . toWeekDate
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")
205+ , ("a map", Object (HM.singleton "baz" (Bool True)))
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)
190-------------------------------------------------------------------------------
221-------------------------------------------------------------------------------
191exampleValue :: Value
222exampleValue :: Value
192−exampleValue = Array $ V.fromList [Null, Object ob]
223+exampleValue = Array $ V.fromList [Null, Object exampleObject]
194− ob = HM.fromList [ ("a bool", Bool False)
195− , ("a long", Number 24)
196− , ("a double", Number 52.3)
197− , ("a string", String "s")
199− , ("a map", Object (HM.singleton "baz" (Bool True)))
203-------------------------------------------------------------------------------
226-------------------------------------------------------------------------------
204annotatedExampleValue :: Value
227annotatedExampleValue :: Value
205annotatedExampleValue = Array $ V.fromList
228annotatedExampleValue = Array $ V.fromList
208− , Object $ HM.fromList
230+ , Object annotatedExampleObject
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)