Created
January 22, 2015 04:08
-
-
Save Porges/69dcf58d86c8b4c06f24 to your computer and use it in GitHub Desktop.
PowerAssert for F#
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 System | |
open System.Linq.Expressions | |
open Microsoft.FSharp.Quotations | |
open FSharp.Quotations.Evaluator | |
let toLinq (expr : Expr<bool>) = | |
let linq = expr.ToLinqExpressionUntyped() | |
let call = linq :?> Expression<Func<unit, bool>> | |
Expression.Lambda(call.Body) :?> Expression<Func<bool>> | |
let passert f = PowerAssert.PAssert.IsTrue (toLinq f) | |
[<EntryPoint>] | |
let main argv = | |
passert <@ 1 = 2 @> | |
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment