Unquote
There is another F# assertion library that is completely different from FsUnit but with different design philosophies accomplishes the same thing, by making F# unit tests more functional. Just like FsUnit, this library provides the means of writing assertions, but relies on NUnit as a testing framework.
Instead of working with a DSL like FsUnit or API such as with the NUnit framework, the Unquote library assertions are based on F# code quotations.
Code quotations is a quite unknown feature of F# where you can turn any code into an abstract syntax tree. Namely, when the F# compiler finds a code quotation in your source file, it will not compile it, but rather expand it into a syntax tree that represents an F# expression.
The following is an example of a code quotation:
<@ 1 + 1 @>
If we execute this in F# Interactive, we'll get the following output:
val it : Quotations.Expr = Call (None, op_Addition, [Value (1), Value (1)])
This is truly code as data, and we can use it to...