From 6e2de43a3bd86c885a1d953e0e866d014c16e9be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20B=20Nagy?= <20251272+BNAndras@users.noreply.github.com> Date: Fri, 9 Jan 2026 20:28:06 -0800 Subject: [PATCH] Sync `forth` tests --- exercises/practice/forth/.meta/tests.toml | 18 ++++++++++++++ exercises/practice/forth/ForthTests.fs | 30 +++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/exercises/practice/forth/.meta/tests.toml b/exercises/practice/forth/.meta/tests.toml index c9c1d6377..d1e146a1e 100644 --- a/exercises/practice/forth/.meta/tests.toml +++ b/exercises/practice/forth/.meta/tests.toml @@ -24,6 +24,9 @@ description = "addition -> errors if there is nothing on the stack" [06efb9a4-817a-435e-b509-06166993c1b8] description = "addition -> errors if there is only one value on the stack" +[1e07a098-c5fa-4c66-97b2-3c81205dbc2f] +description = "addition -> more than two values on the stack" + [09687c99-7bbc-44af-8526-e402f997ccbf] description = "subtraction -> can subtract two numbers" @@ -33,6 +36,9 @@ description = "subtraction -> errors if there is nothing on the stack" [b3cee1b2-9159-418a-b00d-a1bb3765c23b] description = "subtraction -> errors if there is only one value on the stack" +[2c8cc5ed-da97-4cb1-8b98-fa7b526644f4] +description = "subtraction -> more than two values on the stack" + [5df0ceb5-922e-401f-974d-8287427dbf21] description = "multiplication -> can multiply two numbers" @@ -42,6 +48,9 @@ description = "multiplication -> errors if there is nothing on the stack" [8ba4b432-9f94-41e0-8fae-3b3712bd51b3] description = "multiplication -> errors if there is only one value on the stack" +[5cd085b5-deb1-43cc-9c17-6b1c38bc9970] +description = "multiplication -> more than two values on the stack" + [e74c2204-b057-4cff-9aa9-31c7c97a93f5] description = "division -> can divide two numbers" @@ -57,12 +66,21 @@ description = "division -> errors if there is nothing on the stack" [d5547f43-c2ff-4d5c-9cb0-2a4f6684c20d] description = "division -> errors if there is only one value on the stack" +[f224f3e0-b6b6-4864-81de-9769ecefa03f] +description = "division -> more than two values on the stack" + [ee28d729-6692-4a30-b9be-0d830c52a68c] description = "combined arithmetic -> addition and subtraction" [40b197da-fa4b-4aca-a50b-f000d19422c1] description = "combined arithmetic -> multiplication and division" +[f749b540-53aa-458e-87ec-a70797eddbcb] +description = "combined arithmetic -> multiplication and addition" + +[c8e5a4c2-f9bf-4805-9a35-3c3314e4989a] +description = "combined arithmetic -> addition and multiplication" + [c5758235-6eef-4bf6-ab62-c878e50b9957] description = "dup -> copies a value on the stack" diff --git a/exercises/practice/forth/ForthTests.fs b/exercises/practice/forth/ForthTests.fs index 74cb32712..b0449e6a5 100644 --- a/exercises/practice/forth/ForthTests.fs +++ b/exercises/practice/forth/ForthTests.fs @@ -30,6 +30,11 @@ let ``Addition - errors if there is only one value on the stack`` () = let expected = None evaluate ["1 +"] |> should equal expected +[] +let ``Addition - more than two values on the stack`` () = + let expected = Some [1; 5] + evaluate ["1 2 3 +"] |> should equal expected + [] let ``Subtraction - can subtract two numbers`` () = let expected = Some [-1] @@ -45,6 +50,11 @@ let ``Subtraction - errors if there is only one value on the stack`` () = let expected = None evaluate ["1 -"] |> should equal expected +[] +let ``Subtraction - more than two values on the stack`` () = + let expected = Some [1; 9] + evaluate ["1 12 3 -"] |> should equal expected + [] let ``Multiplication - can multiply two numbers`` () = let expected = Some [8] @@ -60,6 +70,11 @@ let ``Multiplication - errors if there is only one value on the stack`` () = let expected = None evaluate ["1 *"] |> should equal expected +[] +let ``Multiplication - more than two values on the stack`` () = + let expected = Some [1; 6] + evaluate ["1 2 3 *"] |> should equal expected + [] let ``Division - can divide two numbers`` () = let expected = Some [4] @@ -85,6 +100,11 @@ let ``Division - errors if there is only one value on the stack`` () = let expected = None evaluate ["1 /"] |> should equal expected +[] +let ``Division - more than two values on the stack`` () = + let expected = Some [1; 4] + evaluate ["1 12 3 /"] |> should equal expected + [] let ``Combined arithmetic - addition and subtraction`` () = let expected = Some [-1] @@ -95,6 +115,16 @@ let ``Combined arithmetic - multiplication and division`` () = let expected = Some [2] evaluate ["2 4 * 3 /"] |> should equal expected +[] +let ``Combined arithmetic - multiplication and addition`` () = + let expected = Some [13] + evaluate ["1 3 4 * +"] |> should equal expected + +[] +let ``Combined arithmetic - addition and multiplication`` () = + let expected = Some [7] + evaluate ["1 3 4 + *"] |> should equal expected + [] let ``Dup - copies a value on the stack`` () = let expected = Some [1; 1]