From 8e994fdb9d4216164578210386bca98e4e151675 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20B=20Nagy?= <20251272+BNAndras@users.noreply.github.com> Date: Sun, 21 Apr 2024 22:20:59 -0700 Subject: [PATCH 1/3] Sync anagram tests --- exercises/practice/anagram/.meta/tests.toml | 5 ++ exercises/practice/anagram/anagram-test.el | 88 ++++++++++++++------- 2 files changed, 65 insertions(+), 28 deletions(-) diff --git a/exercises/practice/anagram/.meta/tests.toml b/exercises/practice/anagram/.meta/tests.toml index c271593a..9b6126a3 100644 --- a/exercises/practice/anagram/.meta/tests.toml +++ b/exercises/practice/anagram/.meta/tests.toml @@ -45,6 +45,11 @@ description = "detects anagrams using case-insensitive possible matches" [7cc195ad-e3c7-44ee-9fd2-d3c344806a2c] description = "does not detect an anagram if the original word is repeated" +include = false + +[630abb71-a94e-4715-8395-179ec1df9f91] +description = "does not detect an anagram if the original word is repeated" +reimplements = "7cc195ad-e3c7-44ee-9fd2-d3c344806a2c" [9878a1c9-d6ea-4235-ae51-3ea2befd6842] description = "anagrams must use all letters exactly once" diff --git a/exercises/practice/anagram/anagram-test.el b/exercises/practice/anagram/anagram-test.el index 923616b2..f4a6e726 100644 --- a/exercises/practice/anagram/anagram-test.el +++ b/exercises/practice/anagram/anagram-test.el @@ -8,47 +8,79 @@ (declare-function anagrams-for "anagram.el" (subject candidates)) (ert-deftest no-matches () - (should (equal '() (anagrams-for + (should (equal '() (anagrams-for "diaper" '("hello" "world" "zombies" "pants"))))) -(ert-deftest detect-simple-anagram () - (should (equal '("tan") (anagrams-for - "ant" - '("tan" "stand" "at"))))) -(ert-deftest does-not-confuse-different-duplicates () - (should (equal '() (anagrams-for - "galea" - '("eagle"))))) +(ert-deftest detects-two-anagrams () + (should (equal '("lemons" "melons") + (anagrams-for + "solemn" + '("lemons" "cherry" "melons"))))) + + +(ert-deftest does-not-detect-anagram-subsets () + (should (equal '() (anagrams-for "good" '("dog" "goody"))))) -(ert-deftest eliminate-anagram-subsets () - (should (equal '() (anagrams-for - "good" - '("dog" "goody"))))) (ert-deftest detect-anagram () - (should (equal '("inlets") (anagrams-for - "listen" - '("enlists" "google" "inlets" "banana"))))) + (should (equal '("inlets") + (anagrams-for + "listen" + '("enlists" "google" "inlets" "banana"))))) + -(ert-deftest multiple-anagrams () +(ert-deftest detects-three-anagrams () (should (equal '("gallery" "regally" "largely") - (anagrams-for + (anagrams-for "allergy" '("gallery" "ballerina" "regally" "clergy" "largely" "leading"))))) -(ert-deftest case-insensitive-anagrams () - (should (equal '("Carthorse") - (anagrams-for - "Orchestra" - '("cashregister" "Carthorse" "radishes"))))) + +(ert-deftest detects-multiple-anagrams-with-different-case () + (should (equal '("Eons" "ONES") + (anagrams-for + "nose" + '("Eons" "ONES"))))) + + +(ert-deftest does-not-detect-non-anagram-with-identical-checksum () + (should (equal '() (anagrams-for "mass" '("last"))))) + + +(ert-deftest detects-anagrams-case-insensitively () + (should (equal '("Carthorse") + (anagrams-for + "Orchestra" + '("cashregister" "Carthorse" "radishes"))))) + + +(ert-deftest detects-anagrams-using-case-insensitive-subject () + (should (equal '("carthorse") + (anagrams-for + "Orchestra" + '("cashregister" "carthorse" "radishes"))))) + + +(ert-deftest detects-anagrams-using-case-insensitive-possible-matches () + (should (equal '("Carthorse") + (anagrams-for + "orchestra" + '("cashregister" "Carthorse" "radishes"))))) + + +(ert-deftest does-not-detect-anagram-if-original-word-is-repeated () + (should (equal '() (anagrams-for "go" '("goGoGO"))))) + + +(ert-deftest anagrams-must-use-all-letters-exactly-once () + (should (equal '() (anagrams-for "tapper" '("patter"))))) + (ert-deftest word-is-not-own-anagram () - (should (equal '() - (anagrams-for - "BANANA" - '("BANANA"))))) + (should (equal '() (anagrams-for "BANANA" '("BANANA"))))) + (ert-deftest word-is-not-own-anagram-if-letter-case-is-partially-different () (should (equal '() @@ -66,7 +98,7 @@ (should (equal '("Silent") (anagrams-for "LISTEN" - '("Listen" "Silent" "LISTEN"))))) + '("LISTEN" "Silent"))))) (provide 'anagram-test) ;;; anagram-test.el ends here From 0365dc6f923e8b33f07b8831426d57692d7a54c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20B=20Nagy?= <20251272+BNAndras@users.noreply.github.com> Date: Mon, 22 Apr 2024 15:35:41 -0700 Subject: [PATCH 2/3] Update stub formatting --- exercises/practice/anagram/anagram.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/exercises/practice/anagram/anagram.el b/exercises/practice/anagram/anagram.el index dfd94bf5..b13f44f4 100644 --- a/exercises/practice/anagram/anagram.el +++ b/exercises/practice/anagram/anagram.el @@ -2,9 +2,12 @@ ;;; Commentary: -(defun anagrams-for (subject candidates) ;;; Code: -) + + +(defun anagrams-for (subject candidates) + (error "Delete this S-Expression and write your own implementation")) + (provide 'anagram) ;;; anagram.el ends here From 723256f63d06706cbd3ceb76bdffa92c224a1eb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20B=20Nagy?= <20251272+BNAndras@users.noreply.github.com> Date: Mon, 22 Apr 2024 16:12:11 -0700 Subject: [PATCH 3/3] Swap expected vs result order --- exercises/practice/anagram/anagram-test.el | 86 ++++++++++------------ 1 file changed, 38 insertions(+), 48 deletions(-) diff --git a/exercises/practice/anagram/anagram-test.el b/exercises/practice/anagram/anagram-test.el index f4a6e726..74234aee 100644 --- a/exercises/practice/anagram/anagram-test.el +++ b/exercises/practice/anagram/anagram-test.el @@ -4,101 +4,91 @@ ;;; Code: + (load-file "anagram.el") (declare-function anagrams-for "anagram.el" (subject candidates)) + (ert-deftest no-matches () - (should (equal '() (anagrams-for - "diaper" - '("hello" "world" "zombies" "pants"))))) + (should (equal (anagrams-for "diaper" '("hello" "world" "zombies" "pants")) + '()))) (ert-deftest detects-two-anagrams () - (should (equal '("lemons" "melons") - (anagrams-for - "solemn" - '("lemons" "cherry" "melons"))))) + (should (equal (anagrams-for "solemn" '("lemons" "cherry" "melons")) + '("lemons" "melons")))) (ert-deftest does-not-detect-anagram-subsets () - (should (equal '() (anagrams-for "good" '("dog" "goody"))))) + (should (equal (anagrams-for "good" '("dog" "goody")) + '()))) (ert-deftest detect-anagram () - (should (equal '("inlets") - (anagrams-for - "listen" - '("enlists" "google" "inlets" "banana"))))) + (should (equal (anagrams-for "listen" '("enlists" "google" "inlets" "banana")) + '("inlets")))) (ert-deftest detects-three-anagrams () - (should (equal '("gallery" "regally" "largely") - (anagrams-for - "allergy" - '("gallery" "ballerina" "regally" "clergy" "largely" "leading"))))) + (should (equal (anagrams-for "allergy" + '("gallery" "ballerina" "regally" "clergy" "largely" "leading")) + '("gallery" "regally" "largely")))) (ert-deftest detects-multiple-anagrams-with-different-case () - (should (equal '("Eons" "ONES") - (anagrams-for - "nose" - '("Eons" "ONES"))))) + (should (equal (anagrams-for "nose" '("Eons" "ONES")) + '("Eons" "ONES")))) (ert-deftest does-not-detect-non-anagram-with-identical-checksum () - (should (equal '() (anagrams-for "mass" '("last"))))) + (should (equal (anagrams-for "mass" '("last")) + '()))) (ert-deftest detects-anagrams-case-insensitively () - (should (equal '("Carthorse") - (anagrams-for - "Orchestra" - '("cashregister" "Carthorse" "radishes"))))) + (should (equal (anagrams-for "Orchestra" '("cashregister" "Carthorse" "radishes")) + '("Carthorse")))) (ert-deftest detects-anagrams-using-case-insensitive-subject () - (should (equal '("carthorse") - (anagrams-for - "Orchestra" - '("cashregister" "carthorse" "radishes"))))) + (should (equal (anagrams-for "Orchestra" '("cashregister" "carthorse" "radishes")) + '("carthorse")))) (ert-deftest detects-anagrams-using-case-insensitive-possible-matches () - (should (equal '("Carthorse") - (anagrams-for - "orchestra" - '("cashregister" "Carthorse" "radishes"))))) + (should (equal (anagrams-for "orchestra" '("cashregister" "Carthorse" "radishes")) + '("Carthorse")))) (ert-deftest does-not-detect-anagram-if-original-word-is-repeated () - (should (equal '() (anagrams-for "go" '("goGoGO"))))) + (should (equal (anagrams-for "go" '("goGoGO")) + '()))) (ert-deftest anagrams-must-use-all-letters-exactly-once () - (should (equal '() (anagrams-for "tapper" '("patter"))))) + (should (equal (anagrams-for "tapper" '("patter")) + '()))) (ert-deftest word-is-not-own-anagram () - (should (equal '() (anagrams-for "BANANA" '("BANANA"))))) + (should (equal (anagrams-for "BANANA" '("BANANA")) + '()))) (ert-deftest word-is-not-own-anagram-if-letter-case-is-partially-different () - (should (equal '() - (anagrams-for - "BANANA" - '("Banana"))))) + (should (equal (anagrams-for "BANANA" '("Banana")) + '()))) + (ert-deftest word-is-not-own-anagram-if-letter-case-is-completely-different () - (should (equal '() - (anagrams-for - "BANANA" - '("banana"))))) + (should (equal (anagrams-for "BANANA" '("banana")) + '()))) + (ert-deftest words-other-than-themselves-can-be-anagrams () - (should (equal '("Silent") - (anagrams-for - "LISTEN" - '("LISTEN" "Silent"))))) + (should (equal (anagrams-for "LISTEN" '("LISTEN" "Silent")) + '("Silent")))) + (provide 'anagram-test) ;;; anagram-test.el ends here