diff --git a/exercises/practice/pig-latin/.meta/config.json b/exercises/practice/pig-latin/.meta/config.json index 4568d4d87..a196c21f1 100644 --- a/exercises/practice/pig-latin/.meta/config.json +++ b/exercises/practice/pig-latin/.meta/config.json @@ -7,7 +7,8 @@ "haus", "querenker", "sjwarner-bp", - "thomchop" + "thomchop", + "tasxatzial" ], "files": { "solution": [ diff --git a/exercises/practice/pig-latin/.meta/generator.tpl b/exercises/practice/pig-latin/.meta/generator.tpl new file mode 100644 index 000000000..9d1e5ea37 --- /dev/null +++ b/exercises/practice/pig-latin/.meta/generator.tpl @@ -0,0 +1,8 @@ +(ns pig-latin-test + (:require [clojure.test :refer [deftest testing is]] + pig-latin)) +{{#test_cases.translate}} +(deftest translate_test_{{idx}} + (testing {{description}} + (is (= {{expected}} (pig-latin/translate {{input.phrase}}))))) +{{/test_cases.translate~}} diff --git a/exercises/practice/pig-latin/.meta/tests.toml b/exercises/practice/pig-latin/.meta/tests.toml index 49ce6e110..d524305b4 100644 --- a/exercises/practice/pig-latin/.meta/tests.toml +++ b/exercises/practice/pig-latin/.meta/tests.toml @@ -1,69 +1,79 @@ -# 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. [11567f84-e8c6-4918-aedb-435f0b73db57] -description = "word beginning with a" +description = "ay is added to words that start with vowels -> word beginning with a" [f623f581-bc59-4f45-9032-90c3ca9d2d90] -description = "word beginning with e" +description = "ay is added to words that start with vowels -> word beginning with e" [7dcb08b3-23a6-4e8a-b9aa-d4e859450d58] -description = "word beginning with i" +description = "ay is added to words that start with vowels -> word beginning with i" [0e5c3bff-266d-41c8-909f-364e4d16e09c] -description = "word beginning with o" +description = "ay is added to words that start with vowels -> word beginning with o" [614ba363-ca3c-4e96-ab09-c7320799723c] -description = "word beginning with u" +description = "ay is added to words that start with vowels -> word beginning with u" [bf2538c6-69eb-4fa7-a494-5a3fec911326] -description = "word beginning with a vowel and followed by a qu" +description = "ay is added to words that start with vowels -> word beginning with a vowel and followed by a qu" [e5be8a01-2d8a-45eb-abb4-3fcc9582a303] -description = "word beginning with p" +description = "first letter and ay are moved to the end of words that start with consonants -> word beginning with p" [d36d1e13-a7ed-464d-a282-8820cb2261ce] -description = "word beginning with k" +description = "first letter and ay are moved to the end of words that start with consonants -> word beginning with k" [d838b56f-0a89-4c90-b326-f16ff4e1dddc] -description = "word beginning with x" +description = "first letter and ay are moved to the end of words that start with consonants -> word beginning with x" [bce94a7a-a94e-4e2b-80f4-b2bb02e40f71] -description = "word beginning with q without a following u" +description = "first letter and ay are moved to the end of words that start with consonants -> word beginning with q without a following u" + +[e59dbbe8-ccee-4619-a8e9-ce017489bfc0] +description = "first letter and ay are moved to the end of words that start with consonants -> word beginning with consonant and vowel containing qu" [c01e049a-e3e2-451c-bf8e-e2abb7e438b8] -description = "word beginning with ch" +description = "some letter clusters are treated like a single consonant -> word beginning with ch" [9ba1669e-c43f-4b93-837a-cfc731fd1425] -description = "word beginning with qu" +description = "some letter clusters are treated like a single consonant -> word beginning with qu" [92e82277-d5e4-43d7-8dd3-3a3b316c41f7] -description = "word beginning with qu and a preceding consonant" +description = "some letter clusters are treated like a single consonant -> word beginning with qu and a preceding consonant" [79ae4248-3499-4d5b-af46-5cb05fa073ac] -description = "word beginning with th" +description = "some letter clusters are treated like a single consonant -> word beginning with th" [e0b3ae65-f508-4de3-8999-19c2f8e243e1] -description = "word beginning with thr" +description = "some letter clusters are treated like a single consonant -> word beginning with thr" [20bc19f9-5a35-4341-9d69-1627d6ee6b43] -description = "word beginning with sch" +description = "some letter clusters are treated like a single consonant -> word beginning with sch" [54b796cb-613d-4509-8c82-8fbf8fc0af9e] -description = "word beginning with yt" +description = "some letter clusters are treated like a single vowel -> word beginning with yt" [8c37c5e1-872e-4630-ba6e-d20a959b67f6] -description = "word beginning with xr" +description = "some letter clusters are treated like a single vowel -> word beginning with xr" [a4a36d33-96f3-422c-a233-d4021460ff00] -description = "y is treated like a consonant at the beginning of a word" +description = "position of y in a word determines if it is a consonant or a vowel -> y is treated like a consonant at the beginning of a word" [adc90017-1a12-4100-b595-e346105042c7] -description = "y is treated like a vowel at the end of a consonant cluster" +description = "position of y in a word determines if it is a consonant or a vowel -> y is treated like a vowel at the end of a consonant cluster" [29b4ca3d-efe5-4a95-9a54-8467f2e5e59a] -description = "y as second letter in two letter word" +description = "position of y in a word determines if it is a consonant or a vowel -> y as second letter in two letter word" [44616581-5ce3-4a81-82d0-40c7ab13d2cf] -description = "a whole phrase" +description = "phrases are translated -> a whole phrase" diff --git a/exercises/practice/pig-latin/src/pig_latin.clj b/exercises/practice/pig-latin/src/pig_latin.clj index 6525c36a4..83c2e9f08 100644 --- a/exercises/practice/pig-latin/src/pig_latin.clj +++ b/exercises/practice/pig-latin/src/pig_latin.clj @@ -1,5 +1,7 @@ (ns pig-latin) -(defn translate [] ;; <- arglist goes here - ;; your code goes here -) +(defn translate + "Translates phrase from English to Pig Latin" + [phrase] + ;; function body + ) diff --git a/exercises/practice/pig-latin/test/pig_latin_test.clj b/exercises/practice/pig-latin/test/pig_latin_test.clj index 919cd2f82..b378785d3 100644 --- a/exercises/practice/pig-latin/test/pig_latin_test.clj +++ b/exercises/practice/pig-latin/test/pig_latin_test.clj @@ -1,100 +1,95 @@ (ns pig-latin-test - (:require [clojure.test :refer [deftest is]] + (:require [clojure.test :refer [deftest testing is]] pig-latin)) -;; ay is added to words that start with vowels +(deftest translate_test_1 + (testing "ay is added to words that start with vowels ▶ word beginning with a" + (is (= "appleay" (pig-latin/translate "apple"))))) -(deftest word-beginning-with-a - (is (= "appleay" - (pig-latin/translate "apple")))) +(deftest translate_test_2 + (testing "ay is added to words that start with vowels ▶ word beginning with e" + (is (= "earay" (pig-latin/translate "ear"))))) -(deftest word-beginning-with-e - (is (= "earay" - (pig-latin/translate "ear")))) +(deftest translate_test_3 + (testing "ay is added to words that start with vowels ▶ word beginning with i" + (is (= "iglooay" (pig-latin/translate "igloo"))))) -(deftest word-beginning-with-i - (is (= "iglooay" - (pig-latin/translate "igloo")))) +(deftest translate_test_4 + (testing "ay is added to words that start with vowels ▶ word beginning with o" + (is (= "objectay" (pig-latin/translate "object"))))) -(deftest word-beginning-with-o - (is (= "objectay" - (pig-latin/translate "object")))) +(deftest translate_test_5 + (testing "ay is added to words that start with vowels ▶ word beginning with u" + (is (= "underay" (pig-latin/translate "under"))))) -(deftest word-beginning-with-u - (is (= "underay" - (pig-latin/translate "under")))) +(deftest translate_test_6 + (testing "ay is added to words that start with vowels ▶ word beginning with a vowel and followed by a qu" + (is (= "equalay" (pig-latin/translate "equal"))))) -(deftest word-beginning-with-a-vowel-and-followed-by-a-qu - (is (= "equalay" - (pig-latin/translate "equal")))) +(deftest translate_test_7 + (testing "first letter and ay are moved to the end of words that start with consonants ▶ word beginning with p" + (is (= "igpay" (pig-latin/translate "pig"))))) -;; first letter and ay are moved to the end of words that start with consonants +(deftest translate_test_8 + (testing "first letter and ay are moved to the end of words that start with consonants ▶ word beginning with k" + (is (= "oalakay" (pig-latin/translate "koala"))))) -(deftest word-beginning-with-p - (is (= "igpay" - (pig-latin/translate "pig")))) +(deftest translate_test_9 + (testing "first letter and ay are moved to the end of words that start with consonants ▶ word beginning with x" + (is (= "enonxay" (pig-latin/translate "xenon"))))) -(deftest word-beginning-with-k - (is (= "oalakay" - (pig-latin/translate "koala")))) +(deftest translate_test_10 + (testing "first letter and ay are moved to the end of words that start with consonants ▶ word beginning with q without a following u" + (is (= "atqay" (pig-latin/translate "qat"))))) -(deftest word-beginning-with-y - (is (= "ellowyay" - (pig-latin/translate "yellow")))) +(deftest translate_test_11 + (testing "first letter and ay are moved to the end of words that start with consonants ▶ word beginning with consonant and vowel containing qu" + (is (= "iquidlay" (pig-latin/translate "liquid"))))) -(deftest word-beginning-with-x - (is (= "enonxay" - (pig-latin/translate "xenon")))) +(deftest translate_test_12 + (testing "some letter clusters are treated like a single consonant ▶ word beginning with ch" + (is (= "airchay" (pig-latin/translate "chair"))))) -(deftest word-beginning-with-q-without-a-following-u - (is (= "atqay" - (pig-latin/translate "qat")))) +(deftest translate_test_13 + (testing "some letter clusters are treated like a single consonant ▶ word beginning with qu" + (is (= "eenquay" (pig-latin/translate "queen"))))) -;; some letter clusters are treated like a single consonant +(deftest translate_test_14 + (testing "some letter clusters are treated like a single consonant ▶ word beginning with qu and a preceding consonant" + (is (= "aresquay" (pig-latin/translate "square"))))) -(deftest word-beginning-with-ch - (is (= "airchay" - (pig-latin/translate "chair")))) +(deftest translate_test_15 + (testing "some letter clusters are treated like a single consonant ▶ word beginning with th" + (is (= "erapythay" (pig-latin/translate "therapy"))))) -(deftest word-beginning-with-qu - (is (= "eenquay" - (pig-latin/translate "queen")))) +(deftest translate_test_16 + (testing "some letter clusters are treated like a single consonant ▶ word beginning with thr" + (is (= "ushthray" (pig-latin/translate "thrush"))))) -(deftest word-beginning-with-qu-and-a-preceding-consonant - (is (= "aresquay" - (pig-latin/translate "square")))) +(deftest translate_test_17 + (testing "some letter clusters are treated like a single consonant ▶ word beginning with sch" + (is (= "oolschay" (pig-latin/translate "school"))))) -(deftest word-beginning-with-th - (is (= "erapythay" - (pig-latin/translate "therapy")))) +(deftest translate_test_18 + (testing "some letter clusters are treated like a single vowel ▶ word beginning with yt" + (is (= "yttriaay" (pig-latin/translate "yttria"))))) -(deftest word-beginning-with-thr - (is (= "ushthray" - (pig-latin/translate "thrush")))) +(deftest translate_test_19 + (testing "some letter clusters are treated like a single vowel ▶ word beginning with xr" + (is (= "xrayay" (pig-latin/translate "xray"))))) -(deftest word-beginning-with-sch - (is (= "oolschay" - (pig-latin/translate "school")))) +(deftest translate_test_20 + (testing "position of y in a word determines if it is a consonant or a vowel ▶ y is treated like a consonant at the beginning of a word" + (is (= "ellowyay" (pig-latin/translate "yellow"))))) -;; some letter clusters are treated like a single vowel +(deftest translate_test_21 + (testing "position of y in a word determines if it is a consonant or a vowel ▶ y is treated like a vowel at the end of a consonant cluster" + (is (= "ythmrhay" (pig-latin/translate "rhythm"))))) -(deftest word-beginning-with-yt - (is (= "yttriaay" - (pig-latin/translate "yttria")))) +(deftest translate_test_22 + (testing "position of y in a word determines if it is a consonant or a vowel ▶ y as second letter in two letter word" + (is (= "ymay" (pig-latin/translate "my"))))) -(deftest word-beginning-with-xr - (is (= "xrayay" - (pig-latin/translate "xray")))) - -(deftest word-beginning-with-consonants-followed-by-y - (is (= "ythmrhay" - (pig-latin/translate "rhythm")))) - -(deftest two-letter-word-ends-with-y - (is (= "ymay" - (pig-latin/translate "my")))) - -;; phrases are translated -(deftest a-whole-phrase - (is (= "ickquay astfay unray" - (pig-latin/translate "quick fast run")))) +(deftest translate_test_23 + (testing "phrases are translated ▶ a whole phrase" + (is (= "ickquay astfay unray" (pig-latin/translate "quick fast run")))))