Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // In this example, we're using FsCheck in an unorthodox way.
- // Typically you tell FsCheck to look for something that violates
- // your rule. Here, we're reappropriating FsCheck's fuzz testing
- // capabilities to enumerate everything that has been deemed
- // "valid" to see if it's actually valid to help us figure out the rules.
- type Money = decimal
- type CouponType = FreeMail | FreeSide
- type PaymentOption =
- | Cash of Amount:Money
- | Coupon of CouponType
- | Credit of Amount:Money * CardNumber:string * Expiration:string
- | GiftCard of Amount:Money * Balance:Money * CardNumber:Guid
- // We'll first assume everything is valid
- let isValidPayment(paymentType:PaymentOption) = true
- // We pass this function to tell FsCheck everything is valid
- // so it keeps throwing data at us. We only print the ones that
- // we've deemed valid.
- let showValidPayment(paymentType) =
- if isValidPayment(paymentType) then
- printfn "%A" paymentType
- true
- FsCheck.Check.Quick(showValidPayment)
Add Comment
Please, Sign In to add comment