为什么我的前提正在于我的基于属性的测试忽略?
我测试的前提是以下几点:
fun rowCount -> rowCount >= 0
因此,我的实际测试:
[<Fact>]
let ``number of cells in grid equals rowcount squared`` () =
Check.QuickThrowOnFailure <|
fun rowCount -> rowCount >= 0 ==>
fun rowCount -> rowCount |> createGrid
|> Map.toList
|> List.length = rowCount * rowCount
但是,我的测试仍然失败:
结果消息:System.Exception的:证伪,经过3个试验(1个收缩)(StdGen(985619705,296133555)):原文:1个-1缩水:0 -1
域:
let createGrid rowCount =
[for x in 0..rowCount-1 do
for y in 0..rowCount-1 do
yield { X=x; Y=y; State=Dead }
]|> List.map (fun c -> (c.X, c.Y), { X=c.X; Y=c.Y; State=Dead })
|> Map.ofList
[UPDATE]
我也试过:
let precondition rowCount =
rowCount >= 0
let ``some property`` rowCount =
precondition rowCount ==> rowCount |> createGrid
|> Map.toList
|> List.length = rowCount * rowCount
[<Fact>]
let ``number of cells in grid equals rowcount squared`` () =
Check.QuickThrowOnFailure <| ``some property``
不过,我收到以下错误:
类型不匹配。 期待一个属性 - >“一但给定一个INT - >地图<(INT * INT),细胞>类型‘属性’不匹配的类型‘INT’