Created
July 22, 2014 04:21
-
-
Save dtchepak/62fe3c689700180777c2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module DaveSquared.Sample | |
open Xunit | |
let incr x = x+1 | |
// Test using Unquote | |
open Swensen.Unquote | |
[<Fact>] | |
let ``map (+1) over list using Unquote`` () = | |
test <@ List.map incr [1;2;3] = [2;3;4] @> | |
// Test using Xunit assertions (or use FsUnit.Xunit for more F#y syntax) | |
open Xunit | |
[<Fact>] | |
let ``map (+1) over list using Xunit`` () = | |
let result = List.map incr [1;2;3] | |
Assert.Equal<int list>([2;3;4], result) | |
// Test using FsUnit.Xunit assertions | |
open FsUnit.Xunit | |
[<Fact>] | |
let ``map (+1) over list using FsUnit.Xunit`` () = | |
let result = List.map incr [1;2;3] | |
result |> should equal [2;3;4] | |
// Test properties | |
open FsCheck | |
open FsCheck.Xunit | |
[<Property>] | |
let ``map f . map g = map (f . g)`` (xs:int list) = | |
let f x = x*10 | |
let g x = x+1 | |
(List.map f << List.map g) xs = List.map (f << g) xs | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment