test-dsl is a test-helper library to write your own DSLs
test-dsl allows you define a set of verbs and conditions, to more easily
concentrate on authoring tests.
How to use it
Using test-dsl is straightforward:
- You define a test harness
- You define a set of 'verbs' that will allow you to act on your test harness
- You define a set of 'conditions' that you will be able to assert during your tests
For example, a fairly simple test-setup to check arithmetic can be defined as follows:
use Arc;
use Condition;
use FunctionVerb;
use NamedSource;
let mut ts = new;
ts.add_condition;
ts.add_condition;
ts.add_verb;
ts.add_verb;
let testcases = ts
.parse_document
.unwrap;
// Check that its true
testcases.run.unwrap;
testcases.run.unwrap;
Builtin verbs
The following verbs come builtin:
-
repeat <number> { .. }: it allows for repetition of a given block. Used as such:testcase { repeat 3 { print "Hello World" print "World Hello" } } -
group { .. }: it allows to group verbs together. Used as such:testcase { group { print "Hello" print "World" } }NB: There is currently not much use to groups, but this may change in the future
-
assert { .. }: it allows to assert a list of conditions. Used as such:testcase { send_message assert { message_was_sent } }