]> gitweb.factorcode.org Git - factor.git/commitdiff
tools.scaffold: Support unit tests with more than one output with run-string helper...
authorDoug Coleman <doug.coleman@gmail.com>
Tue, 9 Aug 2022 05:21:39 +0000 (00:21 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Tue, 9 Aug 2022 05:22:27 +0000 (00:22 -0500)
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 )