git.iko.soy/typeable/swagger2
on master help sign in
use quickcheck-instances
10beedbMatt Parsons
swagger2.cabal+2−1
@@ -92,6 +92,7 @@ test-suite spec
92 , HUnit
92 , HUnit
93 , mtl
93 , mtl
94 , QuickCheck >=2.8.2
94 , QuickCheck >=2.8.2
95+ , quickcheck-instances
95 , swagger2
96 , swagger2
96 , text
97 , text
97 , time
98 , time
@@ -99,7 +100,7 @@ test-suite spec
99 , vector
100 , vector
100 , lens
101 , lens
101 if !impl(ghc >= 8.0)
102 if !impl(ghc >= 8.0)
102− build-depends: semigroups >= 0.18.3 && <0.19
103+ build-depends: semigroups
103
104
104 other-modules:
105 other-modules:
105 SpecCommon
106 SpecCommon
test/Data/Swagger/Schema/ValidationSpec.hs+7−3
@@ -33,6 +33,7 @@ import Data.Swagger.Declare
33import Test.Hspec
33import Test.Hspec
34import Test.Hspec.QuickCheck
34import Test.Hspec.QuickCheck
35import Test.QuickCheck
35import Test.QuickCheck
36+import Test.QuickCheck.Instances ()
36
37
37shouldValidate :: (ToJSON a, ToSchema a) => Proxy a -> a -> Bool
38shouldValidate :: (ToJSON a, ToSchema a) => Proxy a -> a -> Bool
38shouldValidate _ x = validateToJSON x == []
39shouldValidate _ x = validateToJSON x == []
@@ -230,6 +231,10 @@ invalidButtonImagesToJSON = genericToJSON defaultOptions
230instance Arbitrary ButtonImages where
231instance Arbitrary ButtonImages where
231 arbitrary = ButtonImages <$> arbitrary
232 arbitrary = ButtonImages <$> arbitrary
232
233
234+instance Eq ZonedTime where
235+ ZonedTime t (TimeZone x _ _) == ZonedTime t' (TimeZone y _ _) = t == t' && x == y
236+
237+{-
233-- Arbitrary instances for common types
238-- Arbitrary instances for common types
234
239
235instance (Eq k, Hashable k, Arbitrary k, Arbitrary v) => Arbitrary (HashMap k v) where
240instance (Eq k, Hashable k, Arbitrary k, Arbitrary v) => Arbitrary (HashMap k v) where
@@ -252,9 +257,6 @@ instance Arbitrary LocalTime where
252 <$> arbitrary
257 <$> arbitrary
253 <*> liftA3 TimeOfDay (choose (0, 23)) (choose (0, 59)) (fromInteger <$> choose (0, 60))
258 <*> liftA3 TimeOfDay (choose (0, 23)) (choose (0, 59)) (fromInteger <$> choose (0, 60))
254
259
255−instance Eq ZonedTime where
256− ZonedTime t (TimeZone x _ _) == ZonedTime t' (TimeZone y _ _) = t == t' && x == y
257−
258instance Arbitrary ZonedTime where
260instance Arbitrary ZonedTime where
259 arbitrary = ZonedTime
261 arbitrary = ZonedTime
260 <$> arbitrary
262 <$> arbitrary
@@ -272,3 +274,5 @@ instance Arbitrary a => Arbitrary (NonEmpty a) where
272 arbitrary = liftA2 (:|) arbitrary arbitrary
274 arbitrary = liftA2 (:|) arbitrary arbitrary
273 shrink (x :| xs) = mapMaybe nonEmpty (shrink (x:xs))
275 shrink (x :| xs) = mapMaybe nonEmpty (shrink (x:xs))
274#endif
276#endif
277+
278+-}