Skip to content

Commit 23fcdc9

Browse files
authored
acronym: Sync tests (#777)
* add generator and regenerate tests * update starter file * update example solution * update contributors [no important files changed]
1 parent 042942a commit 23fcdc9

File tree

5 files changed

+44
-20
lines changed

5 files changed

+44
-20
lines changed

exercises/practice/acronym/.meta/config.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"contributors": [
66
"AndreaCrotti",
77
"haus",
8-
"sjwarner-bp"
8+
"sjwarner-bp",
9+
"tasxatzial"
910
],
1011
"files": {
1112
"solution": [
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
(ns acronym
2-
(:require [clojure.string :as str]))
1+
(ns acronym)
32

43
(defn acronym [text]
5-
(->> (re-seq #"[A-Z]+[a-z]*|[a-z]+" text)
4+
(->> (re-seq #"(?<=^|[-_ ])[A-Za-z]" text)
65
(map first)
76
(apply str)
8-
str/upper-case))
7+
clojure.string/upper-case))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
(ns acronym-test
2+
(:require [clojure.test :refer [deftest testing is]]
3+
acronym))
4+
{{#test_cases.abbreviate}}
5+
(deftest acronym_test_{{idx}}
6+
(testing {{description}}
7+
(is (= {{expected}} (acronym/acronym {{input.phrase}})))))
8+
{{/test_cases.abbreviate~}}

exercises/practice/acronym/src/acronym.clj

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
(defn acronym
44
"Converts phrase to its acronym."
55
[phrase]
6+
;; function body
67
)
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,39 @@
11
(ns acronym-test
2-
(:require [clojure.test :refer [deftest is]]
2+
(:require [clojure.test :refer [deftest testing is]]
33
acronym))
44

5-
(deftest test-acronym-empty-string
6-
(is (= "" (acronym/acronym ""))))
5+
(deftest acronym_test_1
6+
(testing "basic"
7+
(is (= "PNG" (acronym/acronym "Portable Network Graphics")))))
78

8-
(deftest test-acronym-png
9-
(is (= "PNG" (acronym/acronym "Portable Network Graphics"))))
9+
(deftest acronym_test_2
10+
(testing "lowercase words"
11+
(is (= "ROR" (acronym/acronym "Ruby on Rails")))))
1012

11-
(deftest test-acronym-ror
12-
(is (= "ROR" (acronym/acronym "Ruby on Rails"))))
13+
(deftest acronym_test_3
14+
(testing "punctuation"
15+
(is (= "FIFO" (acronym/acronym "First In, First Out")))))
1316

14-
(deftest test-acronym-html
15-
(is (= "HTML" (acronym/acronym "HyperText Markup Language"))))
17+
(deftest acronym_test_4
18+
(testing "all caps word"
19+
(is (= "GIMP" (acronym/acronym "GNU Image Manipulation Program")))))
1620

17-
(deftest test-acronym-fifo
18-
(is (= "FIFO" (acronym/acronym "First In, First Out"))))
21+
(deftest acronym_test_5
22+
(testing "punctuation without whitespace"
23+
(is (= "CMOS" (acronym/acronym "Complementary metal-oxide semiconductor")))))
1924

20-
(deftest test-acronym-php
21-
(is (= "PHP" (acronym/acronym "PHP: Hypertext Preprocessor"))))
25+
(deftest acronym_test_6
26+
(testing "very long abbreviation"
27+
(is (= "ROTFLSHTMDCOALM" (acronym/acronym "Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me")))))
2228

23-
(deftest test-acronym-cmos
24-
(is (= "CMOS" (acronym/acronym "Complementary metal-oxide semiconductor"))))
29+
(deftest acronym_test_7
30+
(testing "consecutive delimiters"
31+
(is (= "SIMUFTA" (acronym/acronym "Something - I made up from thin air")))))
32+
33+
(deftest acronym_test_8
34+
(testing "apostrophes"
35+
(is (= "HC" (acronym/acronym "Halley's Comet")))))
36+
37+
(deftest acronym_test_9
38+
(testing "underscore emphasis"
39+
(is (= "TRNT" (acronym/acronym "The Road _Not_ Taken")))))

0 commit comments

Comments
 (0)