Skip to content

Instantly share code, notes, and snippets.

@gilles-leblanc
Created March 2, 2016 00:20
Show Gist options
  • Save gilles-leblanc/003b1b9857f082b6c297 to your computer and use it in GitHub Desktop.
Save gilles-leblanc/003b1b9857f082b6c297 to your computer and use it in GitHub Desktop.
fsharp tests
module Tests
// modules under test
open HeightMap
open MidpointDisplacement
// assert functions
let assertAreEqual expected actual =
if expected <> actual then
sprintf "Test failed, expected %A, actual %A" expected, actual
else
"Test passed"
// tests included in run
let testsToRun =
[
"test newHeightMap will return a 0 initialized height map",
fun() ->
let hm = newHeightMap 5
let result = hm.Map |> Array.sum
assertAreEqual 0.0 result
]
// test runner
let runSingleTest (testName, testFunction) =
sprintf "%s... %s" testName, testFunction()
let runTests testList =
testList |> List.map runSingleTest
printfn "%s" "Ran all tests."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment