Skip to content

Instantly share code, notes, and snippets.

@artur-s
Created November 13, 2016 03:58
Show Gist options
  • Save artur-s/bf809bd978e2be8a4cbd427d39d785d6 to your computer and use it in GitHub Desktop.
Save artur-s/bf809bd978e2be8a4cbd427d39d785d6 to your computer and use it in GitHub Desktop.
FsCheck generator for positive decimals constrained to more realistic money amounts
open System
open FsCheck
let positiveDecimal = gen {
let! low = Gen.elements [0..1000]
let! mid = Gen.elements [0..100]
let! scale = Gen.elements [0..5]
return!
Gen.elements [
Decimal(low, mid, 0, false, byte scale)
Decimal(low, 0, 0, false, byte scale) ]
}
// positiveDecimal |> FsCheck.Gen.sample 0 50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment