factor/basis/ui/gadgets/panes/panes-tests.factor

136 lines
3.2 KiB
Factor
Raw Normal View History

2007-09-20 18:09:08 -04:00
USING: alien ui.gadgets.panes ui.gadgets namespaces
2008-04-04 09:44:32 -04:00
kernel sequences io io.styles io.streams.string tools.test
prettyprint definitions help help.syntax help.markup
2008-07-02 16:57:38 -04:00
help.stylesheet splitting tools.test.ui models math summary
inspector accessors help.topics see ;
2008-09-02 02:52:22 -04:00
IN: ui.gadgets.panes.tests
2007-09-20 18:09:08 -04:00
2009-03-23 01:34:02 -04:00
: #children ( -- n ) "pane" get children>> length ;
2007-09-20 18:09:08 -04:00
[ ] [ <pane> "pane" set ] unit-test
[ ] [ #children "num-children" set ] unit-test
[ ] [
"pane" get <pane-stream> [ 100 [ . ] each ] with-output-stream*
2007-09-20 18:09:08 -04:00
] unit-test
[ t ] [ #children "num-children" get = ] unit-test
: test-gadget-text ( quot -- ? )
2008-04-04 09:44:32 -04:00
dup make-pane gadget-text dup print "======" print
swap with-string-writer dup print = ;
2007-09-20 18:09:08 -04:00
[ t ] [ [ "hello" write ] test-gadget-text ] unit-test
[ t ] [ [ "hello" pprint ] test-gadget-text ] unit-test
2008-04-04 09:44:32 -04:00
[ t ] [
[
H{ { wrap-margin 100 } } [ "hello" pprint ] with-nesting
] test-gadget-text
] unit-test
[ t ] [
[
H{ { wrap-margin 100 } } [
H{ } [
"hello" pprint
] with-style
] with-nesting
] test-gadget-text
] unit-test
2007-09-20 18:09:08 -04:00
[ t ] [ [ [ 1 2 3 ] pprint ] test-gadget-text ] unit-test
2008-04-04 09:44:32 -04:00
[ t ] [ [ \ + describe ] test-gadget-text ] unit-test
2007-09-20 18:09:08 -04:00
[ t ] [ [ \ = see ] test-gadget-text ] unit-test
[ t ] [ [ \ = print-topic ] test-gadget-text ] unit-test
2007-09-20 18:09:08 -04:00
2008-04-04 09:44:32 -04:00
[ t ] [
[
title-style get [
"Hello world" write
] with-style
] test-gadget-text
] unit-test
[ t ] [
[
title-style get [
"Hello world" write
] with-nesting
] test-gadget-text
] unit-test
[ t ] [
[
title-style get [
title-style get [
"Hello world" write
] with-nesting
] with-style
] test-gadget-text
] unit-test
[ t ] [
[
title-style get [
title-style get [
[ "Hello world" write ] ($block)
] with-nesting
] with-style
] test-gadget-text
] unit-test
2008-12-22 01:54:08 -05:00
[ t ] [
[
last-element off
\ = >link $title
"Hello world" print-content
] test-gadget-text
] unit-test
[ t ] [
[
last-element off
\ = >link title-style get [
$navigation-table
] with-nesting
"Hello world" print-content
] test-gadget-text
] unit-test
[ t ] [
[ { { "a\n" } } simple-table. ] test-gadget-text
] unit-test
[ t ] [
[ { { "a" } } simple-table. "x" write ] test-gadget-text
] unit-test
[ t ] [
[ H{ } [ { { "a" } } simple-table. ] with-nesting "x" write ] test-gadget-text
] unit-test
2008-04-04 09:44:32 -04:00
ARTICLE: "test-article-1" "This is a test article"
"Hello world, how are you today." ;
[ t ] [ [ "test-article-1" $title ] test-gadget-text ] unit-test
[ t ] [ [ "test-article-1" print-topic ] test-gadget-text ] unit-test
2008-04-04 09:44:32 -04:00
ARTICLE: "test-article-2" "This is a test article"
2007-09-20 18:09:08 -04:00
"Hello world, how are you today."
{ $table { "a" "b" } { "c" "d" } } ;
[ t ] [ [ "test-article-2" print-topic ] test-gadget-text ] unit-test
2007-09-20 18:09:08 -04:00
<pane> [ \ = see ] with-pane
<pane> [ \ = print-topic ] with-pane
2007-11-16 01:19:13 -05:00
[ ] [
\ = <model> [ see ] <pane-control> [ ] with-grafted-gadget
] unit-test
2009-03-06 14:32:41 -05:00
: <test-pane> ( -- foo )
<gadget> pane new-pane ;
[ t ] [ <test-pane> dup input>> child? ] unit-test
[ t ] [ <test-pane> dup last-line>> child? ] unit-test