Skip to content

Commit

Permalink
Sync roman-numerals exercise (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
keiravillekode authored Dec 23, 2023
1 parent 7fd8d25 commit 2bbc012
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 21 deletions.
2 changes: 1 addition & 1 deletion exercises/practice/roman-numerals/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ In Roman numerals 1990 is MCMXC:
2000=MM
8=VIII

Learn more about [Roman numberals on Wikipedia][roman-numerals].
Learn more about [Roman numerals on Wikipedia][roman-numerals].

[roman-numerals]: https://wiki.imperivm-romanvm.com/wiki/Roman_Numerals
21 changes: 21 additions & 0 deletions exercises/practice/roman-numerals/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ description = "6 is VI"
[ff3fb08c-4917-4aab-9f4e-d663491d083d]
description = "9 is IX"

[6d1d82d5-bf3e-48af-9139-87d7165ed509]
description = "16 is XVI"

[2bda64ca-7d28-4c56-b08d-16ce65716cf6]
description = "27 is XXVII"

Expand All @@ -42,6 +45,9 @@ description = "49 is XLIX"
[d5b283d4-455d-4e68-aacf-add6c4b51915]
description = "59 is LIX"

[4465ffd5-34dc-44f3-ada5-56f5007b6dad]
description = "66 is LXVI"

[46b46e5b-24da-4180-bfe2-2ef30b39d0d0]
description = "93 is XCIII"

Expand All @@ -51,17 +57,32 @@ description = "141 is CXLI"
[267f0207-3c55-459a-b81d-67cec7a46ed9]
description = "163 is CLXIII"

[902ad132-0b4d-40e3-8597-ba5ed611dd8d]
description = "166 is CLXVI"

[cdb06885-4485-4d71-8bfb-c9d0f496b404]
description = "402 is CDII"

[6b71841d-13b2-46b4-ba97-dec28133ea80]
description = "575 is DLXXV"

[dacb84b9-ea1c-4a61-acbb-ce6b36674906]
description = "666 is DCLXVI"

[432de891-7fd6-4748-a7f6-156082eeca2f]
description = "911 is CMXI"

[e6de6d24-f668-41c0-88d7-889c0254d173]
description = "1024 is MXXIV"

[efbe1d6a-9f98-4eb5-82bc-72753e3ac328]
description = "1666 is MDCLXVI"

[bb550038-d4eb-4be2-a9ce-f21961ac3bc6]
description = "3000 is MMM"

[3bc4b41c-c2e6-49d9-9142-420691504336]
description = "3001 is MMMI"

[4e18e96b-5fbb-43df-a91b-9cb511fe0856]
description = "3999 is MMMCMXCIX"
64 changes: 44 additions & 20 deletions exercises/practice/roman-numerals/test.sml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(* version 1.0.0 *)
(* version 1.1.0 *)

use "testlib.sml";
use "roman-numerals.sml";
Expand All @@ -8,59 +8,83 @@ fun x |> f = f x

val testsuite =
describe "roman-numerals" [
test "1 is a single I"
test "1 is I"
(fn _ => roman (1) |> Expect.equalTo "I"),

test "2 is two I's"
test "2 is II"
(fn _ => roman (2) |> Expect.equalTo "II"),

test "3 is three I's"
test "3 is III"
(fn _ => roman (3) |> Expect.equalTo "III"),

test "4, being 5 - 1, is IV"
test "4 is IV"
(fn _ => roman (4) |> Expect.equalTo "IV"),

test "5 is a single V"
test "5 is V"
(fn _ => roman (5) |> Expect.equalTo "V"),

test "6, being 5 + 1, is VI"
test "6 is VI"
(fn _ => roman (6) |> Expect.equalTo "VI"),

test "9, being 10 - 1, is IX"
test "9 is IX"
(fn _ => roman (9) |> Expect.equalTo "IX"),

test "20 is two X's"
test "16 is XVI"
(fn _ => roman (16) |> Expect.equalTo "XVI"),

test "27 is XXVII"
(fn _ => roman (27) |> Expect.equalTo "XXVII"),

test "48 is not 50 - 2 but rather 40 + 8"
test "48 is XLVIII"
(fn _ => roman (48) |> Expect.equalTo "XLVIII"),

test "50 is a single L"
test "49 is XLIX"
(fn _ => roman (49) |> Expect.equalTo "XLIX"),

test "59 is LIX"
(fn _ => roman (59) |> Expect.equalTo "LIX"),

test "90, being 100 - 10, is XC"
test "66 is LXVI"
(fn _ => roman (66) |> Expect.equalTo "LXVI"),

test "93 is XCIII"
(fn _ => roman (93) |> Expect.equalTo "XCIII"),

test "100 is a single C"
test "141 is CXLI"
(fn _ => roman (141) |> Expect.equalTo "CXLI"),

test "60, being 50 + 10, is LX"
test "163 is CLXIII"
(fn _ => roman (163) |> Expect.equalTo "CLXIII"),

test "400, being 500 - 100, is CD"
test "166 is CLXVI"
(fn _ => roman (166) |> Expect.equalTo "CLXVI"),

test "402 is CDII"
(fn _ => roman (402) |> Expect.equalTo "CDII"),

test "500 is a single D"
test "575 is DLXXV"
(fn _ => roman (575) |> Expect.equalTo "DLXXV"),

test "900, being 1000 - 100, is CM"
test "666 is DCLXVI"
(fn _ => roman (666) |> Expect.equalTo "DCLXVI"),

test "911 is CMXI"
(fn _ => roman (911) |> Expect.equalTo "CMXI"),

test "1000 is a single M"
test "1024 is MXXIV"
(fn _ => roman (1024) |> Expect.equalTo "MXXIV"),

test "3000 is three M's"
(fn _ => roman (3000) |> Expect.equalTo "MMM")
test "1666 is MDCLXVI"
(fn _ => roman (1666) |> Expect.equalTo "MDCLXVI"),

test "3000 is MMM"
(fn _ => roman (3000) |> Expect.equalTo "MMM"),

test "3001 is MMMI"
(fn _ => roman (3001) |> Expect.equalTo "MMMI"),

test "3999 is MMMCMXCIX"
(fn _ => roman (3999) |> Expect.equalTo "MMMCMXCIX")
]

val _ = Test.run testsuite

0 comments on commit 2bbc012

Please sign in to comment.