Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions test/Test/Property/TestListSet.flix
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,29 @@
mod JonathanStarup.Test.Property.TestListSet {
use JonathanStarup.ListSet
use JonathanStarup.Test.Property.ListSetGenerator
use Abort.abort

eff Crash {
pub def crash(msg: String): Void
}

def runCrash(f: Unit -> Unit \ ef): Bool \ ef + IO - Crash =
try {f(); true} with Crash {
def crash(msg, _) = {
def runCrash(f: Unit -> Unit \ ef): Bool \ ef + IO - Abort =
try {f(); true} with Abort {
def abort(msg, _) = {
println("Test failed: ${msg}");
false
}
}

def _assertEq(x: t, y: t): Unit \ Crash with Eq[t], ToString[t] = {
def _assertEq(x: t, y: t): Unit \ Abort with Eq[t], ToString[t] = {
if (x == y) ()
else Crash.crash("${x} != ${y}")
else abort("${x} != ${y}")
}

def assertExpect(expect: {expect = t}, actual: t): Unit \ Crash with Eq[t], ToString[t] = {
def assertExpect(expect: {expect = t}, actual: t): Unit \ Abort with Eq[t], ToString[t] = {
if (expect#expect == actual) ()
else Crash.crash("found ${actual} but expected ${expect#expect}")
else abort("found ${actual} but expected ${expect#expect}")
}

def runTest(
tests: Int32, seed: Int64, prop: c -> Unit \ Crash
): Bool \ IO + (Collectable.Aef[c] - Crash - Random)
tests: Int32, seed: Int64, prop: c -> Unit \ Abort
): Bool \ IO + (Collectable.Aef[c] - Abort - Random)
with Collectable[c] where Collectable.Elm[c] ~ Int32 = region local {
let f = () ->
ListSetGenerator.randomIterator(local, tests) |>
Expand Down
Loading