I’m currently taking a course on Programming Languages, by Dan Grossman, which you can find for free here.
The assignments use Standard ML of New Jersey, which I had no previous experience with. The first thing in my mind was how to test the code, so I would feel confortable trying different things while solving the problems.
I chose to use sml-testing instead. So here is my setup:
First create and change into a working folder:
Clone the sml-testing repo and cd into it:
I chose to put my homework inside this same folder, since I still don’t know how to organize code in ML. So I created a test file like this:
And of course a file hw1.sml with my solutions.
Also, I wrote this shell script (run-tests.sh), which gives a green message for passing tests, a red list of failing tests or the whole output if there is a different error (like compilation):
Which you can run like this (after
chmod +x run-tests.sh):
Of with fswatch on osx (
brew install fswatch):
Which will run all tests for you whenever you make changes to a file in the current folder.
And that’s it. Happy functional programming!