I’m working on the Clojure track tackling Simple Cipher. Apparently the tests have all passed, but I’m still seeing a red header on the test results and I can’t submit.
My code:
(ns simple-cipher)
(defn rand-key
"Returns a random key"
[]
(loop [s ""]
(if (> (count s) 100) s
(recur (str s (char (+ 97 (rand-int 26))))))))
(defn encode
"Encodes text using the specified key"
[key plaintext]
(loop [[x & key] (apply str (repeat (inc (quot (count plaintext) (count key))) key))
[y & plaintext] plaintext
ciphertext ""]
(if (nil? y) ciphertext
(let [xval (- (int x) 97)
yval (int y)
diff (+ yval xval)
diff (if (> diff 122) (- yval (- 26 xval)) diff)]
(recur key
plaintext
(str ciphertext
(char diff)))))))
(defn decode
"Decodes text using the specified key"
[key ciphertext]
(loop [[x & key] key
[y & ciphertext] ciphertext
plaintext ""]
(if (or (nil? x) (nil? y)) plaintext
(let [xval (- (int x) 97)
yval (int y)
diff(- yval xval)]
(recur key
ciphertext
(str plaintext
(char diff)))))))
Is the clojure test runner having issues at the minute?
All seven tests individually pass, but the overall status is being reported as a failure. This doesn’t happen on my Clojure solutions or the example (used for CI verification purposes) for this solution. It does recurs if I use your code, but I don’t see an obvious reason why this would occur. The Clojure maintainers are pretty active and I’m sure they get to the bottom of this for you.
1 Like
tasx
March 27, 2025, 3:52pm
3
Hi @stevejordan and welcome
I don’t see any issues with the test runner right now. However, I do see an issue with the tests, which I’ll try to fix as soon as possible.
2 Likes
iHiD
March 27, 2025, 6:25pm
5
I’ve merged. Thanks @tasx :)
2 Likes
I think there may be an issue with the test code after that change. I’ve updated the exercise and now get this:
We received the following error when we ran your code:
----- Error --------------------------------------------------------------------
Type: clojure.lang.ExceptionInfo
Message: EOF while reading, expected ) to match ( at [26,1]
Data: {:type :sci.error/parse, :line 40, :column 1, :edamame/expected-delimiter ")", :edamame/opened-delimiter "(", :edamame/opened-delimiter-loc {:row 26, :col 1}, :phase "parse", :file "/mnt/exercism-iteration/src/simple_cipher.clj"}
Location: /mnt/exercism-iteration/test/simple_cipher_test.clj:2:3
Phase: parse
----- Context ------------------------------------------------------------------
1: (ns simple-cipher-test
2: (:require [clojure.test :refer [deftest testing is]]
^--- EOF while reading, expected ) to match ( at [26,1]
3: simple-cipher))
4:
5: (deftest rand-key_test_1
6: (testing "Random key cipher ▶ Key is made only of lowercase letters"
7: (is (true? (boolean (re-matches #"^[a-z]+$" (simple-cipher/rand-key)))))))
----- Stack trace --------------------------------------------------------------
simple-cipher-test - /mnt/exercism-iteration/test/simple_cipher_test.clj:2:3
user - /opt/test-runner/./test-runner.clj:19:1
I reran OP’s code after updating the exercise and got 9 out of 12 tests passing. I didn’t get an exception though.
tasx
March 27, 2025, 7:52pm
8
Not sure what’s causing it.
@stevejordan You should have seen a banner stating, ‘The exercise was updated. Update to the latest version and check if your tests still pass.’
To update, click the banner and then the update button. Did you do that?
Yes, I did that. And re ran the tests to get the above output.
However, coming back to it now an hour later it seems to be working fine. I get 10/12 tests passing.
Thanks for the support, I’m happy with that outcome. Now to go and make those last 2 pass!
3 Likes