Warum wird meine Vorbedingung bei meinem eigenschaftsbasierten Test ignoriert?Warum wird meine Vorbedingung bei meinem eigenschaftsbasierten Test ignoriert?
Voraussetzung für meinen Test ist die folgende:
fun rowCount -> rowCount >= 0
So meine eigentliche Test ist:
[<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
jedoch weiterhin meine Prüfung nicht bestanden:
Result Message: System.Exception : Falsifiable, after 3 tests (1 shrink) (StdGen (985619705,296133555)): Original: 1 -1 Shrunk: 0 -1
Domain:
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]
ich auch versucht habe:
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``
Allerdings habe ich die folgende Fehlermeldung:
Type mismatch. Expecting a Property -> 'a but given a int -> Map<(int * int),Cell> The type 'Property' does not match the type 'int'
Ihr Eigentum nimmt _two_ Argumente - 'rowCount' und zweiten' rowCount', - nicht ein. –
Ich bin verwirrt: Lassen Sie '' einige Eigenschaft'' rowCount = ... –