Skip to content

Instantly share code, notes, and snippets.

Last active September 15, 2021 11:55
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
FsCheck v3 breaking API, how to use in F#
#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 =
| 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