basvandijk avatar basvandijk committed 8fa812d

Fix test-suite to use the new encoding Options terminology

Comments (0)

Files changed (3)

tests/Encoders.hs

 thNullaryParseJSON2ElemArray = $(mkParseJSON opts2ElemArray ''Nullary)
 
 
-thNullaryToJSONObjectWithType :: Nullary -> Value
-thNullaryToJSONObjectWithType = $(mkToJSON optsObjectWithType ''Nullary)
+thNullaryToJSONTaggedObject :: Nullary -> Value
+thNullaryToJSONTaggedObject = $(mkToJSON optsTaggedObject ''Nullary)
 
-thNullaryParseJSONObjectWithType :: Value -> Parser Nullary
-thNullaryParseJSONObjectWithType = $(mkParseJSON optsObjectWithType ''Nullary)
+thNullaryParseJSONTaggedObject :: Value -> Parser Nullary
+thNullaryParseJSONTaggedObject = $(mkParseJSON optsTaggedObject ''Nullary)
 
 
 thNullaryToJSONObjectWithSingleField :: Nullary -> Value
 gNullaryParseJSON2ElemArray = genericParseJSON opts2ElemArray
 
 
-gNullaryToJSONObjectWithType :: Nullary -> Value
-gNullaryToJSONObjectWithType = genericToJSON optsObjectWithType
+gNullaryToJSONTaggedObject :: Nullary -> Value
+gNullaryToJSONTaggedObject = genericToJSON optsTaggedObject
 
-gNullaryParseJSONObjectWithType :: Value -> Parser Nullary
-gNullaryParseJSONObjectWithType = genericParseJSON optsObjectWithType
+gNullaryParseJSONTaggedObject :: Value -> Parser Nullary
+gNullaryParseJSONTaggedObject = genericParseJSON optsTaggedObject
 
 
 gNullaryToJSONObjectWithSingleField :: Nullary -> Value
 thSomeTypeParseJSON2ElemArray = $(mkParseJSON opts2ElemArray ''SomeType)
 
 
-thSomeTypeToJSONObjectWithType :: ToJSON a => SomeType a -> Value
-thSomeTypeToJSONObjectWithType = $(mkToJSON optsObjectWithType ''SomeType)
+thSomeTypeToJSONTaggedObject :: ToJSON a => SomeType a -> Value
+thSomeTypeToJSONTaggedObject = $(mkToJSON optsTaggedObject ''SomeType)
 
-thSomeTypeParseJSONObjectWithType :: FromJSON a => Value -> Parser (SomeType a)
-thSomeTypeParseJSONObjectWithType = $(mkParseJSON optsObjectWithType ''SomeType)
+thSomeTypeParseJSONTaggedObject :: FromJSON a => Value -> Parser (SomeType a)
+thSomeTypeParseJSONTaggedObject = $(mkParseJSON optsTaggedObject ''SomeType)
 
 
 thSomeTypeToJSONObjectWithSingleField :: ToJSON a => SomeType a -> Value
 gSomeTypeParseJSON2ElemArray = genericParseJSON opts2ElemArray
 
 
-gSomeTypeToJSONObjectWithType :: ToJSON a => SomeType a -> Value
-gSomeTypeToJSONObjectWithType = genericToJSON optsObjectWithType
+gSomeTypeToJSONTaggedObject :: ToJSON a => SomeType a -> Value
+gSomeTypeToJSONTaggedObject = genericToJSON optsTaggedObject
 
-gSomeTypeParseJSONObjectWithType :: FromJSON a => Value -> Parser (SomeType a)
-gSomeTypeParseJSONObjectWithType = genericParseJSON optsObjectWithType
+gSomeTypeParseJSONTaggedObject :: FromJSON a => Value -> Parser (SomeType a)
+gSomeTypeParseJSONTaggedObject = genericParseJSON optsTaggedObject
 
 
 gSomeTypeToJSONObjectWithSingleField :: ToJSON a => SomeType a -> Value
 
 optsDefault :: Options
 optsDefault = defaultOptions
