FsCheck v3 breaking API, how to use in F#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "nuget: FsCheck, version=3.0.0-beta1" | |
open FsCheck | |
open FsCheck.FSharp | |
let revRev xs = xs |> List.rev |> List.rev = xs | |
Check.QuickThrowOnFailure revRev | |
type Tree<'a> = Branch of Tree<'a> * Tree<'a> | Leaf of 'a | |
let rec reverse = | |
function | |
| Leaf x -> Leaf x | |
| Branch (l,r) -> Branch (reverse r, reverse l) | |
let revRevTree t = t |> reverse |> reverse = t | |
Check.QuickThrowOnFailure revRevTree | |
//So how do you provide catered data in the form of Gen and Arb? | |
let evens = | |
[for x in [1..100] do if x % 2 = 0 then yield x] | |
|> Gen.elements | |
|> Arb.fromGen | |
let isEven n = n % 2 = 0 | |
let allEvensAreEven = Prop.forAll evens isEven | |
Check.QuickThrowOnFailure allEvensAreEven |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment