]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/tools/scaffold/scaffold.factor
tools.scaffold: Support unit tests with more than one output with run-string helper...
[factor.git] / basis / tools / scaffold / scaffold.factor
index 0b9e1e8085cb117048371bedac91c5a30b086b73..845f2324e279c8163d72578cc973823bba4fe56e 100644 (file)
@@ -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 )