From 2a7c6feb3eb5f7301b1879102113fae0c609e471 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 21:58:23 -0700 Subject: [PATCH 1/3] Sync allergies tests --- .../practice/allergies/allergies-test.el | 199 ++++++++++++++++-- 1 file changed, 180 insertions(+), 19 deletions(-) diff --git a/exercises/practice/allergies/allergies-test.el b/exercises/practice/allergies/allergies-test.el index 834728cb..0e992766 100644 --- a/exercises/practice/allergies/allergies-test.el +++ b/exercises/practice/allergies/allergies-test.el @@ -4,55 +4,216 @@ ;;; Code: + (load-file "allergies.el") (declare-function allergen-list "allergies.el" (score)) (declare-function allergic-to-p "allergies.el" (score allergen)) -(ert-deftest no-allergies-at-all () + +(ert-deftest eggs-not-allergic-to-anything () + (should-not (allergic-to-p 0 "eggs"))) + + +(ert-deftest eggs-allergic-only-to-eggs () + (should (allergic-to-p 1 "eggs"))) + + +(ert-deftest eggs-allergic-to-eggs-and-something-else () + (should (allergic-to-p 3 "eggs"))) + + +(ert-deftest eggs-allergic-to-something-but-not-eggs () + (should-not (allergic-to-p 2 "eggs"))) + + +(ert-deftest eggs-allergic-to-everything () + (should (allergic-to-p 255 "eggs"))) + + +(ert-deftest peanuts-not-allergic-to-anything () + (should-not (allergic-to-p 0 "peanuts"))) + + +(ert-deftest peanuts-allergic-only-to-peanuts () + (should (allergic-to-p 2 "peanuts"))) + + +(ert-deftest peanuts-allergic-to-peanuts-and-something-else () + (should (allergic-to-p 7 "peanuts"))) + + +(ert-deftest peanuts-allergic-to-something-but-not-peanuts () + (should-not (allergic-to-p 5 "peanuts"))) + + +(ert-deftest peanuts-allergic-to-everything () + (should (allergic-to-p 255 "peanuts"))) + + +(ert-deftest shellfish-not-allergic-to-anything () + (should-not (allergic-to-p 0 "shellfish"))) + + +(ert-deftest shellfish-allergic-only-to-shellfish () + (should (allergic-to-p 4 "shellfish"))) + + +(ert-deftest shellfish-allergic-to-shellfish-and-something-else () + (should (allergic-to-p 14 "shellfish"))) + + +(ert-deftest shellfish-allergic-to-something-but-not-shellfish () + (should-not (allergic-to-p 10 "shellfish"))) + + +(ert-deftest shellfish-allergic-to-everything () + (should (allergic-to-p 255 "shellfish"))) + + +(ert-deftest strawberries-not-allergic-to-anything () + (should-not (allergic-to-p 0 "strawberries"))) + + +(ert-deftest strawberries-allergic-only-to-strawberries () + (should (allergic-to-p 8 "strawberries"))) + + +(ert-deftest strawberries-allergic-to-strawberries-and-something-else () + (should (allergic-to-p 28 "strawberries"))) + + +(ert-deftest strawberries-allergic-to-something-but-not-strawberries () + (should-not (allergic-to-p 20 "strawberries"))) + + +(ert-deftest strawberries-allergic-to-everything () + (should (allergic-to-p 255 "strawberries"))) + + +(ert-deftest tomatoes-not-allergic-to-anything () + (should-not (allergic-to-p 0 "tomatoes"))) + + +(ert-deftest tomatoes-allergic-only-to-tomatoes () + (should (allergic-to-p 16 "tomatoes"))) + + +(ert-deftest tomatoes-allergic-to-tomatoes-and-something-else () + (should (allergic-to-p 56 "tomatoes"))) + + +(ert-deftest tomatoes-allergic-to-something-but-not-tomatoes () + (should-not (allergic-to-p 40 "tomatoes"))) + + +(ert-deftest tomatoes-allergic-to-everything () + (should (allergic-to-p 255 "tomatoes"))) + + +(ert-deftest chocolate-not-allergic-to-anything () + (should-not (allergic-to-p 0 "chocolate"))) + + +(ert-deftest chocolate-allergic-only-to-chocolate () + (should (allergic-to-p 32 "chocolate"))) + + +(ert-deftest chocolate-allergic-to-chocolate-and-something-else () + (should (allergic-to-p 112 "chocolate"))) + + +(ert-deftest chocolate-allergic-to-something-but-not-chocolate () + (should-not (allergic-to-p 80 "chocolate"))) + + +(ert-deftest chocolate-allergic-to-everything () + (should (allergic-to-p 255 "chocolate"))) + + +(ert-deftest pollen-not-allergic-to-anything () + (should-not (allergic-to-p 0 "pollen"))) + + +(ert-deftest pollen-allergic-only-to-pollen () + (should (allergic-to-p 64 "pollen"))) + + +(ert-deftest pollen-allergic-to-pollen-and-something-else () + (should (allergic-to-p 224 "pollen"))) + + +(ert-deftest pollen-allergic-to-something-but-not-pollen () + (should-not (allergic-to-p 160 "pollen"))) + + +(ert-deftest pollen-allergic-to-everything () + (should (allergic-to-p 255 "pollen"))) + + +(ert-deftest cats-not-allergic-to-anything () + (should-not (allergic-to-p 0 "cats"))) + + +(ert-deftest cats-allergic-only-to-cats () + (should (allergic-to-p 128 "cats"))) + + +(ert-deftest cats-allergic-to-cats-and-something-else () + (should (allergic-to-p 192 "cats"))) + + +(ert-deftest cats-allergic-to-something-but-not-cats () + (should-not (allergic-to-p 64 "cats"))) + + +(ert-deftest cats-allergic-to-everything () + (should (allergic-to-p 255 "cats"))) + + +(ert-deftest list-when-no-allergies-at-all () (should (equal '() (allergen-list 0)))) -(ert-deftest allergic-to-just-eggs () + +(ert-deftest list-when-allergic-to-just-eggs () (should (equal '("eggs") (allergen-list 1)))) -(ert-deftest allergic-to-just-peanuts () + +(ert-deftest list-when-allergic-to-just-peanuts () (should (equal '("peanuts") (allergen-list 2)))) -(ert-deftest allergic-to-just-strawberries () + +(ert-deftest list-when-allergic-to-just-strawberries () (should (equal '("strawberries") (allergen-list 8)))) -(ert-deftest allergic-to-eggs-and-peanuts () + +(ert-deftest list-when-allergic-to-eggs-and-peanuts () (should (equal '("eggs" "peanuts") (allergen-list 3)))) -(ert-deftest allergic-to-more-than-eggs-but-not-peanuts () + +(ert-deftest list-when-allergic-to-more-than-eggs-but-not-peanuts () (should (equal '("eggs" "shellfish") (allergen-list 5)))) -(ert-deftest allergic-to-lots-of-stuff () + +(ert-deftest list-when-allergic-to-lots-of-stuff () (should (equal '("strawberries" "tomatoes" "chocolate" "pollen" "cats") (allergen-list 248)))) -(ert-deftest allergic-to-everything () + +(ert-deftest list-when-allergic-to-everything () (should (equal '("eggs" "peanuts" "shellfish" "strawberries" "tomatoes" "chocolate" "pollen" "cats") (allergen-list 255)))) -(ert-deftest no-allergies-means-not-allergic () - (should-not (allergic-to-p 0 "peanuts")) - (should-not (allergic-to-p 0 "cats")) - (should-not (allergic-to-p 0 "strawberries"))) - -(ert-deftest is-allergic-to-eggs () - (should (allergic-to-p 1 "eggs"))) - -(ert-deftest allergic-to-eggs-and-other-stuff () - (should (allergic-to-p 5 "eggs"))) (ert-deftest ignore-non-allergen-score-parts () (should (equal '("eggs" "shellfish" "strawberries" "tomatoes" "chocolate" "pollen" "cats") (allergen-list 509)))) -(ert-deftest no-allergen-score-parts-without-highest-valid-score () + +(ert-deftest list-when-no-allergen-score-parts-without-highest-valid-score () (should (equal '("eggs") (allergen-list 257)))) + (provide 'allergies) ;;; allergies-test.el ends here From b2fe23ea02e90e37e5e05169563ca4506299ccc0 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:37:06 -0700 Subject: [PATCH 2/3] Update stub formatting --- exercises/practice/allergies/allergies.el | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/exercises/practice/allergies/allergies.el b/exercises/practice/allergies/allergies.el index 7d42a6e8..4de88fa9 100644 --- a/exercises/practice/allergies/allergies.el +++ b/exercises/practice/allergies/allergies.el @@ -2,15 +2,16 @@ ;;; Commentary: -(defun allergen-list (score) -"List all allergens with a given SCORE." ;;; Code: -) + + +(defun allergen-list (score) + (error "Delete this S-Expression and write your own implementation")) + (defun allergic-to-p (score allergen) -"Check if Allergic to allergen based on SCORE and ALLERGEN." -;;; Code: -) + (error "Delete this S-Expression and write your own implementation")) + (provide 'allergies) ;;; allergies.el ends here From 7cdcc1b36913501de5d1d2b9577ce65926190fb5 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:17:06 -0700 Subject: [PATCH 3/3] Swap result vs. expected --- .../practice/allergies/allergies-test.el | 43 ++++++++++++------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/exercises/practice/allergies/allergies-test.el b/exercises/practice/allergies/allergies-test.el index 0e992766..219be04c 100644 --- a/exercises/practice/allergies/allergies-test.el +++ b/exercises/practice/allergies/allergies-test.el @@ -171,49 +171,60 @@ (ert-deftest list-when-no-allergies-at-all () - (should (equal '() (allergen-list 0)))) + (should (equal (allergen-list 0) '()))) (ert-deftest list-when-allergic-to-just-eggs () - (should (equal '("eggs") (allergen-list 1)))) + (should (equal (allergen-list 1) '("eggs")))) (ert-deftest list-when-allergic-to-just-peanuts () - (should (equal '("peanuts") (allergen-list 2)))) + (should (equal (allergen-list 2) '("peanuts")))) (ert-deftest list-when-allergic-to-just-strawberries () - (should (equal '("strawberries") (allergen-list 8)))) + (should (equal (allergen-list 8) '("strawberries")))) (ert-deftest list-when-allergic-to-eggs-and-peanuts () - (should (equal '("eggs" "peanuts") (allergen-list 3)))) + (should (equal (allergen-list 3) '("eggs" "peanuts")))) (ert-deftest list-when-allergic-to-more-than-eggs-but-not-peanuts () - (should (equal '("eggs" "shellfish") (allergen-list 5)))) + (should (equal (allergen-list 5) '("eggs" "shellfish")))) (ert-deftest list-when-allergic-to-lots-of-stuff () - (should (equal '("strawberries" "tomatoes" "chocolate" "pollen" "cats") - (allergen-list 248)))) + (should (equal (allergen-list 248) + '("strawberries" "tomatoes" "chocolate" "pollen" "cats")))) (ert-deftest list-when-allergic-to-everything () - (should (equal '("eggs" "peanuts" "shellfish" "strawberries" "tomatoes" - "chocolate" "pollen" "cats") - (allergen-list 255)))) + (should (equal (allergen-list 255) + '("eggs" + "peanuts" + "shellfish" + "strawberries" + "tomatoes" + "chocolate" + "pollen" + "cats")))) (ert-deftest ignore-non-allergen-score-parts () - (should (equal '("eggs" "shellfish" "strawberries" "tomatoes" - "chocolate" "pollen" "cats") - (allergen-list 509)))) + (should (equal (allergen-list 509) + '("eggs" + "shellfish" + "strawberries" + "tomatoes" + "chocolate" + "pollen" + "cats")))) (ert-deftest list-when-no-allergen-score-parts-without-highest-valid-score () - (should (equal '("eggs") (allergen-list 257)))) + (should (equal (allergen-list 257) '("eggs")))) -(provide 'allergies) +(provide 'allergies-tests) ;;; allergies-test.el ends here