From 760947bd331693e90dabd75f8e7b995210fb961b Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Tue, 9 Aug 2022 00:21:39 -0500 Subject: [PATCH] tools.scaffold: Support unit tests with more than one output with run-string helper word. --- basis/tools/scaffold/scaffold.factor | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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 ) -- 2.34.1