Last active
August 29, 2015 13:56
-
-
Save vasily-kirichenko/8840989 to your computer and use it in GitHub Desktop.
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
open FsCheck | |
type Tree<'a> = | |
| Branch of 'a * Tree<'a> * Tree<'a> | |
| Empty | |
let associativity (x: Tree<int>, F(_, f: Tree<int> -> float), F(_, g: float -> char), F(_, h: char -> int)) = | |
((f >> g) >> h) x = (f >> (g >> h)) x + 1 // let it fail | |
Check.Quick associativity | |
// Falsifiable, after 1 test (4 shrinks) (StdGen (1177772306,295822005)): | |
// (Empty, { Branch (0,Empty,Empty)->2.0; Empty->2.0 }, { 2.0->'a' }, { 'a'->0 }) | |
// Translated from http://hackage.haskell.org/package/QuickCheck-2.4.1.1/docs/Test-QuickCheck-Function.html | |
let prop (F (_, f)) = f "monkey" = f "banana" || f "banana" = f "elephant" | |
// val prop : Function<string,'a> -> bool when 'a : equality | |
Check.Verbose prop | |
// ... | |
// 97: | |
// { "banana"->"*B_NUwC9"; "monkey"->"*B_NUwC9" } | |
// 98: | |
// { "banana"->false; "monkey"->false } | |
// 99: | |
// { "banana"->'o'; "monkey"->'o' } | |
// Ok, passed 100 tests. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
wait, wasn't the monkey-banana-elephant property supposed to be falsified?