Handbook
Glossary
make-unit-test ( answer code -- str )
Vocabulary
tools
.
scaffold
Inputs
answer
a
string
code
a
string
Outputs
str
a
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
USING:
sequences
splitting
;
IN:
tools.scaffold
:
make-unit-test
( answer code -- str )
split-lines
[
" "
prepend
]
map
"\n"
join
"[\n"
"\n] unit-test\n"
surround
" "
glue
;