Codewars Challenges¶
My solutions to the Codewars challenges implemented in a few languages that interest me. I always do full TDD in everything I code, and these are no exceptions. Therefore, unit tests are provided as well.
Chicken Scheme¶
Install Necessary Eggs¶
For Scheme I use Chicken. Install these eggs:
$ chicken-install \
test \
srfi-1 \
Running Tests¶
To run the tests, make sure you are inside the directory that contains the file with the tests, for example:
$ ls -1
add.spec.scm
add.scm
Then, run this command
$ csi -quiet -batch
-- testing add ----------------------------------------------------
should add zeroes ......................................... [ PASS]
should add positive numbers ............................... [ PASS]
should add negative numbers ............................... [ PASS]
3 tests completed in 0.0 seconds.
3 out of 3 (100%) tests passed.
-- done testing add -----------------------------------------------
If running from Emacs + Geiser, make sure you execute run-geiser
after you visit the .scm
file you want to run, so that Geiser is
in the directory of that file and the (load "..."
) directive does
not fail saying it cannot find the files to load.
To run the tests from Emacs/Geiser, visit the spec file, start Geiser
with M-x geiser
and then do a C-c C-b
(geiser-eval-buffer
).
TypeScript¶
I use Deno to test and run the TypeScript solutions. Also be sure to check these notes about Deno and absolute imports plus editor setup on this very site.
Running Tests With Deno¶
Change to the root directory of where these codewars solutions have been cloned, e.g:
$ cd /path/to/devhowto/src/codewars
The run all tests, or specific tests:
$ deno test --unstable 6kyu
$ deno test --unstable 6kyu/friend-foe
$ deno test --unstable 6kyu/friend-foe/friend-foe.spec
Check extra options with deno test --help | less
.
Unstable APIs¶
We are making use of "deno.unstable": true
in the project
configuration and the use of the --unstable
command line flag for
running the tests because we are sometimes using unstable APIs, like
Nested Testing API from Deno v1.15.
Here’s my setup:
$ sed '' .vim/coc-settings.json
{
"deno.enable": true,
"deno.lint": true,
"deno.unstable": true,
"deno.importMap": "./import-map.json",
"tsserver.enable": false
}