diff options
| author | Tom Smeding <tom@tomsmeding.com> | 2025-03-27 12:53:26 +0100 | 
|---|---|---|
| committer | Tom Smeding <tom@tomsmeding.com> | 2025-03-27 12:53:26 +0100 | 
| commit | 99241c7e763b46f1ea079679ec8ac83d1ea67cea (patch) | |
| tree | 903bba9e0e5b54d368e9cb42290256f94b60322f /test | |
| parent | cfe2aad01ceab3698755162a1d48a2dd8f882b19 (diff) | |
test: Respect shape lower bounds better
Diffstat (limited to 'test')
| -rw-r--r-- | test/Main.hs | 11 | 
1 files changed, 6 insertions, 5 deletions
| diff --git a/test/Main.hs b/test/Main.hs index cc17b5d..d4a835f 100644 --- a/test/Main.hs +++ b/test/Main.hs @@ -164,7 +164,7 @@ genShape = \n tpl -> do    sh <- genShapeNaive n tpl    let sz = shapeSize sh        factor = sz `div` 100 + 1 -  return (shapeDiv sh factor) +  return (shapeDiv sh tpl factor)    where      genShapeNaive :: SNat n -> DimNames n -> StateT (Map String Int) Gen (Shape n)      genShapeNaive SZ () = return ShNil @@ -181,11 +181,12 @@ genShape = \n tpl -> do        Just dim -> return dim      genDim :: Int -> StateT (Map String Int) Gen Int -    genDim lo = Gen.integral (Range.linear lo 10) +    genDim lo = Gen.integral (Range.linear lo (lo+10)) -    shapeDiv :: Shape n -> Int -> Shape n -    shapeDiv ShNil _ = ShNil -    shapeDiv (sh `ShCons` n) f = shapeDiv sh f `ShCons` (n `div` f) +    shapeDiv :: Shape n -> DimNames n -> Int -> Shape n +    shapeDiv ShNil _ _ = ShNil +    shapeDiv (ShNil `ShCons` n) (C _ lo) f = ShNil `ShCons` (max lo (n `div` f)) +    shapeDiv (sh@ShCons{} `ShCons` n) (tpl :$ C _ lo) f = shapeDiv sh tpl f `ShCons` (max lo (n `div` f))  genArray :: STy a -> Shape n -> Gen (Value (TArr n a))  genArray t sh = | 
