在 OpenEuphoria 练习上测试

了解如何在 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))

一次处理一个,当前测试通过后,再取消注释下一个测试。 所有测试都通过时,你就完成了这个练习。