File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,7 @@ tests = testGroup "unit" [
99
99
, testCase " Show Options" showOptions
100
100
, testGroup " SingleMaybeField" singleMaybeField
101
101
, testCase " withEmbeddedJSON" withEmbeddedJSONTest
102
+ , testCase " SingleFieldCon" singleFieldCon
102
103
]
103
104
104
105
roundTripCamel :: String -> Assertion
@@ -534,6 +535,17 @@ withEmbeddedJSONTest :: Assertion
534
535
withEmbeddedJSONTest =
535
536
assertEqual " Unquote embedded JSON" (Right $ EmbeddedJSONTest 1 ) (eitherDecode " {\" prop\" :\" 1\" }" )
536
537
538
+ -- Regression test for https://github.com/bos/aeson/issues/627
539
+ newtype SingleFieldCon = SingleFieldCon Int deriving (Eq , Show , Generic )
540
+
541
+ instance FromJSON SingleFieldCon where
542
+ parseJSON = genericParseJSON defaultOptions{unwrapUnaryRecords= True }
543
+ -- This option should have no effect on this type
544
+
545
+ singleFieldCon :: Assertion
546
+ singleFieldCon =
547
+ assertEqual " fromJSON" (Right (SingleFieldCon 0 )) (eitherDecode " 0" )
548
+
537
549
deriveJSON defaultOptions{omitNothingFields= True } ''MyRecord
538
550
539
551
deriveToJSON defaultOptions ''Foo
You can’t perform that action at this time.
0 commit comments