I like to follow a clean coding principle of sticking to one language per source file as I find the code easier to read and test. It also obviates the need for special quoting and escaping.
In the Bash track, the Darts exercise uses real numbers, which Bash is really not suited to, so I broke the calculation out into a separate darts.bc
file to deal with things like real
s and square roots.
The bats
tests ran fine locally and in a Docker container:
[Sat 23/10/14 13:19 AEDT][s004][x86_64/darwin23.0/23.0.0][5.9]
<paj@Reg-Shoe:~/Exercism/bash/darts>
zsh/3 6565 % docker run --rm -v$PWD:/code -it bats/bats:1.9.0 -Tx darts.bats
darts.bats
β Missed target [0]
β On the outer circle [0]
β On the middle circle [0]
β On the inner circle [0]
β Exactly on centre [0]
β Near the centre [0]
β Just within the inner circle [0]
β Just outside the inner circle [0]
β Just within the middle circle [0]
β Just outside the middle circle [0]
β Just within the outer circle [0]
β Just outside the outer circle [0]
β Asymmetric position between the inner and middle circles [0]
β invalid args: no args [0]
β invalid args: only 1 arg [0]
β invalid args: first arg non-numeric [0]
β invalid args: second arg non-numeric [0]
17 tests, 0 failures in 2 seconds
The tests time out when submitted. E.g. Iteration 5 here: johnsyweb's solution for Darts in Bash on Exercism .
Is this a bug or a feature?