factor/basis/html/streams/streams-tests.factor

73 lines
1.7 KiB
Factor
Raw Normal View History

2008-09-02 14:05:49 -04:00
USING: html.streams html.streams.private accessors io
io.streams.string io.styles kernel namespaces tools.test
sbufs sequences inspector colors xml.writer
classes.predicate prettyprint ;
IN: html.streams.tests
2007-09-20 18:09:08 -04:00
: make-html-string ( quot -- string )
[ with-html-writer write-xml ] with-string-writer ; inline
2008-04-14 07:04:01 -04:00
[ [ ] make-html-string ] must-infer
[ "" ] [
[ "" write ] make-html-string
] unit-test
2007-09-20 18:09:08 -04:00
[ "a" ] [
[ CHAR: a write1 ] make-html-string
2007-09-20 18:09:08 -04:00
] unit-test
[ "<" ] [
[ "<" write ] make-html-string
] unit-test
2007-09-20 18:09:08 -04:00
TUPLE: funky town ;
M: funky url-of "http://www.funky-town.com/" swap town>> append ;
[ "<a href=\"http://www.funky-town.com/austin\">&lt;</a>" ] [
[
"<" "austin" funky boa write-object
] make-html-string
2007-09-20 18:09:08 -04:00
] unit-test
[ "<span style=\"font-family: monospace; \">car</span>" ]
2007-09-20 18:09:08 -04:00
[
[
"car"
2009-01-31 23:41:26 -05:00
H{ { font-name "monospace" } }
format
] make-html-string
2007-09-20 18:09:08 -04:00
] unit-test
[ "<span style=\"color: #ff00ff; \">car</span>" ]
2007-09-20 18:09:08 -04:00
[
[
"car"
H{ { foreground T{ rgba f 1 0 1 1 } } }
format
] make-html-string
] unit-test
2009-10-13 08:54:37 -04:00
[ "<div style=\"background-color: #ff00ff; white-space: pre; font-family: monospace; display: inline-block;\">cdr</div>" ]
[
[
H{ { page-color T{ rgba f 1 0 1 1 } } }
[ "cdr" write ] with-nesting
] make-html-string
2007-09-20 18:09:08 -04:00
] unit-test
2008-01-11 01:01:23 -05:00
2009-10-13 08:54:37 -04:00
[ "<div style=\"white-space: pre; font-family: monospace; display: inline-block;\"></div><br/>" ] [
2008-01-11 01:01:23 -05:00
[ H{ } [ ] with-nesting nl ] make-html-string
] unit-test
[ ] [ [ { 1 2 3 } describe ] with-html-writer drop ] unit-test
[ "<img src=\"/icons/class-word.tiff\"/>" ] [
[
"text"
{ { image "vocab:definitions/icons/class-word.tiff" } }
format
] make-html-string
] unit-test