fix[Type]: Empty Unions are disallowed
This commit is contained in:
parent
987a849682
commit
59ba6e2af5
1 changed files with 4 additions and 3 deletions
|
@ -24,7 +24,7 @@ import qualified Data.Array.IArray as Array
|
|||
import qualified Data.List as List
|
||||
import Control.Arrow ((>>>))
|
||||
import GHC.Records (HasField (getField))
|
||||
import Test.QuickCheck (Gen, Arbitrary (arbitrary), UnicodeString (getUnicodeString))
|
||||
import Test.QuickCheck (Gen, Arbitrary (arbitrary), UnicodeString (getUnicodeString), NonEmptyList (getNonEmpty))
|
||||
import qualified Data.Text as Text
|
||||
import qualified Data.Array.Arbitrary as ArbitraryArray
|
||||
import qualified Data.Traversable as Traversable
|
||||
|
@ -48,6 +48,7 @@ pattern Union set <- Union' set where
|
|||
Union set = let
|
||||
merged = mergeUnionObjects set
|
||||
in case Set.toList merged of
|
||||
[] -> Null
|
||||
[t] -> t
|
||||
_ -> Union' merged
|
||||
|
||||
|
@ -82,8 +83,8 @@ instance Arbitrary Type where
|
|||
, pure Number
|
||||
, pure String
|
||||
, pure Boolean
|
||||
, Array <$> arbitrary
|
||||
, Union <$> Gen.scale (`div` 2) arbitrary
|
||||
, Array <$> Gen.scale (`div` 2) arbitrary
|
||||
, Union . Set.fromList . getNonEmpty <$> Gen.scale (`div` 2) arbitrary
|
||||
, Object . Map.mapKeys (Text.pack . getUnicodeString) <$> Gen.scale (`div` 2) arbitrary
|
||||
]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue