exercism / clojure

Exercism exercises in Clojure.

Home Page:https://exercism.org/tracks/clojure

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Interest is interesting - dependence on implementation details

m1kal opened this issue · comments

There are two problems with this exercise, but I think they can be fixed under a single issue. In my opinion both are related to unnecessary exposure of implementation details.

First, the stub contains annual-yield, which is not covered by any test case. Stub should contain only functions that are tested, other (helper) functions are implementation details.

Second, the test:

(deftest annual-balance-update-large-positive-balance-test
  (is (= 1016.2101016209999M (interest-is-interesting/annual-balance-update 1000.0001M))))

checks if the implementation made a particular numerical error. Both input and output are BigDecimals, so the correct answer could be 1016.210101621M as well. Although it is reasonable to assume most solutions make this mistake, other tests such as

(deftest annual-balance-update-small-positive-balance-test
  (is (= 0.000001005M (interest-is-interesting/annual-balance-update 0.000001M))))

can fail due to rounding errors.

Thank you for the feedback! I ported this exercise from the C# version which does indeed calculate 1016.210101621m. I was confused why I was getting a different result, and never really got to the bottom of it.

Thanks!
The changes look good.