了解如何在 Exercism 上测试你的 Roc 练习
要下载练习,比如hello-world,打开终端并运行:
exercism download --track roc --exercise hello-world
然后进入练习目录,编辑代码来解答练习。例如:
cd {your Exercism folder}/roc/hello-world
edit HelloWorld.roc
每个练习都自带测试套件。你可以使用roc test命令运行测试,例如:
roc test hello-world-test.roc
如果你已经解答了练习,应该会看到 0 个失败的测试,例如:
All (5) tests passed in 123.4 ms.
但如果你的代码有错误,就会像这样:
── EXPECT FAILED in hello-world-test.roc ───────────────────────────────────────
This expectation failed:
6│ expect hello == "Hello, World!"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1 failed and 0 passed in 123.4 ms.
这应该能帮你修复代码。代码能正常运行后,你可以用exercism submit命令提交(更多细节请参见练习目录中的HELP.md)。