1
exercism fetch sml nth-prime

test.sml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(* version 1.0.0 *)

use "testlib.sml";
use "nth-prime.sml";

infixr |>
fun x |> f = f x

val testsuite =
  describe "nth-prime" [
    test "first prime"
      (fn _ => nthPrime 1 |> Expect.equalTo 2),

    test "second prime"
      (fn _ => nthPrime 2 |> Expect.equalTo 3),

    test "sixth prime"
      (fn _ => nthPrime 6 |> Expect.equalTo 13),

    test "big prime"
      (fn _ => nthPrime 10001 |> Expect.equalTo 104743),

    test "there is no zeroth prime"
      (fn _ => (fn _ => nthPrime 0) |> Expect.error Domain)
  ]

val _ = Test.run testsuite