Last active
April 27, 2016 05:29
-
-
Save Gab-km/6bb021cd177b2ed10ff94ab9cdfa0c08 to your computer and use it in GitHub Desktop.
例外が起こるかもしれないparameterizeなテスト
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
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