Skip to content

Instantly share code, notes, and snippets.

@Porges
Created January 22, 2015 04:08
Show Gist options
  • Save Porges/69dcf58d86c8b4c06f24 to your computer and use it in GitHub Desktop.
Save Porges/69dcf58d86c8b4c06f24 to your computer and use it in GitHub Desktop.
PowerAssert for F#
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