From c945d87abe5d15ad2338012575d7df964bed25ed Mon Sep 17 00:00:00 2001 From: xinri Date: Mon, 17 Nov 2025 00:00:57 +0100 Subject: [PATCH 1/2] sync the wordy as they had been implemented but not sync --- exercises/practice/wordy/.meta/tests.toml | 25 ++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/exercises/practice/wordy/.meta/tests.toml b/exercises/practice/wordy/.meta/tests.toml index 912d57600..a0a83ed0b 100644 --- a/exercises/practice/wordy/.meta/tests.toml +++ b/exercises/practice/wordy/.meta/tests.toml @@ -1,13 +1,32 @@ -# This is an auto-generated file. Regular comments will be removed when this -# file is regenerated. Regenerating will not touch any manually added keys, -# so comments can be added in a "comment" key. +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. [88bf4b28-0de3-4883-93c7-db1b14aa806e] description = "just a number" +[18983214-1dfc-4ebd-ac77-c110dde699ce] +description = "just a zero" + +[607c08ee-2241-4288-916d-dae5455c87e6] +description = "just a negative number" + [bb8c655c-cf42-4dfc-90e0-152fcfd8d4e0] description = "addition" +[bb9f2082-171c-46ad-ad4e-c3f72087c1b5] +description = "addition with a left hand zero" + +[6fa05f17-405a-4742-80ae-5d1a8edb0d5d] +description = "addition with a right hand zero" + [79e49e06-c5ae-40aa-a352-7a3a01f70015] description = "more addition" From 41b0b14ad6e63496fbb5b434c1e35201a270b6fa Mon Sep 17 00:00:00 2001 From: xinri Date: Mon, 17 Nov 2025 22:57:47 +0100 Subject: [PATCH 2/2] fix and add displayName to unit tests for Wordy feature --- exercises/practice/wordy/.meta/config.json | 1 + .../src/test/java/WordProblemSolverTest.java | 66 ++++++++++++++++--- 2 files changed, 59 insertions(+), 8 deletions(-) diff --git a/exercises/practice/wordy/.meta/config.json b/exercises/practice/wordy/.meta/config.json index 2e6e383fd..78f4c3f91 100644 --- a/exercises/practice/wordy/.meta/config.json +++ b/exercises/practice/wordy/.meta/config.json @@ -21,6 +21,7 @@ "vasouv", "vivshaw", "vpondala", + "Xinri", "Zaldrick" ], "files": { diff --git a/exercises/practice/wordy/src/test/java/WordProblemSolverTest.java b/exercises/practice/wordy/src/test/java/WordProblemSolverTest.java index 70f0a1c30..79c4a1d41 100644 --- a/exercises/practice/wordy/src/test/java/WordProblemSolverTest.java +++ b/exercises/practice/wordy/src/test/java/WordProblemSolverTest.java @@ -1,4 +1,5 @@ import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -9,129 +10,175 @@ public class WordProblemSolverTest { WordProblemSolver solver = new WordProblemSolver(); @Test + @DisplayName("just a number") public void testJustANumber() { assertThat(solver.solve("What is 5?")).isEqualTo(5); } + @Test + @DisplayName("just a zero") + public void testJustAZero() { + assertThat(solver.solve("What is 0?")).isEqualTo(0); + } + + @Test + @DisplayName("just a negative number") + public void testJustANegativeNumber() { + assertThat(solver.solve("What is -123?")).isEqualTo(-123); + } + @Disabled("Remove to run test") @Test + @DisplayName("addition") public void testSingleAddition1() { assertThat(solver.solve("What is 1 plus 1?")).isEqualTo(2); } @Disabled("Remove to run test") @Test + @DisplayName("addition with a left hand zero") + public void testAdditionWithALeftHandZero() { + assertThat(solver.solve("What is 0 plus 2?")).isEqualTo(2); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("addition with a right hand zero") + public void testAdditionWithARightHandZero() { + assertThat(solver.solve("What is 3 plus 0?")).isEqualTo(3); + } + + @Disabled("Remove to run test") + @Test + @DisplayName("more addition") public void testSingleAddition2() { assertThat(solver.solve("What is 53 plus 2?")).isEqualTo(55); } @Disabled("Remove to run test") @Test + @DisplayName("addition with negative numbers") public void testSingleAdditionWithNegativeNumbers() { assertThat(solver.solve("What is -1 plus -10?")).isEqualTo(-11); } @Disabled("Remove to run test") @Test + @DisplayName("large addition") public void testSingleAdditionOfLargeNumbers() { assertThat(solver.solve("What is 123 plus 45678?")).isEqualTo(45801); } @Disabled("Remove to run test") @Test + @DisplayName("subtraction") public void testSingleSubtraction() { assertThat(solver.solve("What is 4 minus -12?")).isEqualTo(16); } @Disabled("Remove to run test") @Test + @DisplayName("multiplication") public void testSingleMultiplication() { assertThat(solver.solve("What is -3 multiplied by 25?")).isEqualTo(-75); } @Disabled("Remove to run test") @Test + @DisplayName("division") public void testSingleDivision() { assertThat(solver.solve("What is 33 divided by -3?")).isEqualTo(-11); } @Disabled("Remove to run test") @Test + @DisplayName("multiple additions") public void testMultipleAdditions() { assertThat(solver.solve("What is 1 plus 1 plus 1?")).isEqualTo(3); } @Disabled("Remove to run test") @Test + @DisplayName("addition and subtraction") public void testAdditionThenSubtraction() { assertThat(solver.solve("What is 1 plus 5 minus -2?")).isEqualTo(8); } @Disabled("Remove to run test") @Test + @DisplayName("multiple subtraction") public void testMultipleSubtractions() { assertThat(solver.solve("What is 20 minus 4 minus 13?")).isEqualTo(3); } @Disabled("Remove to run test") @Test + @DisplayName("subtraction then addition") public void testSubtractionThenAddition() { assertThat(solver.solve("What is 17 minus 6 plus 3?")).isEqualTo(14); } @Disabled("Remove to run test") @Test + @DisplayName("multiple multiplication") public void testMultipleMultiplications() { assertThat(solver.solve("What is 2 multiplied by -2 multiplied by 3?")).isEqualTo(-12); } @Disabled("Remove to run test") @Test + @DisplayName("addition and multiplication") public void testAdditionThenMultiplication() { assertThat(solver.solve("What is -3 plus 7 multiplied by -2?")).isEqualTo(-8); } @Disabled("Remove to run test") @Test + @DisplayName("multiple division") public void testMultipleDivisions() { assertThat(solver.solve("What is -12 divided by 2 divided by -3?")).isEqualTo(2); } @Disabled("Remove to run test") @Test + @DisplayName("unknown operation") public void testUnknownOperation() { assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> solver.solve("What is 52 cubed?")) - .withMessage("I'm sorry, I don't understand the question!"); + .isThrownBy(() -> solver.solve("What is 52 cubed?")) + .withMessage("I'm sorry, I don't understand the question!"); } @Disabled("Remove to run test") @Test + @DisplayName("Non math question") public void testNonMathQuestion() { // See https://en.wikipedia.org/wiki/President_of_the_United_States if you really need to know! assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> solver.solve("Who is the President of the United States?")) - .withMessage("I'm sorry, I don't understand the question!"); + .isThrownBy(() -> solver.solve("Who is the President of the United States?")) + .withMessage("I'm sorry, I don't understand the question!"); } @Disabled("Remove to run test") @Test + @DisplayName("reject problem missing an operand") public void testMissingAnOperand() { assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> solver.solve("What is 1 plus?")) - .withMessage("I'm sorry, I don't understand the question!"); + .isThrownBy(() -> solver.solve("What is 1 plus?")) + .withMessage("I'm sorry, I don't understand the question!"); } @Disabled("Remove to run test") @Test + @DisplayName("reject problem with no operands or operator") public void testNoOperandsOrOperators() { assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> solver.solve("What is?")) - .withMessage("I'm sorry, I don't understand the question!"); + .isThrownBy(() -> solver.solve("What is?")) + .withMessage("I'm sorry, I don't understand the question!"); } @Disabled("Remove to run test") @Test + @DisplayName("reject two operations in a row") public void testTwoOperationsInARow() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> solver.solve("What is 1 plus plus 2?")) @@ -140,6 +187,7 @@ public void testTwoOperationsInARow() { @Disabled("Remove to run test") @Test + @DisplayName("reject two numbers in a row") public void testTwoNumbersAfterOperation() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> solver.solve("What is 1 plus 2 1?")) @@ -148,6 +196,7 @@ public void testTwoNumbersAfterOperation() { @Disabled("Remove to run test") @Test + @DisplayName("reject postfix notation") public void testPostfixNotation() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> solver.solve("What is 1 2 plus?")) @@ -156,6 +205,7 @@ public void testPostfixNotation() { @Disabled("Remove to run test") @Test + @DisplayName("reject prefix notation") public void testPrefixNotation() { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy(() -> solver.solve("What is plus 1 2?"))