| There is some arc stuff in rainbow that isn't rainbow-specific, so I've committed it to anarki. It includes an arc parser (spun off because welder needed a tokeniser for colourising) and a little test runner. This parser or something like it could eventually replace 'sread. An advantage of having an arc parser written in arc is that there can be no ambiguity about what is officially arc syntax; also, it will be easier to make certain kinds of syntax changes. A temporary disadvantage is that this parser doesn't support all the scheme syntax that arc supports. It's a very simple implementation (apart from the token generator function which took some wikipedia support to get working) and probably needs improvements. arc>(apply (eval (parse "[* _ _]")) '(27))
729
The test runner runs simple tests, or test suites, of this form: (suite "parser tests"
("parse foo" (parse "foo") foo)
("parse a list" (parse "(a b c)") (a b c)))
There are lots of test examples under lib/tests. "foundation-test.arc" covers the most basic, low-level arc functions, and might be useful to anyone building their own arc interpreter. "parser-test.arc" provides a bunch of tests for the parser, and for the source indexer (used by welder).This is one way to launch tests: arc> (load "lib/unit-test.arc")
nil
arc> (load "lib/parser.arc")
nil
arc> (load "lib/tests/parser-test.arc")
nil
arc> (run-all-tests)
passed: 27
failed: 0
I've been a fan of test-driven-development for a few years and this test runner, unsophisticated though it may be, has already been pretty helpful. |