continuations effects 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
-timers unicode urls vocabs vocabs.loader vocabs.metadata words
-words.symbol ;
+prettyprint.config quotations sequences sets sorting splitting
+strings system timers unicode urls vocabs vocabs.loader
+vocabs.metadata words words.symbol ;
IN: tools.scaffold
SYMBOL: developer-name
: set-scaffold-tests-file ( vocab path -- )
[ tests-file-string ] dip utf8 set-file-contents ;
+: vocab>test-path ( vocab -- string )
+ "-tests.factor" vocab/suffix>path ;
+
PRIVATE>
: scaffold-tests ( vocab -- )
- ensure-vocab-exists
- dup "-tests.factor" vocab/suffix>path
+ ensure-vocab-exists dup vocab>test-path
scaffolding? [
set-scaffold-tests-file
] [
: run-string ( string -- datastack )
parse-string V{ } clone swap with-datastack ; inline
-: scaffold-unit-test ( -- str/f )
+: read-unit-test ( -- str/f )
read-contents dup "" = [
drop f
] [
- [ run-string unparse ] keep
+ [ run-string [ unparse ] without-limits ] keep
make-unit-test
] if ;
-: scaffold-unit-tests ( -- str )
- [ scaffold-unit-test dup ] [ ] produce nip "\n\n" join ;
+: read-unit-tests ( -- str )
+ [ read-unit-test dup ] [ ] produce nip "\n\n" join ;
+
+: scaffold-unit-tests ( vocab -- )
+ dup scaffold-tests vocab>test-path
+ [ read-unit-test ]
+ [ dup print "\n\n" prepend
+ over utf8 [ write ] with-file-appender ] while* drop ;
HOOK: scaffold-emacs os ( -- )