Skip to content

Commit 8d128b9

Browse files
committed
fix
1 parent 7807302 commit 8d128b9

1 file changed

Lines changed: 19 additions & 18 deletions

File tree

test/Test/Property/TestListSet.flix

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,40 @@
1717
mod JonathanStarup.Test.Property.TestListSet {
1818
use JonathanStarup.ListSet
1919
use JonathanStarup.Test.Property.ListSetGenerator
20+
use Abort.abort
21+
22+
def runTest(
23+
tests: Int32, seed: Int64, prop: c -> Unit \ Assert
24+
): Unit \ Assert + (Collectable.Aef[c] - Random)
25+
with Collectable[c] where Collectable.Elm[c] ~ Int32 = region local {
26+
let f = () ->
27+
ListSetGenerator.randomIterator(local, tests) |>
28+
Iterator.forEach(prop);
29+
Random.runWithSeed(seed, f)
30+
}
2031

2132
@Test
22-
pub def testEmpty(): Unit \ Assert = region local {
33+
pub def testEmpty(): Unit \ Assert = {
2334
def prop(l) = {
2435
let expectedLength = List.isEmpty(l);
2536
let s = ListSet.fromIterable(l);
26-
if (expectedLength) Assert.assertTrue(ListSet.isEmpty(s))
27-
else Assert.assertFalse(ListSet.isEmpty(s))
37+
ListSet.isEmpty(s) |> Assert.assertEq(expected = expectedLength)
2838
};
29-
Random.runWithSeed(8168590i64, () -> {
30-
ListSetGenerator.randomIterator(local, 100) |>
31-
Iterator.forEach(prop)
32-
})
39+
prop |> runTest(100, 8168590i64)
3340
}
3441

3542
@Test
36-
pub def testSize(): Unit \ Assert = region local {
43+
pub def testSize(): Unit \ Assert = {
3744
def prop(l) = {
3845
let expectedLength = List.length(l);
3946
let s = ListSet.fromIterable(l);
40-
Assert.assertEq(expected = expectedLength, ListSet.size(s))
47+
ListSet.size(s) |> Assert.assertEq(expected = expectedLength)
4148
};
42-
Random.runWithSeed(578956838i64, () -> {
43-
ListSetGenerator.randomIterator(local, 10_000) |>
44-
Iterator.forEach(prop)
45-
})
49+
prop |> runTest(10_000, 578956838i64)
4650
}
4751

4852
@Test
49-
pub def testInsertRedundant(): Unit \ Assert = region local {
53+
pub def testInsertRedundant(): Unit \ Assert = {
5054
def prop(l) = {
5155
let s1 = ListSet.fromIterable(l);
5256
let s2 = l |>
@@ -55,10 +59,7 @@ mod JonathanStarup.Test.Property.TestListSet {
5559
Option.getWithDefault(s1);
5660
Assert.assertEq(expected = s1, s2)
5761
};
58-
Random.runWithSeed(-6859625i64, () -> {
59-
ListSetGenerator.randomIterator(local, 1_000) |>
60-
Iterator.forEach(prop)
61-
})
62+
prop |> runTest(1_000, -6859625i64)
6263
}
6364

6465
}

0 commit comments

Comments
 (0)