Commits

basvandijk  committed 4e94672

Added tests/Options.hs

  • Participants
  • Parent commits ff433c1

Comments (0)

Files changed (2)

File tests/Options.hs

+module Options where
+
+import Data.Aeson.Types
+import Data.Char
+
+optsDefault :: Options
+optsDefault = defaultOptions{ fieldNameModifier       = map toLower
+                             , constructorNameModifier = map toLower
+                             }
+
+opts2ElemArray :: Options
+opts2ElemArray = optsDefault{ nullaryToString = False }
+
+optsObjectWithType :: Options
+optsObjectWithType = optsDefault
+                     { nullaryToString = False
+                     , sumEncoding     = defaultObjectWithType
+                     }
+
+optsObjectWithSingleField :: Options
+optsObjectWithSingleField = optsDefault
+                            { nullaryToString = False
+                            , sumEncoding     = ObjectWithSingleField
+                            }

File tests/Properties.hs

     arbitrary = elements [C1, C2, C3]
 
 thNullaryToJSONString :: Nullary -> Value
-thNullaryToJSONString = $(mkToJSON defaultOptions ''Nullary)
+thNullaryToJSONString = $(mkToJSON optsDefault ''Nullary)
 
 thNullaryParseJSONString :: Value -> Parser Nullary
-thNullaryParseJSONString = $(mkParseJSON defaultOptions ''Nullary)
+thNullaryParseJSONString = $(mkParseJSON optsDefault ''Nullary)
 
 
 thNullaryToJSON2ElemArray :: Nullary -> Value
 deriving instance Generic Nullary
 
 gNullaryToJSONString :: Nullary -> Value
-gNullaryToJSONString = gToJSON defaultOptions . from
+gNullaryToJSONString = gToJSON optsDefault . from
 
 gNullaryParseJSONString :: Value -> Parser Nullary
-gNullaryParseJSONString = fmap to . gParseJSON defaultOptions
+gNullaryParseJSONString = fmap to . gParseJSON optsDefault
 
 
 gNullaryToJSON2ElemArray :: Nullary -> Value