Hello! I saw this addendum in the Clojure version of the Complex Numbers exercise, and I also noticed that the Clojure version doesn’t require implementing a reciprocal function either. I have forked the exercism/clojure repo and added an example implementation, test cases for the reciprocal function, and a stub for the function in src/complex_numbers.clj.
I’m having trouble running the tests locally using babashka, and I’ve confirmed it’s a result of my changes because I can run the tests on the unmodified repo without my changes. I’m wondering if there’s some command I need to run using configlet, I noticed a tests.toml file in the complex-numbers/.meta folder that says it can be updated with configlet sync and has entries for all the existing test cases, but I don’t see any diff for that file when I try running that command.
Additionally, I was wondering if I could try adding test cases for the exponentiation function or if it’s preferable to avoid that on a Learning exercise (as opposed to a Practice exercise).
As for the tests.toml question, configlet sync --tests will report a missing test if there’s a difference between the tests listed in your local toml file and the upstream problem-specifications repo. It might be that the toml file is up-to-date, and any tests regarding reciprocal functions were marked as not included.
That’s true, but this comes directly from the instructions, which don’t require a reciprocal function. It’s listed as an operation only because it might be helpful for implementing division, which is required.
The exponentiation operation is listed as optional in the canonical-data.json, so when the exercise was first implemented, the original authors decided, presumably for their own reasons, to leave it out. Implementing this operation now would invalidate every existing solution, which is something I’m generally trying to avoid unless there’s a compelling reason. Additionally, there was a previous discussion about whether the operation should be made mandatory across tracks, but it’s still unclear whether that’s the right approach.
We don’t provide any instructions on how to run the tests using babashka. Could you please share exactly how you are running them?
From the repository root, after having installed bb: ./test.clj .
Without my changes, returns the following (although I forgot the trailing dot):
% ./test.clj
{:tested 113, :fails ()}
When I unstash my changes:
% ./test.clj
----- Error --------------------------------------------------------------------
Type: java.lang.NullPointerException
Location: /Users/remicah/Documents/clj/exercism-clojure/./test.clj:44:19
----- Context ------------------------------------------------------------------
40: (shell/sh "cp" src src-copy)
41: (try
42: (do
43: (shell/sh "cp" example src)
44: (= "pass" ((json/parse-string
^---
45: (:out (shell/sh (str test-runner-dir "test-runner.clj")
46: slug
47: dir
48: dir)))
49: "status")))
----- Stack trace --------------------------------------------------------------
user - /Users/remicah/Documents/clj/exercism-clojure/./test.clj:44:19
clojure.core/= - <built-in>
user/test-exercise - /Users/remicah/Documents/clj/exercism-clojure/./test.clj:44:9
user/test-exercise - /Users/remicah/Documents/clj/exercism-clojure/./test.clj:31:1
user - /Users/remicah/Documents/clj/exercism-clojure/./test.clj:56:27
... (run with --debug to see elided elements)
clojure.core/count - <built-in>
user - /Users/remicah/Documents/clj/exercism-clojure/./test.clj:60:17
clojure.core/prn - <built-in>
user - /Users/remicah/Documents/clj/exercism-clojure/./test.clj:60:3
user - /Users/remicah/Documents/clj/exercism-clojure/./test.clj:58:1
Interestingly, when I try running the tests with the latest commit on the main branch with the README instructions (that is, including the trailing dot for current directory), I get the same error:
% git stash
Saved working directory and index state WIP on main: 8e6ada9 Make deps.edn consistent across exercises (#848)
% ./test.clj .
----- Error --------------------------------------------------------------------
Type: java.lang.NullPointerException
Location: /Users/remicah/Documents/clj/exercism-clojure/./test.clj:44:19
----- Context ------------------------------------------------------------------
40: (shell/sh "cp" src src-copy)
41: (try
42: (do
43: (shell/sh "cp" example src)
44: (= "pass" ((json/parse-string
^---
45: (:out (shell/sh (str test-runner-dir "test-runner.clj")
46: slug
47: dir
48: dir)))
49: "status")))
----- Stack trace --------------------------------------------------------------
user - /Users/remicah/Documents/clj/exercism-clojure/./test.clj:44:19
clojure.core/= - <built-in>
user/test-exercise - /Users/remicah/Documents/clj/exercism-clojure/./test.clj:44:9
user/test-exercise - /Users/remicah/Documents/clj/exercism-clojure/./test.clj:31:1
user - /Users/remicah/Documents/clj/exercism-clojure/./test.clj:56:27
... (run with --debug to see elided elements)
clojure.core/count - <built-in>
user - /Users/remicah/Documents/clj/exercism-clojure/./test.clj:60:17
clojure.core/prn - <built-in>
user - /Users/remicah/Documents/clj/exercism-clojure/./test.clj:60:3
user - /Users/remicah/Documents/clj/exercism-clojure/./test.clj:58:1
The command ./test.clj . doesn’t work for me at all even with no changes. The readme might be outdated, incorrect, or something else could be going on.
These commands always work for me: ./test.clj and ./test.clj complex-numbers
Unstashing changes shouldn’t, and doesn’t, seem to cause an issue, so I’m unable to replicate what you’re describing, unless you’re running tests with ./test.clj . or your changes have an error.