]> gitweb.factorcode.org Git - factor.git/blob - basis/ui/gadgets/panes/panes-tests.factor
factor: rename [ ] [ ] unit-test -> { } [ ] unit-test using a refactoring tool!
[factor.git] / basis / ui / gadgets / panes / panes-tests.factor
1 USING: alien ui.gadgets.panes ui.gadgets namespaces
2 kernel sequences io io.styles io.streams.string tools.test
3 prettyprint definitions help help.syntax help.markup
4 help.stylesheet splitting ui.gadgets.debug models math summary
5 inspector accessors help.topics see fry ;
6 IN: ui.gadgets.panes.tests
7
8 : #children ( -- n ) "pane" get children>> length ;
9
10 { } [ <pane> "pane" set ] unit-test
11
12 { } [ #children "num-children" set ] unit-test
13
14 { } [
15     "pane" get <pane-stream> [ 100 [ . ] each-integer ] with-output-stream*
16 ] unit-test
17
18 { t } [ #children "num-children" get = ] unit-test
19
20 : test-gadget-text ( quot -- ? )
21     '[ _ call( -- ) ]
22     [ make-pane gadget-text dup print "======" print ]
23     [ with-string-writer dup print ] bi = ;
24
25 { t } [ [ "hello" write ] test-gadget-text ] unit-test
26 { t } [ [ "hello" pprint ] test-gadget-text ] unit-test
27 { t } [
28     [
29         H{ { wrap-margin 100 } } [ "hello" pprint ] with-nesting
30     ] test-gadget-text
31 ] unit-test
32 { t } [
33     [
34         H{ { wrap-margin 100 } } [
35             H{ } [
36                 "hello" pprint
37             ] with-style
38         ] with-nesting
39     ] test-gadget-text
40 ] unit-test
41 { t } [ [ [ 1 2 3 ] pprint ] test-gadget-text ] unit-test
42 { t } [ [ \ + describe ] test-gadget-text ] unit-test
43 { t } [ [ \ = see ] test-gadget-text ] unit-test
44 { t } [ [ \ = print-topic ] test-gadget-text ] unit-test
45
46 { t } [
47     [
48         title-style get [
49                 "Hello world" write
50         ] with-style
51     ] test-gadget-text
52 ] unit-test
53
54
55 { t } [
56     [
57         title-style get [
58                 "Hello world" write
59         ] with-nesting
60     ] test-gadget-text
61 ] unit-test
62
63 { t } [
64     [
65         title-style get [
66             title-style get [
67                 "Hello world" write
68             ] with-nesting
69         ] with-style
70     ] test-gadget-text
71 ] unit-test
72
73 { t } [
74     [
75         title-style get [
76             title-style get [
77                 [ "Hello world" write ] ($block)
78             ] with-nesting
79         ] with-style
80     ] test-gadget-text
81 ] unit-test
82
83 { t } [
84     [
85         last-element off
86         \ = >link $title
87         "Hello world" print-content
88     ] test-gadget-text
89 ] unit-test
90
91 { t } [
92     [
93         last-element off
94         \ = >link title-style get [
95             $navigation-table
96         ] with-nesting
97         "Hello world" print-content
98     ] test-gadget-text
99 ] unit-test
100
101 { t } [
102     [ { { "a\n" } } simple-table. ] test-gadget-text
103 ] unit-test
104
105 { t } [
106     [ { { "a" } } simple-table. "x" write ] test-gadget-text
107 ] unit-test
108
109 { t } [
110     [ H{ } [ { { "a" } } simple-table. ] with-nesting "x" write ] test-gadget-text
111 ] unit-test
112
113 ARTICLE: "test-article-1" "This is a test article"
114 "Hello world, how are you today." ;
115
116 { t } [ [ "test-article-1" $title ] test-gadget-text ] unit-test
117
118 { t } [ [ "test-article-1" print-topic ] test-gadget-text ] unit-test
119
120 ARTICLE: "test-article-2" "This is a test article"
121 "Hello world, how are you today."
122 { $table { "a" "b" } { "c" "d" } } ;
123
124 { t } [ [ "test-article-2" print-topic ] test-gadget-text ] unit-test
125
126 <pane> [ \ = see ] with-pane
127 <pane> [ \ = print-topic ] with-pane
128
129 { } [
130     \ = <model> [ see ] <pane-control> [ ] with-grafted-gadget
131 ] unit-test
132
133 : <test-pane> ( -- foo )
134     <gadget> pane new-pane ;
135
136 { t } [ <test-pane> dup input>> child? ] unit-test
137 { t } [ <test-pane> dup last-line>> child? ] unit-test