Skip to content

Commit a5c61cb

Browse files
author
Poscat
committed
More property tests
1 parent 35a50d1 commit a5c61cb

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

tests/DataFamilies/Encoders.hs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ thNullaryParseJSONTaggedObject :: Value -> Parser (Nullary Int)
4646
thNullaryParseJSONTaggedObject = $(mkParseJSON optsTaggedObject 'C3)
4747

4848

49+
thNullaryToJSONTaggedFlatObject :: Nullary Int -> Value
50+
thNullaryToJSONTaggedFlatObject = $(mkToJSON optsTaggedFlatObject 'C1)
51+
52+
thNullaryToEncodingTaggedFlatObject :: Nullary Int -> Encoding
53+
thNullaryToEncodingTaggedFlatObject = $(mkToEncoding optsTaggedFlatObject 'C2)
54+
55+
thNullaryParseJSONTaggedFlatObject :: Value -> Parser (Nullary Int)
56+
thNullaryParseJSONTaggedFlatObject = $(mkParseJSON optsTaggedFlatObject 'C3)
57+
58+
4959
thNullaryToJSONObjectWithSingleField :: Nullary Int -> Value
5060
thNullaryToJSONObjectWithSingleField =
5161
$(mkToJSON optsObjectWithSingleField 'C1)
@@ -82,6 +92,16 @@ thSomeTypeParseJSONTaggedObject :: Value -> Parser (SomeType c () Int)
8292
thSomeTypeParseJSONTaggedObject = $(mkParseJSON optsTaggedObject 'Unary)
8393

8494

95+
thSomeTypeToJSONTaggedFlatObject :: SomeType c () Int -> Value
96+
thSomeTypeToJSONTaggedFlatObject = $(mkToJSON optsTaggedFlatObject 'Record)
97+
98+
thSomeTypeToEncodingTaggedFlatObject :: SomeType c () Int -> Encoding
99+
thSomeTypeToEncodingTaggedFlatObject = $(mkToEncoding optsTaggedFlatObject 'Nullary)
100+
101+
thSomeTypeParseJSONTaggedFlatObject :: Value -> Parser (SomeType c () Int)
102+
thSomeTypeParseJSONTaggedFlatObject = $(mkParseJSON optsTaggedFlatObject 'Unary)
103+
104+
85105
thSomeTypeToJSONObjectWithSingleField :: SomeType c () Int -> Value
86106
thSomeTypeToJSONObjectWithSingleField =
87107
$(mkToJSON optsObjectWithSingleField 'Product)
@@ -177,6 +197,16 @@ gNullaryParseJSONTaggedObject :: Value -> Parser (Nullary Int)
177197
gNullaryParseJSONTaggedObject = genericParseJSON optsTaggedObject
178198

179199

200+
gNullaryToJSONTaggedFlatObject :: Nullary Int -> Value
201+
gNullaryToJSONTaggedFlatObject = genericToJSON optsTaggedFlatObject
202+
203+
gNullaryToEncodingTaggedFlatObject :: Nullary Int -> Encoding
204+
gNullaryToEncodingTaggedFlatObject = genericToEncoding optsTaggedFlatObject
205+
206+
gNullaryParseJSONTaggedFlatObject :: Value -> Parser (Nullary Int)
207+
gNullaryParseJSONTaggedFlatObject = genericParseJSON optsTaggedFlatObject
208+
209+
180210
gNullaryToJSONObjectWithSingleField :: Nullary Int -> Value
181211
gNullaryToJSONObjectWithSingleField = genericToJSON optsObjectWithSingleField
182212

@@ -208,6 +238,16 @@ gSomeTypeParseJSONTaggedObject :: Value -> Parser (SomeType c () Int)
208238
gSomeTypeParseJSONTaggedObject = genericParseJSON optsTaggedObject
209239

210240

241+
gSomeTypeToJSONTaggedFlatObject :: SomeType c () Int -> Value
242+
gSomeTypeToJSONTaggedFlatObject = genericToJSON optsTaggedFlatObject
243+
244+
gSomeTypeToEncodingTaggedFlatObject :: SomeType c () Int -> Encoding
245+
gSomeTypeToEncodingTaggedFlatObject = genericToEncoding optsTaggedFlatObject
246+
247+
gSomeTypeParseJSONTaggedFlatObject :: Value -> Parser (SomeType c () Int)
248+
gSomeTypeParseJSONTaggedFlatObject = genericParseJSON optsTaggedFlatObject
249+
250+
211251
gSomeTypeToJSONObjectWithSingleField :: SomeType c () Int -> Value
212252
gSomeTypeToJSONObjectWithSingleField = genericToJSON optsObjectWithSingleField
213253

tests/DataFamilies/Properties.hs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,25 @@ tests = testGroup "data families" [
2323
testProperty "string" (isString . thNullaryToJSONString)
2424
, testProperty "2ElemArray" (is2ElemArray . thNullaryToJSON2ElemArray)
2525
, testProperty "TaggedObject" (isNullaryTaggedObject . thNullaryToJSONTaggedObject)
26+
, testProperty "TaggedFlatObject" (isNullaryTaggedObject . thNullaryToJSONTaggedFlatObject)
2627
, testProperty "ObjectWithSingleField" (isObjectWithSingleField . thNullaryToJSONObjectWithSingleField)
2728
, testGroup "roundTrip" [
2829
testProperty "string" (toParseJSON thNullaryParseJSONString thNullaryToJSONString)
2930
, testProperty "2ElemArray" (toParseJSON thNullaryParseJSON2ElemArray thNullaryToJSON2ElemArray)
3031
, testProperty "TaggedObject" (toParseJSON thNullaryParseJSONTaggedObject thNullaryToJSONTaggedObject)
32+
, testProperty "TaggedFlatObject" (toParseJSON thNullaryParseJSONTaggedFlatObject thNullaryToJSONTaggedFlatObject)
3133
, testProperty "ObjectWithSingleField" (toParseJSON thNullaryParseJSONObjectWithSingleField thNullaryToJSONObjectWithSingleField)
3234
]
3335
]
3436
, testGroup "SomeType" [
3537
testProperty "2ElemArray" (is2ElemArray . thSomeTypeToJSON2ElemArray)
3638
, testProperty "TaggedObject" (isTaggedObject . thSomeTypeToJSONTaggedObject)
39+
, testProperty "TaggedFlatObject" (isTaggedObject . thSomeTypeToJSONTaggedFlatObject)
3740
, testProperty "ObjectWithSingleField" (isObjectWithSingleField . thSomeTypeToJSONObjectWithSingleField)
3841
, testGroup "roundTrip" [
3942
testProperty "2ElemArray" (toParseJSON thSomeTypeParseJSON2ElemArray thSomeTypeToJSON2ElemArray)
4043
, testProperty "TaggedObject" (toParseJSON thSomeTypeParseJSONTaggedObject thSomeTypeToJSONTaggedObject)
44+
, testProperty "TaggedFlatObject" (toParseJSON thSomeTypeParseJSONTaggedFlatObject thSomeTypeToJSONTaggedFlatObject)
4145
, testProperty "ObjectWithSingleField" (toParseJSON thSomeTypeParseJSONObjectWithSingleField thSomeTypeToJSONObjectWithSingleField)
4246
]
4347
]
@@ -65,6 +69,8 @@ tests = testGroup "data families" [
6569
thNullaryToJSON2ElemArray `sameAs` thNullaryToEncoding2ElemArray
6670
, testProperty "NullaryTaggedObject" $
6771
thNullaryToJSONTaggedObject `sameAs` thNullaryToEncodingTaggedObject
72+
, testProperty "NullaryTaggedFlatObject" $
73+
thNullaryToJSONTaggedFlatObject `sameAs` thNullaryToEncodingTaggedFlatObject
6874
, testProperty "NullaryObjectWithSingleField" $
6975
thNullaryToJSONObjectWithSingleField `sameAs`
7076
thNullaryToEncodingObjectWithSingleField
@@ -76,6 +82,8 @@ tests = testGroup "data families" [
7682
thSomeTypeToJSON2ElemArray `sameAs` thSomeTypeToEncoding2ElemArray
7783
, testProperty "SomeTypeTaggedObject" $
7884
thSomeTypeToJSONTaggedObject `sameAs` thSomeTypeToEncodingTaggedObject
85+
, testProperty "SomeTypeTaggedFlatObject" $
86+
thSomeTypeToJSONTaggedFlatObject `sameAs` thSomeTypeToEncodingTaggedFlatObject
7987
, testProperty "SomeTypeObjectWithSingleField" $
8088
thSomeTypeToJSONObjectWithSingleField `sameAs`
8189
thSomeTypeToEncodingObjectWithSingleField
@@ -88,21 +96,25 @@ tests = testGroup "data families" [
8896
testProperty "string" (isString . gNullaryToJSONString)
8997
, testProperty "2ElemArray" (is2ElemArray . gNullaryToJSON2ElemArray)
9098
, testProperty "TaggedObject" (isNullaryTaggedObject . gNullaryToJSONTaggedObject)
99+
, testProperty "TaggedFlatObject" (isNullaryTaggedObject . gNullaryToJSONTaggedFlatObject)
91100
, testProperty "ObjectWithSingleField" (isObjectWithSingleField . gNullaryToJSONObjectWithSingleField)
92101
, testGroup "roundTrip" [
93102
testProperty "string" (toParseJSON gNullaryParseJSONString gNullaryToJSONString)
94103
, testProperty "2ElemArray" (toParseJSON gNullaryParseJSON2ElemArray gNullaryToJSON2ElemArray)
95104
, testProperty "TaggedObject" (toParseJSON gNullaryParseJSONTaggedObject gNullaryToJSONTaggedObject)
105+
, testProperty "TaggedFlatObject" (toParseJSON gNullaryParseJSONTaggedFlatObject gNullaryToJSONTaggedFlatObject)
96106
, testProperty "ObjectWithSingleField" (toParseJSON gNullaryParseJSONObjectWithSingleField gNullaryToJSONObjectWithSingleField)
97107
]
98108
]
99109
, testGroup "SomeType" [
100110
testProperty "2ElemArray" (is2ElemArray . gSomeTypeToJSON2ElemArray)
101111
, testProperty "TaggedObject" (isTaggedObject . gSomeTypeToJSONTaggedObject)
112+
, testProperty "TaggedFlatObject" (isTaggedObject . gSomeTypeToJSONTaggedFlatObject)
102113
, testProperty "ObjectWithSingleField" (isObjectWithSingleField . gSomeTypeToJSONObjectWithSingleField)
103114
, testGroup "roundTrip" [
104115
testProperty "2ElemArray" (toParseJSON gSomeTypeParseJSON2ElemArray gSomeTypeToJSON2ElemArray)
105116
, testProperty "TaggedObject" (toParseJSON gSomeTypeParseJSONTaggedObject gSomeTypeToJSONTaggedObject)
117+
, testProperty "TaggedFlatObject" (toParseJSON gSomeTypeParseJSONTaggedFlatObject gSomeTypeToJSONTaggedFlatObject)
106118
, testProperty "ObjectWithSingleField" (toParseJSON gSomeTypeParseJSONObjectWithSingleField gSomeTypeToJSONObjectWithSingleField)
107119
]
108120
]
@@ -122,6 +134,8 @@ tests = testGroup "data families" [
122134
gNullaryToJSON2ElemArray `sameAs` gNullaryToEncoding2ElemArray
123135
, testProperty "NullaryTaggedObject" $
124136
gNullaryToJSONTaggedObject `sameAs` gNullaryToEncodingTaggedObject
137+
, testProperty "NullaryTaggedFlatObject" $
138+
gNullaryToJSONTaggedFlatObject `sameAs` gNullaryToEncodingTaggedFlatObject
125139
, testProperty "NullaryObjectWithSingleField" $
126140
gNullaryToJSONObjectWithSingleField `sameAs`
127141
gNullaryToEncodingObjectWithSingleField
@@ -133,6 +147,8 @@ tests = testGroup "data families" [
133147
gSomeTypeToJSON2ElemArray `sameAs` gSomeTypeToEncoding2ElemArray
134148
, testProperty "SomeTypeTaggedObject" $
135149
gSomeTypeToJSONTaggedObject `sameAs` gSomeTypeToEncodingTaggedObject
150+
, testProperty "SomeTypeTaggedFlatObject" $
151+
gSomeTypeToJSONTaggedFlatObject `sameAs` gSomeTypeToEncodingTaggedFlatObject
136152
, testProperty "SomeTypeObjectWithSingleField" $
137153
gSomeTypeToJSONObjectWithSingleField `sameAs`
138154
gSomeTypeToEncodingObjectWithSingleField

0 commit comments

Comments
 (0)