1 USING: continuations documents
2 ui.tools.listener hashtables kernel namespaces parser sequences
3 tools.test ui.commands ui.gadgets ui.gadgets.editors
4 ui.gadgets.panes vocabs words ui.gadgets.debug slots.private
5 arrays generic threads accessors listener math
6 calendar concurrency.promises io ui.tools.common ;
7 IN: ui.tools.listener.tests
10 [ ] [ <interactor> <pane> <pane-stream> >>output "interactor" set ] unit-test
12 [ ] [ "interactor" get register-self ] unit-test
14 [ ] [ "[ 1 2 3" "interactor" get set-editor-string ] unit-test
16 [ ] [ <promise> "promise" set ] unit-test
19 self "interactor" get thread<<
20 "interactor" get stream-read-quot "promise" get fulfill
21 ] "Interactor test" spawn drop
23 ! This should not throw an exception
24 [ ] [ "interactor" get evaluate-input ] unit-test
26 [ ] [ [ "interactor" get interactor-busy? ] [ yield ] while ] unit-test
28 [ ] [ "[ 1 2 3 ]" "interactor" get set-editor-string ] unit-test
30 [ ] [ "interactor" get evaluate-input ] unit-test
32 [ [ [ 1 2 3 ] ] ] [ "promise" get 5 seconds ?promise-timeout ] unit-test
33 ] with-interactive-vocabs
36 [ ] [ <interactor> <pane> <pane-stream> >>output "interactor" set ] unit-test
38 [ ] [ "interactor" get register-self ] unit-test
40 [ ] [ <promise> "promise" set ] unit-test
43 self "interactor" get thread<<
44 "interactor" get stream-readln "promise" get fulfill
45 ] "Interactor test" spawn drop
47 [ ] [ "hi" "interactor" get set-editor-string ] unit-test
49 [ ] [ [ "interactor" get interactor-busy? ] [ yield ] while ] unit-test
51 [ ] [ "interactor" get evaluate-input ] unit-test
53 [ "hi" ] [ "promise" get 5 seconds ?promise-timeout ] unit-test
55 [ ] [ <promise> "promise" set ] unit-test
58 self "interactor" get thread<<
59 "\n" "interactor" get stream-read-until 2array "promise" get fulfill
60 ] "Interactor test" spawn drop
62 [ ] [ "Hello\nWorld\n" "interactor" get set-editor-string ] unit-test
64 [ ] [ [ "interactor" get interactor-busy? ] [ yield ] while ] unit-test
66 [ ] [ "interactor" get evaluate-input ] unit-test
68 [ { "Hello" 10 } ] [ "promise" get 5 seconds ?promise-timeout ] unit-test
70 [ ] [ <promise> "promise" set ] unit-test
73 self "interactor" get thread<<
74 "C\n" "interactor" get stream-read-until 2array "promise" get fulfill
75 ] "Interactor test" spawn drop
77 [ ] [ "ABCDEFGHIJKLM" "interactor" get set-editor-string ] unit-test
79 [ ] [ [ "interactor" get interactor-busy? ] [ yield ] while ] unit-test
81 [ ] [ "interactor" get evaluate-input ] unit-test
83 [ { "AB" 67 } ] [ "promise" get 5 seconds ?promise-timeout ] unit-test
85 [ ] [ <promise> "promise" set ] unit-test
88 self "interactor" get thread<<
89 "Z" "interactor" get stream-read-until 2array "promise" get fulfill
90 ] "Interactor test" spawn drop
92 [ ] [ "Hello\nWorld" "interactor" get set-editor-string ] unit-test
94 [ ] [ [ "interactor" get interactor-busy? ] [ yield ] while ] unit-test
96 [ ] [ "interactor" get evaluate-input ] unit-test
98 [ ] [ "interactor" get interactor-eof ] unit-test
100 [ { "Hello\nWorld\n" f } ] [ "promise" get 5 seconds ?promise-timeout ] unit-test
101 ] with-interactive-vocabs
104 { } [ <interactor> <pane> <pane-stream> >>output "interactor" set ] unit-test
106 { } [ [ "interactor" get stream-read-quot drop ] "A" spawn drop ] unit-test
108 { } [ [ "interactor" get stream-read-quot drop ] "B" spawn drop ] unit-test
110 { } [ 1 seconds sleep ] unit-test
112 { } [ "interactor" get interactor-eof ] unit-test
114 { } [ <interactor> <pane> <pane-stream> >>output "interactor" set ] unit-test
116 CONSTANT: text "Hello world.\nThis is a test."
118 { } [ text "interactor" get set-editor-string ] unit-test
120 { } [ <promise> "promise" set ] unit-test
124 "interactor" get register-self
125 "interactor" get stream-contents "promise" get fulfill
129 { } [ 100 milliseconds sleep ] unit-test
131 { } [ "interactor" get evaluate-input ] unit-test
133 { } [ 100 milliseconds sleep ] unit-test
135 { } [ "interactor" get interactor-eof ] unit-test
137 { t } [ "promise" get 2 seconds ?promise-timeout text = ] unit-test
139 { } [ <interactor> <pane> <pane-stream> >>output "interactor" set ] unit-test
141 { } [ text "interactor" get set-editor-string ] unit-test
143 { } [ <promise> "promise" set ] unit-test
147 "interactor" get register-self
148 "interactor" get stream-read1 "promise" get fulfill
152 { } [ 100 milliseconds sleep ] unit-test
154 { } [ "interactor" get evaluate-input ] unit-test
156 { CHAR: H } [ "promise" get 2 seconds ?promise-timeout ] unit-test
158 { } [ <listener-gadget> [ ] with-grafted-gadget ] unit-test
160 { } [ <listener-gadget> "listener" set ] unit-test
163 <interactor> <pane> <pane-stream> >>output "i" set
165 [ t ] [ "i" get interactor? ] unit-test
167 [ ] [ "SYMBOL:" "i" get set-editor-string ] unit-test
170 "i" get [ { "SYMBOL:" } parse-lines ] [ go-to-error ] recover
174 "i" get model>> doc-end
175 "i" get editor-caret =
178 ! Race condition discovered by SimonRC
181 "listener" get input>>
182 [ stream-read-quot drop ]
183 [ stream-read-quot drop ] bi
184 ] "OH, HAI" spawn drop
187 [ ] [ "listener" get clear-output ] unit-test
189 [ ] [ "listener" get restart-listener ] unit-test
191 [ ] [ 1 seconds sleep ] unit-test
193 [ ] [ "listener" get com-end ] unit-test
194 ] with-grafted-gadget
196 { } [ \ + <interactor> manifest>> use-if-necessary ] unit-test
198 { } [ <listener-gadget> "l" set ] unit-test
199 { } [ "l" get com-scroll-up ] unit-test
200 { } [ "l" get com-scroll-down ] unit-test