Skip to content

Commit 1bbb9cc

Browse files
committed
Issue #755: add a regression test
1 parent 2e7635c commit 1bbb9cc

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test-prototypes/Test/ScheduledMergesQLS.hs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
module Test.ScheduledMergesQLS (tests) where
77

8+
import Control.Monad (void)
89
import Control.Monad.ST
910
import Control.Tracer (Tracer, nullTracer)
1011
import Data.Constraint (Dict (..))
@@ -18,18 +19,44 @@ import Prelude hiding (lookup)
1819
import ScheduledMerges as LSM
1920

2021
import Test.QuickCheck
22+
import qualified Test.QuickCheck.DynamicLogic as DL
2123
import Test.QuickCheck.StateModel hiding (lookUpVar)
2224
import Test.QuickCheck.StateModel.Lockstep hiding (ModelOp)
2325
import qualified Test.QuickCheck.StateModel.Lockstep.Defaults as Lockstep
26+
import Test.QuickCheck.StateModel.Lockstep.Op.Identity (Op (OpId))
2427
import qualified Test.QuickCheck.StateModel.Lockstep.Run as Lockstep
2528
import Test.Tasty
2629
import Test.Tasty.QuickCheck (testProperty)
2730

2831
tests :: TestTree
2932
tests = testGroup "Test.ScheduledMergesQLS" [
3033
testProperty "ScheduledMerges vs model" $ mapSize (*10) prop_LSM -- still <10s
34+
, testProperty "propRegression_issue755" $
35+
let scenario = do
36+
var1 <- DL.action $ ANew (LSMConfig {configMaxWriteBufferSize = 1, configSizeRatio = 2})
37+
void $ DL.action $ AInsert (unsafeMkGVar var1 OpId) (Right (K 0)) (V 0) Nothing
38+
var16 <- DL.action $ AUnions [unsafeMkGVar var1 OpId]
39+
void $ DL.action $ AInsert (unsafeMkGVar var16 OpId) (Right (K 0)) (V 0) Nothing
40+
void $ DL.action $ AInsert (unsafeMkGVar var16 OpId) (Right (K 1)) (V 0) Nothing
41+
void $ DL.action $ AInsert (unsafeMkGVar var16 OpId) (Right (K 0)) (V 0) Nothing
42+
void $ DL.action $ AInsert (unsafeMkGVar var16 OpId) (Right (K 0)) (V 0) Nothing
43+
void $ DL.action $ AInsert (unsafeMkGVar var16 OpId) (Right (K 1)) (V 0) Nothing
44+
void $ DL.action $ AInsert (unsafeMkGVar var16 OpId) (Right (K 2)) (V 0) Nothing
45+
void $ DL.action $ AInsert (unsafeMkGVar var16 OpId) (Right (K 0)) (V 0) Nothing
46+
void $ DL.action $ AInsert (unsafeMkGVar var16 OpId) (Right (K 0)) (V 0) Nothing
47+
void $ DL.action $ AInsert (unsafeMkGVar var16 OpId) (Right (K 0)) (V 0) Nothing
48+
in DL.forAllDL scenario prop_LSM
49+
{-
50+
The scenario above is a manually modified version of output produced by:
51+
52+
cabal run prototypes-test -- \
53+
--quickcheck-replay="(SMGen 3702524042292853426 14344574976030159473,92)" \
54+
-p '/ScheduledMerges vs model/'
55+
-}
3156
]
3257

58+
instance DL.DynLogicModel (Lockstep Model) where
59+
3360
-- TODO: add tagging, e.g. how often ASupplyUnion makes progress or completes a
3461
-- union merge.
3562
prop_LSM :: Actions (Lockstep Model) -> Property

0 commit comments

Comments
 (0)