Skip to content

Commit cb50ebd

Browse files
authored
simple-cipher: Add the ability to select which tests to run (#876)
[no important files changed]
1 parent b9e7d4f commit cb50ebd

File tree

3 files changed

+19
-16
lines changed

3 files changed

+19
-16
lines changed

exercises/practice/simple-cipher/.meta/generator.tpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
simple-cipher))
44

55
{{#test_cases.key}}
6-
(deftest rand-key_test_{{idx}}
6+
(deftest ^:rand-key rand-key_test_{{idx}}
77
(testing {{context}}
88
(is (true? (boolean (re-matches #{{expected.match}} (simple-cipher/rand-key)))))))
99
{{/test_cases.key}}
1010

1111
{{#test_cases.encode}}
12-
(deftest encode_test_{{idx}}
12+
(deftest ^:encode encode_test_{{idx}}
1313
(testing {{context}}
1414
{{#if input.key~}}
1515
(is (= {{expected}} (simple-cipher/encode {{input.key}} {{input.plaintext}})))))
@@ -20,7 +20,7 @@
2020
{{/test_cases.encode}}
2121

2222
{{#test_cases.decode}}
23-
(deftest decode_test_{{idx}}
23+
(deftest ^:decode decode_test_{{idx}}
2424
(testing {{context}}
2525
{{#if input.key~}}
2626
(is (= {{expected}} (simple-cipher/decode {{input.key}} {{#if input.plaintext}}(simple-cipher/encode {{input.key}} {{input.plaintext}}){{else}}{{input.ciphertext}}{{/if}})))))
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
(defproject simple-cipher "0.1.0-SNAPSHOT"
22
:description "simple-cipher exercise."
33
:url "https://github.com/exercism/clojure/tree/main/exercises/practice/simple-cipher"
4-
:dependencies [[org.clojure/clojure "1.12.0"]])
4+
:dependencies [[org.clojure/clojure "1.12.0"]]
5+
:test-selectors {:rand-key :rand-key
6+
:encode :encode
7+
:decode :decode})

exercises/practice/simple-cipher/test/simple_cipher_test.clj

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,53 @@
22
(:require [clojure.test :refer [deftest testing is]]
33
simple-cipher))
44

5-
(deftest rand-key_test_1
5+
(deftest ^:rand-key rand-key_test_1
66
(testing "Random key cipher ▶ Key is made only of lowercase letters"
77
(is (true? (boolean (re-matches #"^[a-z]+$" (simple-cipher/rand-key)))))))
88

9-
(deftest encode_test_1
9+
(deftest ^:encode encode_test_1
1010
(testing "Random key cipher ▶ Can encode"
1111
(let [key (simple-cipher/rand-key)]
1212
(is (= (subs key 0 (count "aaaaaaaaaa")) (simple-cipher/encode key "aaaaaaaaaa"))))))
1313

14-
(deftest encode_test_2
14+
(deftest ^:encode encode_test_2
1515
(testing "Substitution cipher ▶ Can encode"
1616
(is (= "abcdefghij" (simple-cipher/encode "abcdefghij" "aaaaaaaaaa")))))
1717

18-
(deftest encode_test_3
18+
(deftest ^:encode encode_test_3
1919
(testing "Substitution cipher ▶ Can double shift encode"
2020
(is (= "qayaeaagaciai" (simple-cipher/encode "iamapandabear" "iamapandabear")))))
2121

22-
(deftest encode_test_4
22+
(deftest ^:encode encode_test_4
2323
(testing "Substitution cipher ▶ Can wrap on encode"
2424
(is (= "zabcdefghi" (simple-cipher/encode "abcdefghij" "zzzzzzzzzz")))))
2525

26-
(deftest encode_test_5
26+
(deftest ^:encode encode_test_5
2727
(testing "Substitution cipher ▶ Can encode messages longer than the key"
2828
(is (= "iboaqcnecbfcr" (simple-cipher/encode "abc" "iamapandabear")))))
2929

30-
(deftest decode_test_1
30+
(deftest ^:decode decode_test_1
3131
(testing "Random key cipher ▶ Can decode"
3232
(let [key (simple-cipher/rand-key)]
3333
(is (= "aaaaaaaaaa" (simple-cipher/decode key (subs key 0 (count "aaaaaaaaaa"))))))))
3434

35-
(deftest decode_test_2
35+
(deftest ^:decode decode_test_2
3636
(testing "Random key cipher ▶ Is reversible. I.e., if you apply decode in a encoded result, you must see the same plaintext encode parameter as a result of the decode method"
3737
(let [key (simple-cipher/rand-key)]
3838
(is (= "abcdefghij" (simple-cipher/decode key (simple-cipher/encode key "abcdefghij")))))))
3939

40-
(deftest decode_test_3
40+
(deftest ^:decode decode_test_3
4141
(testing "Substitution cipher ▶ Can decode"
4242
(is (= "aaaaaaaaaa" (simple-cipher/decode "abcdefghij" "abcdefghij")))))
4343

44-
(deftest decode_test_4
44+
(deftest ^:decode decode_test_4
4545
(testing "Substitution cipher ▶ Is reversible. I.e., if you apply decode in a encoded result, you must see the same plaintext encode parameter as a result of the decode method"
4646
(is (= "abcdefghij" (simple-cipher/decode "abcdefghij" (simple-cipher/encode "abcdefghij" "abcdefghij"))))))
4747

48-
(deftest decode_test_5
48+
(deftest ^:decode decode_test_5
4949
(testing "Substitution cipher ▶ Can wrap on decode"
5050
(is (= "zzzzzzzzzz" (simple-cipher/decode "abcdefghij" "zabcdefghi")))))
5151

52-
(deftest decode_test_6
52+
(deftest ^:decode decode_test_6
5353
(testing "Substitution cipher ▶ Can decode messages longer than the key"
5454
(is (= "iamapandabear" (simple-cipher/decode "abc" "iboaqcnecbfcr")))))

0 commit comments

Comments
 (0)