factor/extra/html/parser/printer/printer-tests.factor

35 lines
758 B
Factor
Raw Normal View History

2013-08-05 07:25:26 -04:00
USING:
html.parser html.parser.printer
io.streams.string
namespaces
strings
2013-08-05 07:25:26 -04:00
tools.test ;
IN: html.parser.printer.tests
{
2013-08-05 07:25:26 -04:00
" "
} [
2016-11-12 10:56:55 -05:00
5 #indentations [ [ indent ] with-string-writer ] with-variable
2013-08-05 07:25:26 -04:00
] unit-test
{
" href='http://www.google.com' rel='nofollow'"
} [
2013-08-05 07:25:26 -04:00
H{ { "href" "http://www.google.com" } { "rel" "nofollow" } }
[ print-attributes ] with-string-writer
] unit-test
{
2013-08-05 07:25:26 -04:00
"<p>\n Sup dude!\n <br>\n</p>\n"
} [
2013-08-05 07:25:26 -04:00
"<p>Sup dude!<br></p>" parse-html [ prettyprint-html ] with-string-writer
] unit-test
! Wrongly nested tags
{
2013-08-05 07:25:26 -04:00
"<div>\n <p>\n Sup dude!\n <br>\n </div>\n</p>\n"
} [
2013-08-05 07:25:26 -04:00
"<div><p>Sup dude!<br></div></p>" parse-html
[ prettyprint-html ] with-string-writer
] unit-test