Pourquoi ma condition préalable est-elle ignorée dans mon test basé sur la propriété?Pourquoi ma condition préalable est-elle ignorée dans mon test basé sur la propriété?
La condition sine qua non pour mon test est la suivante:
fun rowCount -> rowCount >= 0
Ainsi, mon test réel est:
[<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
Cependant, mon test échoue:
Result Message: System.Exception : Falsifiable, after 3 tests (1 shrink) (StdGen (985619705,296133555)): Original: 1 -1 Shrunk: 0 -1
Domaine:
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]
J'ai aussi essayé:
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``
Cependant, je reçois l'erreur suivante:
Type mismatch. Expecting a Property -> 'a but given a int -> Map<(int * int),Cell> The type 'Property' does not match the type 'int'
Votre propriété prend _two_ arguments - '' rowCount' et seconde rowCount', - pas. –
Je suis confus: laissez '' some property'' rowCount = ... –