factor/basis/help/markup/markup-tests.factor

106 lines
2.8 KiB
Factor
Raw Normal View History

2011-09-15 18:52:31 -04:00
USING: accessors arrays assocs definitions fry generic help
help.markup io.streams.string kernel math namespaces parser
2011-09-15 18:52:31 -04:00
sequences sets strings tools.test words ;
FROM: namespaces => set ;
2008-03-01 17:00:45 -05:00
IN: help.markup.tests
2007-09-20 18:09:08 -04:00
: with-markup-test ( quot -- )
2012-07-19 16:55:34 -04:00
[ f last-element ] dip
'[ _ with-string-writer ] with-variable ; inline
2007-09-20 18:09:08 -04:00
TUPLE: blahblah quux ;
[ "int" ] [ [ { "int" } $instance ] with-markup-test ] unit-test
2007-09-20 18:09:08 -04:00
[ ] [ \ quux>> print-topic ] unit-test
[ ] [ \ >>quux print-topic ] unit-test
[ ] [ \ blahblah? print-topic ] unit-test
2007-09-20 18:09:08 -04:00
2009-03-23 01:34:02 -04:00
: fooey ( -- * ) "fooey" throw ;
2007-09-20 18:09:08 -04:00
[ ] [ \ fooey print-topic ] unit-test
2007-09-20 18:09:08 -04:00
[ ] [ gensym print-topic ] unit-test
2009-01-22 23:30:43 -05:00
[ "a string" ]
[ [ { $or string } print-element ] with-markup-test ] unit-test
2009-01-22 23:30:43 -05:00
[ "a string or an integer" ]
[ [ { $or string integer } print-element ] with-markup-test ] unit-test
2009-01-22 23:30:43 -05:00
[ "a string, a fixnum, or an integer" ]
[ [ { $or string fixnum integer } print-element ] with-markup-test ] unit-test
2009-02-09 02:47:31 -05:00
! Layout
[ "span" ]
[ [ { "span" } print-content ] with-markup-test ] unit-test
[ "span1span2" ]
[ [ { "span1" "span2" } print-content ] with-markup-test ] unit-test
[ "span1\n\nspan2" ]
[ [ { "span1" { $nl } "span2" } print-content ] with-markup-test ] unit-test
[ "\nspan" ]
[ [ { { $nl } "span" } print-content ] with-markup-test ] unit-test
[ "2 2 +\nspan" ]
[ [ { { $code "2 2 +" } "span" } print-content ] with-markup-test ] unit-test
[ "2 2 +" ]
[ [ { { $code "2 2 +" } } print-content ] with-markup-test ] unit-test
[ "span\n2 2 +" ]
[ [ { "span" { $code "2 2 +" } } print-content ] with-markup-test ] unit-test
[ "\n2 2 +" ]
[ [ { { $nl } { $code "2 2 +" } } print-content ] with-markup-test ] unit-test
[ "span\n\n2 2 +" ]
[ [ { "span" { $nl } { $code "2 2 +" } } print-content ] with-markup-test ] unit-test
[ "Heading" ]
[ [ { { $heading "Heading" } } print-content ] with-markup-test ] unit-test
[ "Heading1\n\nHeading2" ]
[ [ { { $heading "Heading1" } { $heading "Heading2" } } print-content ] with-markup-test ] unit-test
[ "span\n\nHeading" ]
[ [ { "span" { $heading "Heading" } } print-content ] with-markup-test ] unit-test
[ "\nHeading" ]
[ [ { { $nl } { $heading "Heading" } } print-content ] with-markup-test ] unit-test
[ "span\n\nHeading" ]
[ [ { "span" { $nl } { $heading "Heading" } } print-content ] with-markup-test ] unit-test
2011-09-15 18:52:31 -04:00
: word-related-words ( word -- word related-words )
dup [ "related" word-prop ] [ 1array ] bi diff ;
SYMBOLS:
1foo 2foo 3foo
1bar 2bar 3bar ;
{
1foo { 2foo 3foo }
1bar { 2bar 3bar }
1foo { 1bar }
2foo { 3foo }
2bar { 3bar }
} [
{ 1foo 2foo 3foo } related-words
{ 1bar 2bar 3bar } related-words
1foo word-related-words
1bar word-related-words
{ 2foo 3foo } related-words
{ 1foo 1bar } related-words
1foo word-related-words
2foo word-related-words
2bar word-related-words
] unit-test