Skip to content

Commit 53bc55d

Browse files
authored
isogram: Sync tests (#705)
* sync tests * update starter file * implement tests * update example solution so that it passes the tests * update config * rename test functions * move example.clj to .meta folder [no important files changed]
1 parent a45651f commit 53bc55d

File tree

5 files changed

+85
-25
lines changed

5 files changed

+85
-25
lines changed

Diff for: exercises/practice/isogram/.meta/config.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"AndreaCrotti",
77
"haus",
88
"sjwarner-bp",
9-
"yurrriq"
9+
"yurrriq",
10+
"tasxatzial"
1011
],
1112
"files": {
1213
"solution": [

Diff for: exercises/practice/isogram/.meta/example.clj

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
(ns isogram
2-
(:require [clojure.string :as str]))
1+
(ns isogram)
32

4-
(defn isogram? [word]
5-
(apply distinct? (filter #(Character/isLetter %) (str/lower-case word))))
3+
(defn isogram?
4+
[s]
5+
(->> s
6+
clojure.string/lower-case
7+
(filter #(Character/isAlphabetic (int %)))
8+
frequencies
9+
vals
10+
(every? #{1})))

Diff for: exercises/practice/isogram/.meta/tests.toml

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
# This is an auto-generated file. Regular comments will be removed when this
2-
# file is regenerated. Regenerating will not touch any manually added keys,
3-
# so comments can be added in a "comment" key.
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
411

512
[a0e97d2d-669e-47c7-8134-518a1e2c4555]
613
description = "empty string"
@@ -40,3 +47,6 @@ description = "duplicated character in the middle"
4047

4148
[310ac53d-8932-47bc-bbb4-b2b94f25a83e]
4249
description = "same first and last characters"
50+
51+
[0d0b8644-0a1e-4a31-a432-2b3ee270d847]
52+
description = "word with duplicated character and with two hyphens"

Diff for: exercises/practice/isogram/src/isogram.clj

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
(ns isogram)
22

3-
(defn isogram? [] ;; <- arglist goes here
4-
;; your code goes here
5-
)
3+
(defn isogram?
4+
"Returns true if the given string is an isogram; otherwise, returns false"
5+
[s]
6+
;; function body
7+
)

Diff for: exercises/practice/isogram/test/isogram_test.clj

+56-14
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,59 @@
11
(ns isogram-test
2-
(:require [clojure.test :refer [deftest is]]
2+
(:require [clojure.test :refer [deftest testing is]]
33
isogram))
44

5-
(deftest test-isograms
6-
(is (isogram/isogram? "duplicates"))
7-
(is (isogram/isogram? "subdermatoglyphic"))
8-
(is (isogram/isogram? "thumbscrew-japingly"))
9-
(is (isogram/isogram? "Hjelmqvist-Gryb-Zock-Pfund-Wax"))
10-
(is (isogram/isogram? "Heizölrückstoßabdämpfung"))
11-
(is (isogram/isogram? "Emily Jung Schwartzkopf")))
12-
13-
(deftest test-non-isograms
14-
(is (not (isogram/isogram? "eleven")))
15-
(is (not (isogram/isogram? "Alphabet")))
16-
(is (not (isogram/isogram? "the quick brown fox")))
17-
(is (not (isogram/isogram? "éléphant"))))
5+
(deftest isogram?_test_1
6+
(testing "empty string"
7+
(is (true? (isogram/isogram? "")))))
8+
9+
(deftest isogram?_test_2
10+
(testing "isogram with only lower case characters"
11+
(is (true? (isogram/isogram? "isogram")))))
12+
13+
(deftest isogram?_test_3
14+
(testing "word with one duplicated character"
15+
(is (false? (isogram/isogram? "eleven")))))
16+
17+
(deftest isogram?_test_4
18+
(testing "word with one duplicated character from the end of the alphabet"
19+
(is (false? (isogram/isogram? "zzyzx")))))
20+
21+
(deftest isogram?_test_5
22+
(testing "longest reported english isogram"
23+
(is (true? (isogram/isogram? "subdermatoglyphic")))))
24+
25+
(deftest isogram?_test_6
26+
(testing "word with duplicated character in mixed case"
27+
(is (false? (isogram/isogram? "Alphabet")))))
28+
29+
(deftest isogram?_test_7
30+
(testing "word with duplicated character in mixed case, lowercase first"
31+
(is (false? (isogram/isogram? "alphAbet")))))
32+
33+
(deftest isogram?_test_8
34+
(testing "hypothetical isogrammic word with hyphen"
35+
(is (true? (isogram/isogram? "thumbscrew-japingly")))))
36+
37+
(deftest isogram?_test_9
38+
(testing "hypothetical word with duplicated character following hyphen"
39+
(is (false? (isogram/isogram? "thumbscrew-jappingly")))))
40+
41+
(deftest isogram?_test_10
42+
(testing "isogram with duplicated hyphen"
43+
(is (true? (isogram/isogram? "six-year-old")))))
44+
45+
(deftest isogram?_test_11
46+
(testing "made-up name that is an isogram"
47+
(is (true? (isogram/isogram? "Emily Jung Schwartzkopf")))))
48+
49+
(deftest isogram?_test_12
50+
(testing "duplicated character in the middle"
51+
(is (false? (isogram/isogram? "accentor")))))
52+
53+
(deftest isogram?_test_13
54+
(testing "same first and last characters"
55+
(is (false? (isogram/isogram? "angola")))))
56+
57+
(deftest isogram?_test_14
58+
(testing "word with duplicated character and with two hyphens"
59+
(is (false? (isogram/isogram? "up-to-date")))))

0 commit comments

Comments
 (0)