From 94615125a48f046df5a88aa11433393506ba9252 Mon Sep 17 00:00:00 2001 From: Maximilian Algehed Date: Tue, 29 Oct 2024 14:43:19 +0100 Subject: [PATCH] `constrained-generators`: fix flaky test --- libs/constrained-generators/src/Constrained/Base.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/constrained-generators/src/Constrained/Base.hs b/libs/constrained-generators/src/Constrained/Base.hs index ffe12891160..a7d39bfa157 100644 --- a/libs/constrained-generators/src/Constrained/Base.hs +++ b/libs/constrained-generators/src/Constrained/Base.hs @@ -3354,14 +3354,18 @@ genFromFold (nub -> must) (simplifySpec -> size) elemS fn foldS = let elemS' = mapSpec fn elemS mustVal = adds @fn (map (sem fn) must) foldS' = propagateSpecFun (theAddFn @fn) (HOLE :? Value mustVal :> Nil) foldS + sizeSpec' = propagateSpecFun (addFn @fn) (HOLE :? Value (sizeOf must) :> Nil) size m <- getMode + when (isErrorLike sizeSpec') $ genError1 "Inconsistent size spec" results0 <- withMode Loose $ ( withMode m $ + -- TODO: this is not the best solution to this problem, we need + -- to use the size information in `genList` instead suchThatWithTryT - 1000 + 10 (genList (simplifySpec elemS') (simplifySpec foldS')) - (\xs -> (sizeOf must + sizeOf xs) `conformsToSpec` size) + (\xs -> sizeOf xs `conformsToSpec` sizeSpec') ) results <- explain