Coverage tool


The tools.coverage vocabulary is a tool for testing code coverage. The implementation uses tools.annotations to place a coverage object at the beginning of every quotation. When the quotation executes, a slot on the coverage object is set to true. By examining the coverage objects after running the code for some time, one can see which of the quotations did not execute and write more tests or refactor the code.

An example of using the coverage tool by hand would be to call add-coverage and then call coverage-on. Next, run whatever code you think will call the most quotations in the code you're testing, and then run the coverage. word on your vocabulary to see which quotations didn't get run.

A fully automated way to test the unit-test coverage of a vocabulary is the test-coverage word.

Adding coverage annotations to a vocabulary:
add-coverage ( object -- )

remove-coverage ( object -- )


Resetting coverage annotations:
reset-coverage ( object -- )


Enabling/disabling coverage:
coverage-on ( -- )

coverage-off ( -- )


Examining coverage data:
coverage ( object -- seq )

coverage. ( object -- )

%coverage ( string -- x )


Gather unit-test coverage data for a vocabulary:
test-coverage ( vocab -- coverage )


Combinators for iterating over words in a vocabulary:
each-word ( string quot -- )

map-words ( string quot -- sequence )