@@ -168,11 +168,14 @@ isTaggedObjectValue (Object obj) = "tag" `H.member` obj &&
168
168
isTaggedObjectValue _ = False
169
169
170
170
isNullaryTaggedObject :: Value -> Bool
171
- isNullaryTaggedObject obj = isTaggedObject obj && isObjectWithSingleField obj
171
+ isNullaryTaggedObject obj = isTaggedObject' obj && isObjectWithSingleField obj
172
172
173
- isTaggedObject :: Value -> Bool
174
- isTaggedObject (Object obj) = " tag" `H.member` obj
175
- isTaggedObject _ = False
173
+ isTaggedObject :: Value -> Property
174
+ isTaggedObject = checkValue isTaggedObject'
175
+
176
+ isTaggedObject' :: Value -> Bool
177
+ isTaggedObject' (Object obj) = " tag" `H.member` obj
178
+ isTaggedObject' _ = False
176
179
177
180
isObjectWithSingleField :: Value -> Bool
178
181
isObjectWithSingleField (Object obj) = H. size obj == 1
@@ -338,6 +341,14 @@ tests = testGroup "properties" [
338
341
#endif
339
342
]
340
343
]
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)
350
+ ]
351
+ ]
341
352
]
342
353
, testGroup " toEncoding" [
343
354
testProperty " NullaryString" $
@@ -386,6 +397,11 @@ tests = testGroup "properties" [
386
397
387
398
, testProperty " SomeTypeOmitNothingFields" $
388
399
gSomeTypeToJSONOmitNothingFields `sameAs` gSomeTypeToEncodingOmitNothingFields
400
+
401
+ , testProperty " OneConstructorDefault" $
402
+ gOneConstructorToJSONDefault `sameAs` gOneConstructorToEncodingDefault
403
+ , testProperty " OneConstructorTagged" $
404
+ gOneConstructorToJSONTagged `sameAs` gOneConstructorToEncodingTagged
389
405
]
390
406
]
391
407
, testGroup " template-haskell" [
@@ -440,8 +456,10 @@ tests = testGroup "properties" [
440
456
]
441
457
, testGroup " OneConstructor" [
442
458
testProperty " default" (isEmptyArray . thOneConstructorToJSONDefault)
459
+ , testProperty " Tagged" (isTaggedObject . thOneConstructorToJSONTagged)
443
460
, testGroup " roundTrip" [
444
461
testProperty " default" (toParseJSON thOneConstructorParseJSONDefault thOneConstructorToJSONDefault)
462
+ , testProperty " Tagged" (toParseJSON thOneConstructorParseJSONTagged thOneConstructorToJSONTagged)
445
463
]
446
464
]
447
465
]
@@ -484,8 +502,10 @@ tests = testGroup "properties" [
484
502
, testProperty " SomeTypeObjectWithSingleField unary agree" $
485
503
thSomeTypeToEncodingObjectWithSingleField `sameAs1Agree` thSomeTypeLiftToEncodingObjectWithSingleField
486
504
487
- , testProperty " OneConstructor " $
505
+ , testProperty " OneConstructorDefault " $
488
506
thOneConstructorToJSONDefault `sameAs` thOneConstructorToEncodingDefault
507
+ , testProperty " OneConstructorTagged" $
508
+ thOneConstructorToJSONTagged `sameAs` thOneConstructorToEncodingTagged
489
509
]
490
510
]
491
511
]
0 commit comments