ExercismでOpenEuphoriaの演習をテストする方法を学びましょう
演習のディレクトリで、exercism testまたはeutestを実行します。
するとEuphoriaが、t_<exercise>.eを使って解答をテストします。
演習を始めた時点では、解答ファイルには戻り値がなく、実行するとクラッシュします。
C:\path\to\leap.ex:3
<0120>:: no value returned from function
end function
^
FAILURE: t_leap.e EUPHORIA error with status 1
Test results summary:
FAIL: t_leap.e
Files (run: 1) (failed: 1) (0% success)
これは想定どおりの動作です。 関数を実装してからもう一度実行すると、どのテストが合格して、どのテストが失敗するかがわかります。
interpreting t_leap.e:
passed: year not divisible by 4 in common year
failed: year divisible by 2, not divisible by 4 in common year, expected: FALSE but got: TRUE
failed: year divisible by 4, not divisible by 100 in leap year, expected: TRUE but got: FALSE
...
9 tests run, 6 passed, 3 failed, 67% success
FAILURE: t_leap.e program died with status 1
Test results summary:
FAIL: t_leap.e
Files (run: 1) (failed: 1) (0% success)
取りかかり方としておすすめなのは、t_<exercise>.eの中で最初のテスト以外をすべてコメントアウトすることです。
test_false("year not divisible by 4 in common year", leap(1800))
-- test_false("year divisible by 100 but not by 3 is still not a leap year", leap(1900))
-- test_false("year divisible by 2, not divisible by 4 in common year", leap(1970))
1つずつ進めていき、今のテストが合格したら次のテストのコメントアウトを外します。 すべてのテストが合格したら、演習は完了です。