From: Doug Coleman Date: Tue, 9 Aug 2022 05:21:39 +0000 (-0500) Subject: tools.scaffold: Support unit tests with more than one output with run-string helper... X-Git-Tag: 0.99~1156 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=760947bd331693e90dabd75f8e7b995210fb961b tools.scaffold: Support unit tests with more than one output with run-string helper word. --- diff --git a/basis/tools/scaffold/scaffold.factor b/basis/tools/scaffold/scaffold.factor index 0b9e1e8085..845f2324e2 100644 --- a/basis/tools/scaffold/scaffold.factor +++ b/basis/tools/scaffold/scaffold.factor @@ -393,15 +393,19 @@ ${example-indent}} ".factor-roots" scaffold-rc ; : make-unit-test ( answer code -- str ) - [ split-lines [ " " prepend ] map "\n" join ] bi@ - [ "{\n" "\n}" surround ] [ "[\n" "\n] unit-test\n" surround ] bi* + split-lines [ " " prepend ] map "\n" join + "[\n" "\n] unit-test\n" surround " " glue ; +: run-string ( string -- datastack ) + parse-string V{ } clone swap with-datastack ; inline + : scaffold-unit-test ( -- str/f ) read-contents dup "" = [ drop f ] [ - [ eval( -- x ) unparse ] keep make-unit-test + [ run-string unparse ] keep + make-unit-test ] if ; : scaffold-unit-tests ( -- str )