-
Notifications
You must be signed in to change notification settings - Fork 847
Description
I noticed this while writing property tests with FsCheck.Xunit.
Let's say you're writing a simple property test like this:
[<Property>]
let fact seed =
let rng = Random seed
let a = rng.Next() % 2 = 0
let b = rng.Next() % 2 = 0
a && b
You cannot step or put a breakpoint on the last line (which would be nice, because you'd like to know for which reason the test is failing). This is especially annoying because Visual Studio will let you put the breakpoint, but then when you start debugging, strange things can happen like the debugger never actually breaking inside your code, or in my case, the test runner failing with cryptic errors. Wasted a lot of time figuring out what was actually going on yesterday.
A simple workaround is to bind the expression to a local and return that instead:
[<Property>]
let fact seed =
let rng = Random seed
let a = rng.Next() % 2 = 0
let b = rng.Next() % 2 = 0
let result = a && b
result
But I think the the compiler should do the work for me.
Tested on Visual Studio 2015 Enterprise Update 3.