1
exercism fetch sml raindrops

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
(* version 1.0.0 *)

use "testlib.sml";
use "raindrops.sml";

infixr |>
fun x |> f = f x

val testsuite =
  describe "raindrops" [
    test "the sound for 1 is 1"
      (fn _ => convert (1) |> Expect.equalTo "1"),

    test "the sound for 3 is Pling"
      (fn _ => convert (3) |> Expect.equalTo "Pling"),

    test "the sound for 5 is Plang"
      (fn _ => convert (5) |> Expect.equalTo "Plang"),

    test "the sound for 7 is Plong"
      (fn _ => convert (7) |> Expect.equalTo "Plong"),

    test "the sound for 6 is Pling as it has a factor 3"
      (fn _ => convert (6) |> Expect.equalTo "Pling"),

    test "2 to the power 3 does not make a raindrop sound as 3 is the exponent not the base"
      (fn _ => convert (8) |> Expect.equalTo "8"),

    test "the sound for 9 is Pling as it has a factor 3"
      (fn _ => convert (9) |> Expect.equalTo "Pling"),

    test "the sound for 10 is Plang as it has a factor 5"
      (fn _ => convert (10) |> Expect.equalTo "Plang"),

    test "the sound for 14 is Plong as it has a factor of 7"
      (fn _ => convert (14) |> Expect.equalTo "Plong"),

    test "the sound for 15 is PlingPlang as it has factors 3 and 5"
      (fn _ => convert (15) |> Expect.equalTo "PlingPlang"),

    test "the sound for 21 is PlingPlong as it has factors 3 and 7"
      (fn _ => convert (21) |> Expect.equalTo "PlingPlong"),

    test "the sound for 25 is Plang as it has a factor 5"
      (fn _ => convert (25) |> Expect.equalTo "Plang"),

    test "the sound for 27 is Pling as it has a factor 3"
      (fn _ => convert (27) |> Expect.equalTo "Pling"),

    test "the sound for 35 is PlangPlong as it has factors 5 and 7"
      (fn _ => convert (35) |> Expect.equalTo "PlangPlong"),

    test "the sound for 49 is Plong as it has a factor 7"
      (fn _ => convert (49) |> Expect.equalTo "Plong"),

    test "the sound for 52 is 52"
      (fn _ => convert (52) |> Expect.equalTo "52"),

    test "the sound for 105 is PlingPlangPlong as it has factors 3, 5 and 7"
      (fn _ => convert (105) |> Expect.equalTo "PlingPlangPlong"),

    test "the sound for 3125 is Plang as it has a factor 5"
      (fn _ => convert (3125) |> Expect.equalTo "Plang")
  ]

val _ = Test.run testsuite