help.lint.checks: improve check-example to print the stack (if any).

Any output from the example will be preserved like it currently is,
and any objects on the stack will be printed the same way they are
in the listener prefixed by ``--- Data stack:``.
char-rename
John Benediktsson 2017-05-05 08:40:47 -07:00
parent f75743ecf7
commit b1c0a1be33
1 changed files with 17 additions and 5 deletions

View File

@ -1,10 +1,11 @@
! Copyright (C) 2009 Slava Pestov. ! Copyright (C) 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: accessors arrays assocs classes classes.struct USING: accessors arrays assocs classes classes.struct
classes.tuple combinators combinators.short-circuit debugger classes.tuple combinators combinators.short-circuit
definitions effects eval formatting fry grouping help combinators.smart continuations debugger definitions effects
help.markup help.topics io io.streams.string kernel macros math eval formatting fry grouping help help.markup help.topics io
namespaces sequences sequences.deep sets splitting strings io.streams.string kernel macros math namespaces parser.notes
prettyprint sequences sequences.deep sets splitting strings
summary tools.destructors unicode vocabs vocabs.loader words summary tools.destructors unicode vocabs vocabs.loader words
words.constant words.symbol ; words.constant words.symbol ;
IN: help.lint.checks IN: help.lint.checks
@ -28,12 +29,23 @@ SYMBOL: vocab-articles
} member? } member?
] reject ; ] reject ;
: eval-with-stack ( str -- output )
[
[
parser-quiet? on parse-string [
output>array [
nl "--- Data stack:" print stack.
] unless-empty
] call( quot -- )
] [ nip print-error ] recover
] with-string-writer ;
: check-example ( element -- ) : check-example ( element -- )
[ [
'[ '[
_ rest [ _ rest [
but-last "\n" join but-last "\n" join
[ (eval>string) ] call( code -- output ) eval-with-stack
"\n" ?tail drop "\n" ?tail drop
] keep ] keep
last assert= last assert=