From 25a34f0705cb44660f5572a329cbe974c99022b9 Mon Sep 17 00:00:00 2001 From: Erik Schierboom Date: Mon, 13 Jan 2025 16:57:21 +0100 Subject: [PATCH] scrabble-score: update to latest (#737) * scrabble-score: add generator and regenerate tests [no important files changed] * Update exercises/practice/scrabble-score/test/scrabble_score_test.clj Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> --------- Co-authored-by: Anastasios Chatzialexiou <16361161+tasxatzial@users.noreply.github.com> --- .../scrabble-score/.meta/generator.tpl | 8 ++++ .../scrabble-score/src/scrabble_score.clj | 12 +++--- .../test/scrabble_score_test.clj | 42 +++++++++---------- 3 files changed, 34 insertions(+), 28 deletions(-) create mode 100644 exercises/practice/scrabble-score/.meta/generator.tpl diff --git a/exercises/practice/scrabble-score/.meta/generator.tpl b/exercises/practice/scrabble-score/.meta/generator.tpl new file mode 100644 index 000000000..81c2569e0 --- /dev/null +++ b/exercises/practice/scrabble-score/.meta/generator.tpl @@ -0,0 +1,8 @@ +(ns scrabble-score-test + (:require [clojure.test :refer [deftest testing is]] + scrabble-score)) +{{#test_cases.score}} +(deftest score-word_test_{{idx}} + (testing "{{description}}" + (is (= {{expected}} (scrabble-score/score-word "{{input.word}}"))))) +{{/test_cases.score~}} diff --git a/exercises/practice/scrabble-score/src/scrabble_score.clj b/exercises/practice/scrabble-score/src/scrabble_score.clj index 0ed49b4a3..27e80f67d 100644 --- a/exercises/practice/scrabble-score/src/scrabble_score.clj +++ b/exercises/practice/scrabble-score/src/scrabble_score.clj @@ -1,9 +1,7 @@ (ns scrabble-score) -(defn score-letter [] ;; <- arglist goes here - ;; your code goes here -) - -(defn score-word [] ;; <- arglist goes here - ;; your code goes here -) +(defn score-word + "Calculate a word's scrabble score" + [word] + ;; function body + ) diff --git a/exercises/practice/scrabble-score/test/scrabble_score_test.clj b/exercises/practice/scrabble-score/test/scrabble_score_test.clj index 09a2f40cc..c9573ccc8 100644 --- a/exercises/practice/scrabble-score/test/scrabble_score_test.clj +++ b/exercises/practice/scrabble-score/test/scrabble_score_test.clj @@ -2,46 +2,46 @@ (:require [clojure.test :refer [deftest testing is]] scrabble-score)) -(deftest lowercase-letter - (testing "Lowercase letter" +(deftest score-word_test_1 + (testing "lowercase letter" (is (= 1 (scrabble-score/score-word "a"))))) -(deftest uppercase-letter - (testing "Uppercase letter" +(deftest score-word_test_2 + (testing "uppercase letter" (is (= 1 (scrabble-score/score-word "A"))))) -(deftest valuable-letter - (testing "Valuable letter" +(deftest score-word_test_3 + (testing "valuable letter" (is (= 4 (scrabble-score/score-word "f"))))) -(deftest short-word - (testing "Short word" +(deftest score-word_test_4 + (testing "short word" (is (= 2 (scrabble-score/score-word "at"))))) -(deftest short-valuable-word - (testing "Short, valuable word" +(deftest score-word_test_5 + (testing "short, valuable word" (is (= 12 (scrabble-score/score-word "zoo"))))) -(deftest medium-word - (testing "Medium word" +(deftest score-word_test_6 + (testing "medium word" (is (= 6 (scrabble-score/score-word "street"))))) -(deftest medium-valuable-word +(deftest score-word_test_7 (testing "medium, valuable word" (is (= 22 (scrabble-score/score-word "quirky"))))) -(deftest long-mixed-case-word - (testing "Long, mixed-case word" +(deftest score-word_test_8 + (testing "long, mixed-case word" (is (= 41 (scrabble-score/score-word "OxyphenButazone"))))) -(deftest english-like-word - (testing "English-like word" +(deftest score-word_test_9 + (testing "english-like word" (is (= 8 (scrabble-score/score-word "pinata"))))) -(deftest empty-input - (testing "Empty input" +(deftest score-word_test_10 + (testing "empty input" (is (= 0 (scrabble-score/score-word ""))))) -(deftest entire-alphabet-available - (testing "Entire alphabet available" +(deftest score-word_test_11 + (testing "entire alphabet available" (is (= 87 (scrabble-score/score-word "abcdefghijklmnopqrstuvwxyz")))))