未调用 FSCheck 压缩器

FSCheck shrinker isn't called

我似乎无法让 FSCheck 收缩器工作。说我有这个

    let arb_chars =
        Arb.fromGenShrink(
            Arb.generate<char[]>,
            fun cs -> seq {
                printfn "shrinking..."
                for i in 0..(cs.Length) do
                    printfn "  shrink %d" i
                    yield [| cs.[0] |]
            })

    let prop_len() = gen {
        //let! a = Arb.generate<char[]> // this doesn't work either...
        let! a = arb_chars.Generator
        let len = a.Length
        printfn "a.Length = %A" len
        return (len <> 5)
    }
    :
    Check.One(config, prop_len)

当我 运行 它时,我总是得到 0 收缩。这是一个典型的 运行:

a.Length = 0
a.Length = 4
a.Length = 1
a.Length = 0
a.Length = 4
a.Length = 7
a.Length = 6
a.Length = 7
a.Length = 19
a.Length = 18
a.Length = 5
Falsifiable, after 11 tests (0 shrinks) (StdGen (19971972,296557937)):
Original:
<null>

使用 Prop.ForAll 定义您的 属性 并使用自定义 generator/shrinker。类似这样的东西(抱歉凭记忆打字,但应该很接近)

let prop_len = Prop.ForAll (arb_chars) 
    (fun a ->
        let len = a.Length
        printfn "a.Length = %A" len
        return (len <> 5)
    )