elm-test icon indicating copy to clipboard operation
elm-test copied to clipboard

List shrinking not aggresive enough

Open zkessin opened this issue 8 years ago • 5 comments

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)]

zkessin avatar Feb 01 '17 08:02 zkessin

Can you see if this reproduces with the patch in #118 applied?

mgold avatar Feb 01 '17 17:02 mgold

sure I will try that later today

zkessin avatar Feb 02 '17 10:02 zkessin

@zkessin how did it go?

drathier avatar Jul 30 '17 23:07 drathier

I don't think I ever did that test, and I am no longer working with that project.

zkessin avatar Jul 31 '17 08:07 zkessin

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.

drathier avatar Jul 31 '17 09:07 drathier