Skip to content

Instantly share code, notes, and snippets.

@Gab-km
Last active April 27, 2016 05:29
Show Gist options
  • Save Gab-km/6bb021cd177b2ed10ff94ab9cdfa0c08 to your computer and use it in GitHub Desktop.
Save Gab-km/6bb021cd177b2ed10ff94ab9cdfa0c08 to your computer and use it in GitHub Desktop.
例外が起こるかもしれないparameterizeなテスト
let catch (expr: Lazy<'T>) =
try
Choice2Of2(expr.Force())
with
| ex -> Choice1Of2(ex)
let parameterizedTest(input, expected) = test {
let actual = catch (Lazy.Create <| fun () -> fut input)
match (expected, actual) with
| (Choice1Of2 ex, Choice1Of2 ex') ->
do! assertEqual (ex.GetType()) (ex'.GetType())
| (Choice2Of2 value, Choice2Of2 value') ->
do! assertEqual value value'
| _ ->
let message = sprintf "Expect: %A\nActual: %A" expected actual
do! AssertionResult.NotPassed(NotPassedCause.Violated message)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment