prettyprint: fix off-by-one, thanks @adjvondrak!
parent
0ea8ed84b5
commit
74460b548b
|
@ -433,11 +433,7 @@ TUPLE: fo { a intersection{ integer fixnum } initial: 0 } ;
|
|||
] unit-test
|
||||
|
||||
[
|
||||
"""union{
|
||||
intersection{ string hashtable }
|
||||
union{ integer float }
|
||||
}
|
||||
"""
|
||||
"""union{ intersection{ string hashtable } union{ integer float } }\n"""
|
||||
] [ [ union{ union{ float integer } intersection{ string hashtable } } . ] with-string-writer ] unit-test
|
||||
|
||||
[
|
||||
|
@ -469,3 +465,21 @@ TUPLE: fo { a intersection{ integer fixnum } initial: 0 } ;
|
|||
[ 5 length-limit [ 6 iota >array pprint ] with-variable ]
|
||||
with-string-writer
|
||||
] unit-test
|
||||
|
||||
: margin-test ( number-of-'a's -- str )
|
||||
[
|
||||
[ CHAR: a <string> text "b" text ] with-pprint
|
||||
] with-string-writer ;
|
||||
|
||||
[
|
||||
"""aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa b"""
|
||||
] [ margin get 3 - margin-test ] unit-test
|
||||
|
||||
[
|
||||
"""aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa b"""
|
||||
] [ margin get 2 - margin-test ] unit-test
|
||||
|
||||
[
|
||||
"""aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||
b"""
|
||||
] [ margin get 1 - margin-test ] unit-test
|
||||
|
|
|
@ -98,7 +98,7 @@ style overhang ;
|
|||
0 >>overhang ; inline
|
||||
|
||||
M: section section-fits? ( section -- ? )
|
||||
[ end>> pprinter get last-newline>> - ]
|
||||
[ end>> 1 - pprinter get last-newline>> - ]
|
||||
[ overhang>> ] bi
|
||||
+ text-fits? ;
|
||||
|
||||
|
@ -266,7 +266,7 @@ M: flow short-section? ( section -- ? )
|
|||
#! a short section
|
||||
{
|
||||
[ section-fits? ]
|
||||
[ [ end>> ] [ start>> ] bi - text-fits? not ]
|
||||
[ [ end>> 1 - ] [ start>> ] bi - text-fits? not ]
|
||||
} 1|| ;
|
||||
|
||||
: <flow ( -- ) <flow> (<block) ;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
USING: vocabs.prettyprint tools.test io.streams.string eval ;
|
||||
USING: vocabs.prettyprint vocabs.prettyprint.private tools.test
|
||||
io.streams.string eval ;
|
||||
IN: vocabs.prettyprint.tests
|
||||
|
||||
: manifest-test-1 ( -- string )
|
||||
|
@ -42,3 +43,27 @@ EXCLUDE: parser => run-file ;
|
|||
IN: vocabs.prettyprint.tests"""
|
||||
]
|
||||
[ [ manifest-test-3 eval( -- ) ] with-string-writer ] unit-test
|
||||
|
||||
[
|
||||
"""USING: alien.c-types alien.syntax byte-arrays io
|
||||
io.encodings.binary io.encodings.string io.encodings.utf8
|
||||
io.streams.byte-array kernel sequences system system-info unix ;"""
|
||||
] [
|
||||
[
|
||||
{
|
||||
"alien.c-types"
|
||||
"alien.syntax"
|
||||
"byte-arrays"
|
||||
"io"
|
||||
"io.encodings.binary"
|
||||
"io.encodings.string"
|
||||
"io.encodings.utf8"
|
||||
"io.streams.byte-array"
|
||||
"kernel"
|
||||
"sequences"
|
||||
"system"
|
||||
"system-info"
|
||||
"unix"
|
||||
} pprint-using
|
||||
] with-string-writer
|
||||
] unit-test
|
||||
|
|
Loading…
Reference in New Issue