Skip to content

Commit

Permalink
More set tests
Browse files Browse the repository at this point in the history
Summary:
I've added sets to the test predicate in our test DB.
That in itself is a good test and found a couple of bugs.

I've also added a test.

Also added a round-tripping test to exercise the JSON encoding.

Reviewed By: simonmar

Differential Revision: D63611597

fbshipit-source-id: cdaf19383fdfc72f3290d51b8c6c5c88a95e48cb
  • Loading branch information
Josef Svenningsson authored and facebook-github-bot committed Nov 14, 2024
1 parent d41b9e6 commit 1ab3307
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions common/util/Util/Testing.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
{-# LANGUAGE NamedFieldPuns #-}
module Util.Testing
( assertProperty
, assertPropertyWithArgs
, QC.stdArgs
, QC.Args(..)
, skip
, skipTest
, skipTestIf
Expand Down Expand Up @@ -44,12 +47,17 @@ skipTestIfRtsIsProfiled = skipTestIf $ const (rtsIsProfiled /= 0)

assertProperty
:: (HasCallStack, QC.Testable prop) => String -> prop -> Assertion
assertProperty msg prop = do
size <- maybe (QC.maxSize QC.stdArgs) read <$> lookupEnv "QUICKCHECK_SIZE"
assertProperty msg prop =
assertPropertyWithArgs msg QC.stdArgs prop

assertPropertyWithArgs
:: (HasCallStack, QC.Testable prop) => String -> QC.Args -> prop -> Assertion
assertPropertyWithArgs msg qcArgs prop = do
size <- maybe (QC.maxSize qcArgs) read <$> lookupEnv "QUICKCHECK_SIZE"
success <-
maybe (QC.maxSuccess QC.stdArgs )read <$> lookupEnv "QUICKCHECK_RUNS"
maybe (QC.maxSuccess qcArgs) read <$> lookupEnv "QUICKCHECK_RUNS"
mbSeed <- lookupEnv "QUICKCHECK_SEED"
let args = QC.stdArgs {
let args = qcArgs {
QC.maxSize = size,
QC.maxSuccess = success,
QC.replay = (,size) . read <$> mbSeed
Expand Down

0 comments on commit 1ab3307

Please sign in to comment.