Skip to content

Lightweight Test Framework

Jamie A. Jennings requested to merge Veratil:testframework into master

Created by: Veratil

This expands on the argparse PR #13 to add a test command for #34 (closed)

Tests are added inside RPL files as a comment, matched based upon this rosie expression:

testKeyword = "accepts" / "rejects"
test_line = "-- test" identifier testKeyword quoted_string (ignore "," ignore quoted_string)*

Sample test lines:

-- test common.int accepts "34", "+34", "-34
-- test common.int rejects "BEEF", "0x20"

Multiple lines testing the same identifier are allowed, so the above accepts line can also be written as:

-- test common.int accepts "34"
-- test common.int accepts "+34"
-- test common.int accepts "-34"

When run, a failure will produce output for each failed string. For instance adding "123" to the common.int rejects line will produce this output:

$ bin/rosie test rpl/common.rpl 
FAIL: common.int did not reject 123

A successful test run will produce this output:

$ bin/rosie test rpl/common.rpl 
All tests passed

If no test lines are found:

$ bin/rosie test rpl/basic.rpl 
No tests found

Merge request reports