elm-test
elm-test copied to clipboard
List shrinking not aggresive enough
Given this test I am getting a failure (see bellow) which could be shrunk more, It shrinks to 11 element in the array, but it would be better if it could shrink it down to just the two elements that are causing the error.
I included the code and test here as well as the test run output
sortAsNumber : List (String, Int) -> List (String, Int)
sortAsNumber elements =
let
sortFun (a,acount) (b,bcount) =
case (String.toFloat a, String.toFloat b) of
(Ok anum, Ok bnum) ->
compare (anum, acount) (bnum,bcount)
(Ok _, Err _) ->
LT
(Err _, Ok _ ) ->
GT
(Err _,Err _) ->
compare (a,acount) (b,bcount)
in
List.sortWith sortFun elements
propSortAsNumber : Test
propSortAsNumber =
let
key = frequencyOrCrash[(1.0, string)
,( 1.0, Fuzz.map toString int)
,( 1.0, Fuzz.map toString float)
]
listGen = (key, intRange 0 9999)
|> tuple
|> list
in
fuzz listGen "List of kv Pairs"
<| \l ->
let
sorted = Boxes.sortAsNumber l
in
Expect.equalLists sorted <| Boxes.sortAsNumber sorted
↓ Sample Test Suite
↓ Boxes Tests
✗ List of kv Pairs
Given [("",0),("0",0),("0",0),("0.000001",0),("",0),("0.000001",0),("0",0),("",0),("+0",0),("0.000001",0),("",0)]
[("0",0),("0",0),("+0",0),("0",0),("0.000001",0),("0.000001",0),("0.000001",0),("",0),("",0),("",0),("",0)]
first diff at index index 2: +`("+0",0)`, -`("0",0)`
╷
│ Expect.equalLists
╵
first diff at index index 2: +`("0",0)`, -`("+0",0)`
[("0",0),("0",0),("0",0),("+0",0),("0.000001",0),("0.000001",0),("0.000001",0),("",0),("",0),("",0),("",0)]
Can you see if this reproduces with the patch in #118 applied?
sure I will try that later today
@zkessin how did it go?
I don't think I ever did that test, and I am no longer working with that project.
Could you try to reproduce it now? Otherwise, since there are no upvotes and no activity on this for the last 6 months, I say we close it. It's probably fixed by #118.