! Copyright (C) 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
-
USING: accessors alien arrays assocs byte-arrays calendar
classes classes.error combinators combinators.short-circuit
-continuations hashtables help.markup interpolate io
+continuations eval hashtables help.markup interpolate io
io.directories io.encodings.utf8 io.files io.pathnames
io.streams.string kernel math math.parser namespaces prettyprint
quotations sequences sets sorting splitting strings system
: scaffold-factor-roots ( -- )
".factor-roots" scaffold-rc ;
+: make-unit-test ( answer code -- str )
+ 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
+ ] [
+ [ run-string unparse ] keep
+ make-unit-test
+ ] if ;
+
+: scaffold-unit-tests ( -- str )
+ [ scaffold-unit-test dup ] [ ] produce nip "\n\n" join ;
+
HOOK: scaffold-emacs os ( -- )
M: unix scaffold-emacs ".emacs" scaffold-rc ;