gnu: abseil-cpp: Patch sterror_test.
[jackhill/guix/guix.git] / gnu / packages / patches / ghc-microlens-aeson-fix-tests.patch
1 This patch fixes the test suite to allow any order when listing the
2 members of a JSON object. Aeson (being true to the JSON specification)
3 does not specify an order for objects. In practice, the order depends
4 on your processor architecture.
5
6 See <https://github.com/bos/aeson/issues/568> for a discussion resulting
7 in a similar patch fixing the Aeson tests.
8
9 See <https://github.com/fosskers/microlens-aeson/issues/1> for the
10 upstream bug report.
11
12 diff -ruN a/test/Test.hs b/test/Test.hs
13 --- a/test/Test.hs 2018-12-31 15:10:50.000000000 -0500
14 +++ b/test/Test.hs 2019-11-08 01:34:07.419706831 -0500
15 @@ -48,8 +48,10 @@
16 , testCase "" $ ("{\"a\": {}, \"b\": null}" ^? key (T.pack "b") . _Object) @?= Nothing
17 , testCase "" $ ("{\"a\": 100, \"b\": 200}" ^? key (T.pack "a")) @?= Just (Number 100.0)
18 , testCase "" $ ("[1,2,3]" ^? key (T.pack "a")) @?= Nothing
19 - , testCase "" $ ("{\"a\": 4, \"b\": 7}" ^.. members) @?= [Number 4.0,Number 7.0]
20 - , testCase "" $ ("{\"a\": 4, \"b\": 7}" & members . _Number %~ (* 10)) @?= "{\"a\":40,\"b\":70}"
21 + , testCase "" $ assertBool "" (let x = ("{\"a\": 4, \"b\": 7}" ^.. members)
22 + in x == [Number 4.0,Number 7.0] || x == [Number 7.0,Number 4.0])
23 + , testCase "" $ assertBool "" (let x = ("{\"a\": 4, \"b\": 7}" & members . _Number %~ (* 10))
24 + in x == "{\"a\":40,\"b\":70}" || x == "{\"b\":70,\"a\":40}")
25 , testCase "" $ ("[1,2,3]" ^? nth 1) @?= Just (Number 2.0)
26 , testCase "" $ ("{\"a\": 100, \"b\": 200}" ^? nth 1) @?= Nothing
27 , testCase "" $ ("[1,2,3]" & nth 1 .~ Number 20) @?= "[1,20,3]"