@@ -11,7 +11,7 @@ import Data.String (IsString, fromString)
1111import qualified Data.Text as T
1212import qualified Data.Text.Lazy as TL
1313import System.Random (Random(..), RandomGen)
14−import Test.QuickCheck (Gen, Arbitrary(..), choose, sized, vector, oneof)
14+import Test.QuickCheck hiding ((.&.))
1515import qualified Data.ByteString as B
1616
1717instance Random Int64 where
@@ -98,6 +98,12 @@ genUnicode = fmap fromString string where
9898instance Arbitrary T.Text where
9999 arbitrary = T.pack `fmap` arbitrary
100100
101+-- For tests that have O(n^2) running times or input sizes, resize
102+-- their inputs to the square root of the originals.
103+unsquare :: (Arbitrary a, Show a, Testable b) => (a -> b) -> Property
104+unsquare = forAll . sized $ \n -> resize (smallish n) arbitrary
105+ where smallish = round . (sqrt :: Double -> Double) . fromIntegral
106+
101107instance Arbitrary TL.Text where
102108 arbitrary = (TL.fromChunks . map notEmpty) `fmap` arbitrary
103109