make-unit-test ( answer code -- str )


Vocabulary
tools.scaffold

Inputs
answera string
codea string


Outputs
stra string


Word description
Takes a code snippet and an answer string and returns a unit-test code snippet for use with tools.test vocabulary. The answer string should represent an array of values left on the stack by the code snippet.

Examples
USING: io tools.scaffold ; "{ 2 2 3 }" "3 2 dup rot" make-unit-test write
{ 2 2 3 } [ 3 2 dup rot ] unit-test


See also
read-unit-test

Definition


: make-unit-test ( answer code -- str )
split-lines [ " " prepend ] map "\n" join
"[\n" "\n] unit-test\n" surround " " glue ;