-              { fieldNameModifier       = map toLower
-              , constructorNameModifier = map toLower
+              { fieldLabelModifier     = map toLower
+              , constructorTagModifier = map toLower
               }
 
 opts2ElemArray :: Options
 opts2ElemArray = optsDefault
-                 { nullaryToString = False
+                 { allNullaryToStringTag = False
                  , sumEncoding     = TwoElemArray
                  }
 
-optsObjectWithType :: Options
-optsObjectWithType = optsDefault
-                     { nullaryToString = False }
+optsTaggedObject :: Options
+optsTaggedObject = optsDefault
+                   { allNullaryToStringTag = False }
 
 optsObjectWithSingleField :: Options
 optsObjectWithSingleField = optsDefault
-                            { nullaryToString = False
-                            , sumEncoding     = ObjectWithSingleField
+                            { allNullaryToStringTag = False
+                            , sumEncoding           = ObjectWithSingleField
                             }

tests/Properties.hs

 is2ElemArray (Array v) = V.length v == 2 && isString (V.head v)
 is2ElemArray _         = False
 
-isObjectWithTypeValue :: Value -> Bool
-isObjectWithTypeValue (Object obj) = "type"  `H.member` obj &&
-                                     "value" `H.member` obj
-isObjectWithTypeValue _            = False
+isTaggedObjectValue :: Value -> Bool
+isTaggedObjectValue (Object obj) = "tag"      `H.member` obj &&
+                                   "contents" `H.member` obj
+isTaggedObjectValue _            = False
 
-isObjectWithType :: Value -> Bool
-isObjectWithType (Object obj) = "type" `H.member` obj
-isObjectWithType _            = False
+isTaggedObject :: Value -> Bool
+isTaggedObject (Object obj) = "tag" `H.member` obj
+isTaggedObject _            = False
 
 isObjectWithSingleField :: Value -> Bool
 isObjectWithSingleField (Object obj) = H.size obj == 1
       testGroup "Nullary" [
           testProperty "string"                (isString                . thNullaryToJSONString)
         , testProperty "2ElemArray"            (is2ElemArray            . thNullaryToJSON2ElemArray)
-        , testProperty "ObjectWithType"        (isObjectWithTypeValue   . thNullaryToJSONObjectWithType)
+        , testProperty "TaggedObject"          (isTaggedObjectValue     . thNullaryToJSONTaggedObject)
         , testProperty "ObjectWithSingleField" (isObjectWithSingleField . thNullaryToJSONObjectWithSingleField)
 
         , testGroup "roundTrip" [
               testProperty "string"                (toParseJSON thNullaryParseJSONString                thNullaryToJSONString)
             , testProperty "2ElemArray"            (toParseJSON thNullaryParseJSON2ElemArray            thNullaryToJSON2ElemArray)
-            , testProperty "ObjectWithType"        (toParseJSON thNullaryParseJSONObjectWithType        thNullaryToJSONObjectWithType)
+            , testProperty "TaggedObject"          (toParseJSON thNullaryParseJSONTaggedObject          thNullaryToJSONTaggedObject)
             , testProperty "ObjectWithSingleField" (toParseJSON thNullaryParseJSONObjectWithSingleField thNullaryToJSONObjectWithSingleField)
           ]
         ]
     , testGroup "SomeType" [
           testProperty "2ElemArray"            (is2ElemArray            . (thSomeTypeToJSON2ElemArray            :: SomeTypeToJSON))
-        , testProperty "ObjectWithType"        (isObjectWithType        . (thSomeTypeToJSONObjectWithType        :: SomeTypeToJSON))
+        , testProperty "TaggedObject"          (isTaggedObject          . (thSomeTypeToJSONTaggedObject          :: SomeTypeToJSON))
         , testProperty "ObjectWithSingleField" (isObjectWithSingleField . (thSomeTypeToJSONObjectWithSingleField :: SomeTypeToJSON))
 
         , testGroup "roundTrip" [
               testProperty "2ElemArray"            (toParseJSON thSomeTypeParseJSON2ElemArray            (thSomeTypeToJSON2ElemArray            :: SomeTypeToJSON))
-            , testProperty "ObjectWithType"        (toParseJSON thSomeTypeParseJSONObjectWithType        (thSomeTypeToJSONObjectWithType        :: SomeTypeToJSON))
+            , testProperty "TaggedObject"          (toParseJSON thSomeTypeParseJSONTaggedObject          (thSomeTypeToJSONTaggedObject          :: SomeTypeToJSON))
             , testProperty "ObjectWithSingleField" (toParseJSON thSomeTypeParseJSONObjectWithSingleField (thSomeTypeToJSONObjectWithSingleField :: SomeTypeToJSON))
           ]
       ]
         testGroup "Nullary" [
             testProperty "string"                (isString                . gNullaryToJSONString)
           , testProperty "2ElemArray"            (is2ElemArray            . gNullaryToJSON2ElemArray)
-          , testProperty "ObjectWithType"        (isObjectWithTypeValue   . gNullaryToJSONObjectWithType)
+          , testProperty "TaggedObject"          (isTaggedObjectValue     . gNullaryToJSONTaggedObject)
           , testProperty "ObjectWithSingleField" (isObjectWithSingleField . gNullaryToJSONObjectWithSingleField)
           , testGroup "eq" [
                 testProperty "string"                (\n -> gNullaryToJSONString                n == thNullaryToJSONString                n)
               , testProperty "2ElemArray"            (\n -> gNullaryToJSON2ElemArray            n == thNullaryToJSON2ElemArray            n)
-              , testProperty "ObjectWithType"        (\n -> gNullaryToJSONObjectWithType        n == thNullaryToJSONObjectWithType        n)
+              , testProperty "TaggedObject"          (\n -> gNullaryToJSONTaggedObject          n == thNullaryToJSONTaggedObject          n)
               , testProperty "ObjectWithSingleField" (\n -> gNullaryToJSONObjectWithSingleField n == thNullaryToJSONObjectWithSingleField n)
             ]
           , testGroup "roundTrip" [
               testProperty "string"                (toParseJSON gNullaryParseJSONString                gNullaryToJSONString)
             , testProperty "2ElemArray"            (toParseJSON gNullaryParseJSON2ElemArray            gNullaryToJSON2ElemArray)
-            , testProperty "ObjectWithType"        (toParseJSON gNullaryParseJSONObjectWithType        gNullaryToJSONObjectWithType)
+            , testProperty "TaggedObject"          (toParseJSON gNullaryParseJSONTaggedObject          gNullaryToJSONTaggedObject)
             , testProperty "ObjectWithSingleField" (toParseJSON gNullaryParseJSONObjectWithSingleField gNullaryToJSONObjectWithSingleField)
             ]
           ]
     , testGroup "SomeType" [
           testProperty "2ElemArray"            (is2ElemArray            . (gSomeTypeToJSON2ElemArray            :: SomeTypeToJSON))
-        , testProperty "ObjectWithType"        (isObjectWithType        . (gSomeTypeToJSONObjectWithType        :: SomeTypeToJSON))
+        , testProperty "TaggedObject"          (isTaggedObject          . (gSomeTypeToJSONTaggedObject          :: SomeTypeToJSON))
         , testProperty "ObjectWithSingleField" (isObjectWithSingleField . (gSomeTypeToJSONObjectWithSingleField :: SomeTypeToJSON))
 
         , testGroup "eq" [
               testProperty "2ElemArray"            (\n -> (gSomeTypeToJSON2ElemArray            :: SomeTypeToJSON) n == thSomeTypeToJSON2ElemArray            n)
-            , testProperty "ObjectWithType"        (\n -> (gSomeTypeToJSONObjectWithType        :: SomeTypeToJSON) n == thSomeTypeToJSONObjectWithType        n)
+            , testProperty "TaggedObject"          (\n -> (gSomeTypeToJSONTaggedObject          :: SomeTypeToJSON) n == thSomeTypeToJSONTaggedObject          n)
             , testProperty "ObjectWithSingleField" (\n -> (gSomeTypeToJSONObjectWithSingleField :: SomeTypeToJSON) n == thSomeTypeToJSONObjectWithSingleField n)
           ]
         , testGroup "roundTrip" [
             testProperty "2ElemArray"            (toParseJSON gSomeTypeParseJSON2ElemArray            (gSomeTypeToJSON2ElemArray            :: SomeTypeToJSON))
-          , testProperty "ObjectWithType"        (toParseJSON gSomeTypeParseJSONObjectWithType        (gSomeTypeToJSONObjectWithType        :: SomeTypeToJSON))
+          , testProperty "TaggedObject"          (toParseJSON gSomeTypeParseJSONTaggedObject          (gSomeTypeToJSONTaggedObject          :: SomeTypeToJSON))
           , testProperty "ObjectWithSingleField" (toParseJSON gSomeTypeParseJSONObjectWithSingleField (gSomeTypeToJSONObjectWithSingleField :: SomeTypeToJSON))
           ]
       ]
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.