@@ -168,11 +168,14 @@ isTaggedObjectValue (Object obj) = "tag" `H.member` obj &&
168isTaggedObjectValue _ = False
168isTaggedObjectValue _ = False
170isNullaryTaggedObject :: Value -> Bool
170isNullaryTaggedObject :: Value -> Bool
171−isNullaryTaggedObject obj = isTaggedObject obj && isObjectWithSingleField obj
171+isNullaryTaggedObject obj = isTaggedObject' obj && isObjectWithSingleField obj
173−isTaggedObject :: Value -> Bool
173+isTaggedObject :: Value -> Property
174+isTaggedObject = checkValue isTaggedObject'
176+isTaggedObject' :: Value -> Bool
174−isTaggedObject (Object obj) = "tag" `H.member` obj
177+isTaggedObject' (Object obj) = "tag" `H.member` obj
175−isTaggedObject _ = False
178+isTaggedObject' _ = False
177isObjectWithSingleField :: Value -> Bool
180isObjectWithSingleField :: Value -> Bool
178isObjectWithSingleField (Object obj) = H.size obj == 1
181isObjectWithSingleField (Object obj) = H.size obj == 1
@@ -338,6 +341,14 @@ tests = testGroup "properties" [
344+ , testGroup "OneConstructor" [
345+ testProperty "default" (isEmptyArray . gOneConstructorToJSONDefault)
346+ , testProperty "Tagged" (isTaggedObject . gOneConstructorToJSONTagged)
347+ , testGroup "roundTrip" [
348+ testProperty "default" (toParseJSON gOneConstructorParseJSONDefault gOneConstructorToJSONDefault)
349+ , testProperty "Tagged" (toParseJSON gOneConstructorParseJSONTagged gOneConstructorToJSONTagged)
342 , testGroup "toEncoding" [
353 , testGroup "toEncoding" [
343 testProperty "NullaryString" $
354 testProperty "NullaryString" $
@@ -386,6 +397,11 @@ tests = testGroup "properties" [
387 , testProperty "SomeTypeOmitNothingFields" $
398 , testProperty "SomeTypeOmitNothingFields" $
388 gSomeTypeToJSONOmitNothingFields `sameAs` gSomeTypeToEncodingOmitNothingFields
399 gSomeTypeToJSONOmitNothingFields `sameAs` gSomeTypeToEncodingOmitNothingFields
401+ , testProperty "OneConstructorDefault" $
402+ gOneConstructorToJSONDefault `sameAs` gOneConstructorToEncodingDefault
403+ , testProperty "OneConstructorTagged" $
404+ gOneConstructorToJSONTagged `sameAs` gOneConstructorToEncodingTagged
391 , testGroup "template-haskell" [
407 , testGroup "template-haskell" [
@@ -440,8 +456,10 @@ tests = testGroup "properties" [
441 , testGroup "OneConstructor" [
457 , testGroup "OneConstructor" [
442 testProperty "default" (isEmptyArray . thOneConstructorToJSONDefault)
458 testProperty "default" (isEmptyArray . thOneConstructorToJSONDefault)
459+ , testProperty "Tagged" (isTaggedObject . thOneConstructorToJSONTagged)
443 , testGroup "roundTrip" [
460 , testGroup "roundTrip" [
444 testProperty "default" (toParseJSON thOneConstructorParseJSONDefault thOneConstructorToJSONDefault)
461 testProperty "default" (toParseJSON thOneConstructorParseJSONDefault thOneConstructorToJSONDefault)
462+ , testProperty "Tagged" (toParseJSON thOneConstructorParseJSONTagged thOneConstructorToJSONTagged)
@@ -484,8 +502,10 @@ tests = testGroup "properties" [
484 , testProperty "SomeTypeObjectWithSingleField unary agree" $
502 , testProperty "SomeTypeObjectWithSingleField unary agree" $
485 thSomeTypeToEncodingObjectWithSingleField `sameAs1Agree` thSomeTypeLiftToEncodingObjectWithSingleField
503 thSomeTypeToEncodingObjectWithSingleField `sameAs1Agree` thSomeTypeLiftToEncodingObjectWithSingleField
487− , testProperty "OneConstructor" $
505+ , testProperty "OneConstructorDefault" $
488 thOneConstructorToJSONDefault `sameAs` thOneConstructorToEncodingDefault
506 thOneConstructorToJSONDefault `sameAs` thOneConstructorToEncodingDefault
507+ , testProperty "OneConstructorTagged" $
508+ thOneConstructorToJSONTagged `sameAs` thOneConstructorToEncodingTagged