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..74234aee 100644 --- a/exercises/practice/anagram/anagram-test.el +++ b/exercises/practice/anagram/anagram-test.el @@ -4,69 +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 (anagrams-for "solemn" '("lemons" "cherry" "melons")) + '("lemons" "melons")))) -(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 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"))))) - -(ert-deftest multiple-anagrams () - (should (equal '("gallery" "regally" "largely") - (anagrams-for - "allergy" - '("gallery" "ballerina" "regally" "clergy" "largely" "leading"))))) - -(ert-deftest case-insensitive-anagrams () - (should (equal '("Carthorse") - (anagrams-for - "Orchestra" - '("cashregister" "Carthorse" "radishes"))))) + (should (equal (anagrams-for "listen" '("enlists" "google" "inlets" "banana")) + '("inlets")))) + + +(ert-deftest detects-three-anagrams () + (should (equal (anagrams-for "allergy" + '("gallery" "ballerina" "regally" "clergy" "largely" "leading")) + '("gallery" "regally" "largely")))) + + +(ert-deftest detects-multiple-anagrams-with-different-case () + (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")) + '()))) + + +(ert-deftest detects-anagrams-case-insensitively () + (should (equal (anagrams-for "Orchestra" '("cashregister" "Carthorse" "radishes")) + '("Carthorse")))) + + +(ert-deftest detects-anagrams-using-case-insensitive-subject () + (should (equal (anagrams-for "Orchestra" '("cashregister" "carthorse" "radishes")) + '("carthorse")))) + + +(ert-deftest detects-anagrams-using-case-insensitive-possible-matches () + (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")) + '()))) + + +(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 '() - (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" "LISTEN"))))) + (should (equal (anagrams-for "LISTEN" '("LISTEN" "Silent")) + '("Silent")))) + (provide 'anagram-test) ;;; anagram-test.el ends here 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