|
Packit |
9a2dfb |
{-# LANGUAGE CPP #-}
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
module DataFamilies.Properties (tests) where
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
import Prelude ()
|
|
Packit |
9a2dfb |
import Prelude.Compat
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
import DataFamilies.Encoders
|
|
Packit |
9a2dfb |
import DataFamilies.Instances ()
|
|
Packit |
9a2dfb |
import Properties hiding (tests)
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
import Test.Framework (Test, testGroup)
|
|
Packit |
9a2dfb |
import Test.Framework.Providers.QuickCheck2 (testProperty)
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
--------------------------------------------------------------------------------
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
tests :: Test
|
|
Packit |
9a2dfb |
tests = testGroup "data families" [
|
|
Packit |
9a2dfb |
testGroup "template-haskell" [
|
|
Packit |
9a2dfb |
testGroup "toJSON" [
|
|
Packit |
9a2dfb |
testGroup "Nullary" [
|
|
Packit |
9a2dfb |
testProperty "string" (isString . thNullaryToJSONString)
|
|
Packit |
9a2dfb |
, testProperty "2ElemArray" (is2ElemArray . thNullaryToJSON2ElemArray)
|
|
Packit |
9a2dfb |
, testProperty "TaggedObject" (isNullaryTaggedObject . thNullaryToJSONTaggedObject)
|
|
Packit |
9a2dfb |
, testProperty "ObjectWithSingleField" (isObjectWithSingleField . thNullaryToJSONObjectWithSingleField)
|
|
Packit |
9a2dfb |
, testGroup "roundTrip" [
|
|
Packit |
9a2dfb |
testProperty "string" (toParseJSON thNullaryParseJSONString thNullaryToJSONString)
|
|
Packit |
9a2dfb |
, testProperty "2ElemArray" (toParseJSON thNullaryParseJSON2ElemArray thNullaryToJSON2ElemArray)
|
|
Packit |
9a2dfb |
, testProperty "TaggedObject" (toParseJSON thNullaryParseJSONTaggedObject thNullaryToJSONTaggedObject)
|
|
Packit |
9a2dfb |
, testProperty "ObjectWithSingleField" (toParseJSON thNullaryParseJSONObjectWithSingleField thNullaryToJSONObjectWithSingleField)
|
|
Packit |
9a2dfb |
]
|
|
Packit |
9a2dfb |
]
|
|
Packit |
9a2dfb |
, testGroup "SomeType" [
|
|
Packit |
9a2dfb |
testProperty "2ElemArray" (is2ElemArray . thSomeTypeToJSON2ElemArray)
|
|
Packit |
9a2dfb |
, testProperty "TaggedObject" (isTaggedObject . thSomeTypeToJSONTaggedObject)
|
|
Packit |
9a2dfb |
, testProperty "ObjectWithSingleField" (isObjectWithSingleField . thSomeTypeToJSONObjectWithSingleField)
|
|
Packit |
9a2dfb |
, testGroup "roundTrip" [
|
|
Packit |
9a2dfb |
testProperty "2ElemArray" (toParseJSON thSomeTypeParseJSON2ElemArray thSomeTypeToJSON2ElemArray)
|
|
Packit |
9a2dfb |
, testProperty "TaggedObject" (toParseJSON thSomeTypeParseJSONTaggedObject thSomeTypeToJSONTaggedObject)
|
|
Packit |
9a2dfb |
, testProperty "ObjectWithSingleField" (toParseJSON thSomeTypeParseJSONObjectWithSingleField thSomeTypeToJSONObjectWithSingleField)
|
|
Packit |
9a2dfb |
]
|
|
Packit |
9a2dfb |
]
|
|
Packit |
9a2dfb |
, testGroup "Approx" [
|
|
Packit |
9a2dfb |
testProperty "string" (isString . thApproxToJSONUnwrap)
|
|
Packit |
9a2dfb |
, testProperty "ObjectWithSingleField" (isObjectWithSingleField . thApproxToJSONDefault)
|
|
Packit |
9a2dfb |
, testGroup "roundTrip" [
|
|
Packit |
9a2dfb |
testProperty "string" (toParseJSON thApproxParseJSONUnwrap thApproxToJSONUnwrap)
|
|
Packit |
9a2dfb |
, testProperty "ObjectWithSingleField" (toParseJSON thApproxParseJSONDefault thApproxToJSONDefault)
|
|
Packit |
9a2dfb |
]
|
|
Packit |
9a2dfb |
]
|
|
Packit |
9a2dfb |
, testGroup "GADT" [
|
|
Packit |
9a2dfb |
testProperty "string" (isString . thGADTToJSONUnwrap)
|
|
Packit |
9a2dfb |
, testProperty "ObjectWithSingleField" (isObjectWithSingleField . thGADTToJSONDefault)
|
|
Packit |
9a2dfb |
, testGroup "roundTrip" [
|
|
Packit |
9a2dfb |
testProperty "string" (toParseJSON thGADTParseJSONUnwrap thGADTToJSONUnwrap)
|
|
Packit |
9a2dfb |
, testProperty "ObjectWithSingleField" (toParseJSON thGADTParseJSONDefault thGADTToJSONDefault)
|
|
Packit |
9a2dfb |
]
|
|
Packit |
9a2dfb |
]
|
|
Packit |
9a2dfb |
]
|
|
Packit |
9a2dfb |
, testGroup "toEncoding" [
|
|
Packit |
9a2dfb |
testProperty "NullaryString" $
|
|
Packit |
9a2dfb |
thNullaryToJSONString `sameAs` thNullaryToEncodingString
|
|
Packit |
9a2dfb |
, testProperty "Nullary2ElemArray" $
|
|
Packit |
9a2dfb |
thNullaryToJSON2ElemArray `sameAs` thNullaryToEncoding2ElemArray
|
|
Packit |
9a2dfb |
, testProperty "NullaryTaggedObject" $
|
|
Packit |
9a2dfb |
thNullaryToJSONTaggedObject `sameAs` thNullaryToEncodingTaggedObject
|
|
Packit |
9a2dfb |
, testProperty "NullaryObjectWithSingleField" $
|
|
Packit |
9a2dfb |
thNullaryToJSONObjectWithSingleField `sameAs`
|
|
Packit |
9a2dfb |
thNullaryToEncodingObjectWithSingleField
|
|
Packit |
9a2dfb |
, testProperty "ApproxUnwrap" $
|
|
Packit |
9a2dfb |
thApproxToJSONUnwrap `sameAs` thApproxToEncodingUnwrap
|
|
Packit |
9a2dfb |
, testProperty "ApproxDefault" $
|
|
Packit |
9a2dfb |
thApproxToJSONDefault `sameAs` thApproxToEncodingDefault
|
|
Packit |
9a2dfb |
, testProperty "SomeType2ElemArray" $
|
|
Packit |
9a2dfb |
thSomeTypeToJSON2ElemArray `sameAs` thSomeTypeToEncoding2ElemArray
|
|
Packit |
9a2dfb |
, testProperty "SomeTypeTaggedObject" $
|
|
Packit |
9a2dfb |
thSomeTypeToJSONTaggedObject `sameAs` thSomeTypeToEncodingTaggedObject
|
|
Packit |
9a2dfb |
, testProperty "SomeTypeObjectWithSingleField" $
|
|
Packit |
9a2dfb |
thSomeTypeToJSONObjectWithSingleField `sameAs`
|
|
Packit |
9a2dfb |
thSomeTypeToEncodingObjectWithSingleField
|
|
Packit |
9a2dfb |
]
|
|
Packit |
9a2dfb |
]
|
|
Packit |
9a2dfb |
|
|
Packit |
9a2dfb |
, testGroup "generics" [
|
|
Packit |
9a2dfb |
testGroup "toJSON" [
|
|
Packit |
9a2dfb |
testGroup "Nullary" [
|
|
Packit |
9a2dfb |
testProperty "string" (isString . gNullaryToJSONString)
|
|
Packit |
9a2dfb |
, testProperty "2ElemArray" (is2ElemArray . gNullaryToJSON2ElemArray)
|
|
Packit |
9a2dfb |
, testProperty "TaggedObject" (isNullaryTaggedObject . gNullaryToJSONTaggedObject)
|
|
Packit |
9a2dfb |
, testProperty "ObjectWithSingleField" (isObjectWithSingleField . gNullaryToJSONObjectWithSingleField)
|
|
Packit |
9a2dfb |
, testGroup "roundTrip" [
|
|
Packit |
9a2dfb |
testProperty "string" (toParseJSON gNullaryParseJSONString gNullaryToJSONString)
|
|
Packit |
9a2dfb |
, testProperty "2ElemArray" (toParseJSON gNullaryParseJSON2ElemArray gNullaryToJSON2ElemArray)
|
|
Packit |
9a2dfb |
, testProperty "TaggedObject" (toParseJSON gNullaryParseJSONTaggedObject gNullaryToJSONTaggedObject)
|
|
Packit |
9a2dfb |
, testProperty "ObjectWithSingleField" (toParseJSON gNullaryParseJSONObjectWithSingleField gNullaryToJSONObjectWithSingleField)
|
|
Packit |
9a2dfb |
]
|
|
Packit |
9a2dfb |
]
|
|
Packit |
9a2dfb |
, testGroup "SomeType" [
|
|
Packit |
9a2dfb |
testProperty "2ElemArray" (is2ElemArray . gSomeTypeToJSON2ElemArray)
|
|
Packit |
9a2dfb |
, testProperty "TaggedObject" (isTaggedObject . gSomeTypeToJSONTaggedObject)
|
|
Packit |
9a2dfb |
, testProperty "ObjectWithSingleField" (isObjectWithSingleField . gSomeTypeToJSONObjectWithSingleField)
|
|
Packit |
9a2dfb |
, testGroup "roundTrip" [
|
|
Packit |
9a2dfb |
testProperty "2ElemArray" (toParseJSON gSomeTypeParseJSON2ElemArray gSomeTypeToJSON2ElemArray)
|
|
Packit |
9a2dfb |
, testProperty "TaggedObject" (toParseJSON gSomeTypeParseJSONTaggedObject gSomeTypeToJSONTaggedObject)
|
|
Packit |
9a2dfb |
, testProperty "ObjectWithSingleField" (toParseJSON gSomeTypeParseJSONObjectWithSingleField gSomeTypeToJSONObjectWithSingleField)
|
|
Packit |
9a2dfb |
]
|
|
Packit |
9a2dfb |
]
|
|
Packit |
9a2dfb |
, testGroup "Approx" [
|
|
Packit |
9a2dfb |
testProperty "string" (isString . gApproxToJSONUnwrap)
|
|
Packit |
9a2dfb |
, testProperty "ObjectWithSingleField" (isObjectWithSingleField . gApproxToJSONDefault)
|
|
Packit |
9a2dfb |
, testGroup "roundTrip" [
|
|
Packit |
9a2dfb |
testProperty "string" (toParseJSON gApproxParseJSONUnwrap gApproxToJSONUnwrap)
|
|
Packit |
9a2dfb |
, testProperty "ObjectWithSingleField" (toParseJSON gApproxParseJSONDefault gApproxToJSONDefault)
|
|
Packit |
9a2dfb |
]
|
|
Packit |
9a2dfb |
]
|
|
Packit |
9a2dfb |
]
|
|
Packit |
9a2dfb |
, testGroup "toEncoding" [
|
|
Packit |
9a2dfb |
testProperty "NullaryString" $
|
|
Packit |
9a2dfb |
gNullaryToJSONString `sameAs` gNullaryToEncodingString
|
|
Packit |
9a2dfb |
, testProperty "Nullary2ElemArray" $
|
|
Packit |
9a2dfb |
gNullaryToJSON2ElemArray `sameAs` gNullaryToEncoding2ElemArray
|
|
Packit |
9a2dfb |
, testProperty "NullaryTaggedObject" $
|
|
Packit |
9a2dfb |
gNullaryToJSONTaggedObject `sameAs` gNullaryToEncodingTaggedObject
|
|
Packit |
9a2dfb |
, testProperty "NullaryObjectWithSingleField" $
|
|
Packit |
9a2dfb |
gNullaryToJSONObjectWithSingleField `sameAs`
|
|
Packit |
9a2dfb |
gNullaryToEncodingObjectWithSingleField
|
|
Packit |
9a2dfb |
, testProperty "ApproxUnwrap" $
|
|
Packit |
9a2dfb |
gApproxToJSONUnwrap `sameAs` gApproxToEncodingUnwrap
|
|
Packit |
9a2dfb |
, testProperty "ApproxDefault" $
|
|
Packit |
9a2dfb |
gApproxToJSONDefault `sameAs` gApproxToEncodingDefault
|
|
Packit |
9a2dfb |
, testProperty "SomeType2ElemArray" $
|
|
Packit |
9a2dfb |
gSomeTypeToJSON2ElemArray `sameAs` gSomeTypeToEncoding2ElemArray
|
|
Packit |
9a2dfb |
, testProperty "SomeTypeTaggedObject" $
|
|
Packit |
9a2dfb |
gSomeTypeToJSONTaggedObject `sameAs` gSomeTypeToEncodingTaggedObject
|
|
Packit |
9a2dfb |
, testProperty "SomeTypeObjectWithSingleField" $
|
|
Packit |
9a2dfb |
gSomeTypeToJSONObjectWithSingleField `sameAs`
|
|
Packit |
9a2dfb |
gSomeTypeToEncodingObjectWithSingleField
|
|
Packit |
9a2dfb |
]
|
|
Packit |
9a2dfb |
]
|
|
Packit |
9a2dfb |
]
|