了解如何在 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))
一次處理一個,等目前這個測試通過之後,再取消下一個測試的註解。 當所有測試都通過,就代表你完成這個練習了喔!