on 0.11.2.0 help sign in
80 lines 4.2 kB history raw
1module DataFamilies.Properties (tests) where
3import DataFamilies.Encoders
4import DataFamilies.Instances ()
6import Properties hiding (tests)
8import Test.Framework (Test, testGroup)
9import Test.Framework.Providers.QuickCheck2 (testProperty)
11--------------------------------------------------------------------------------
13tests :: Test
14tests = testGroup "data families" [
15 testGroup "template-haskell" [
16 testGroup "toJSON" [
17 testGroup "Nullary" [
18 testProperty "string" (isString . thNullaryToJSONString)
19 , testProperty "2ElemArray" (is2ElemArray . thNullaryToJSON2ElemArray)
20 , testProperty "TaggedObject" (isTaggedObjectValue . thNullaryToJSONTaggedObject)
21 , testProperty "ObjectWithSingleField" (isObjectWithSingleField . thNullaryToJSONObjectWithSingleField)
23 , testGroup "roundTrip" [
24 testProperty "string" (toParseJSON thNullaryParseJSONString thNullaryToJSONString)
25 , testProperty "2ElemArray" (toParseJSON thNullaryParseJSON2ElemArray thNullaryToJSON2ElemArray)
26 , testProperty "TaggedObject" (toParseJSON thNullaryParseJSONTaggedObject thNullaryToJSONTaggedObject)
27 , testProperty "ObjectWithSingleField" (toParseJSON thNullaryParseJSONObjectWithSingleField thNullaryToJSONObjectWithSingleField)
28 ]
29 ]
30 , testGroup "SomeType" [
31 testProperty "2ElemArray" (is2ElemArray . thSomeTypeToJSON2ElemArray)
32 , testProperty "TaggedObject" (isTaggedObject . thSomeTypeToJSONTaggedObject)
33 , testProperty "ObjectWithSingleField" (isObjectWithSingleField . thSomeTypeToJSONObjectWithSingleField)
34 , testGroup "roundTrip" [
35 testProperty "2ElemArray" (toParseJSON thSomeTypeParseJSON2ElemArray thSomeTypeToJSON2ElemArray)
36 , testProperty "TaggedObject" (toParseJSON thSomeTypeParseJSONTaggedObject thSomeTypeToJSONTaggedObject)
37 , testProperty "ObjectWithSingleField" (toParseJSON thSomeTypeParseJSONObjectWithSingleField thSomeTypeToJSONObjectWithSingleField)
38 ]
39 , testGroup "Approx" [
40 testProperty "string" (isString . thApproxToJSONUnwrap)
41 , testProperty "ObjectWithSingleField" (isObjectWithSingleField . thApproxToJSONDefault)
42 , testGroup "roundTrip" [
43 testProperty "string" (toParseJSON thApproxParseJSONUnwrap thApproxToJSONUnwrap)
44 , testProperty "ObjectWithSingleField" (toParseJSON thApproxParseJSONDefault thApproxToJSONDefault)
45 ]
46 ]
47 , testGroup "GADT" [
48 testProperty "string" (isString . thGADTToJSONUnwrap)
49 , testProperty "ObjectWithSingleField" (isObjectWithSingleField . thGADTToJSONDefault)
50 , testGroup "roundTrip" [
51 testProperty "string" (toParseJSON thGADTParseJSONUnwrap thGADTToJSONUnwrap)
52 , testProperty "ObjectWithSingleField" (toParseJSON thGADTParseJSONDefault thGADTToJSONDefault)
53 ]
54 ]
55 ]
56 ]
57 , testGroup "toEncoding" [
58 testProperty "NullaryString" $
59 thNullaryToJSONString `sameAs` thNullaryToEncodingString
60 , testProperty "Nullary2ElemArray" $
61 thNullaryToJSON2ElemArray `sameAs` thNullaryToEncoding2ElemArray
62 , testProperty "NullaryTaggedObject" $
63 thNullaryToJSONTaggedObject `sameAs` thNullaryToEncodingTaggedObject
64 , testProperty "NullaryObjectWithSingleField" $
65 thNullaryToJSONObjectWithSingleField `sameAs`
66 thNullaryToEncodingObjectWithSingleField
67 , testProperty "ApproxUnwrap" $
68 thApproxToJSONUnwrap `sameAs` thApproxToEncodingUnwrap
69 , testProperty "ApproxDefault" $
70 thApproxToJSONDefault `sameAs` thApproxToEncodingDefault
71 , testProperty "SomeType2ElemArray" $
72 thSomeTypeToJSON2ElemArray `sameAs` thSomeTypeToEncoding2ElemArray
73 , testProperty "SomeTypeTaggedObject" $
74 thSomeTypeToJSONTaggedObject `sameAs` thSomeTypeToEncodingTaggedObject
75 , testProperty "SomeTypeObjectWithSingleField" $
76 thSomeTypeToJSONObjectWithSingleField `sameAs`
77 thSomeTypeToEncodingObjectWithSingleField
78 ]
79 ]
80 ]