]> gitweb.factorcode.org Git - factor.git/blob - basis/ui/gadgets/editors/editors-tests.factor
more test IN: cleanup.
[factor.git] / basis / ui / gadgets / editors / editors-tests.factor
1 USING: accessors ui.gadgets.editors ui.gadgets.editors.private
2 tools.test kernel io io.streams.plain definitions namespaces
3 ui.gadgets ui.gadgets.grids prettyprint documents ui.gestures
4 ui.gadgets.debug models documents.elements ui.gadgets.scrollers
5 ui.gadgets.line-support sequences ;
6
7 { "foo bar" } [
8     <editor> "editor" set
9     "editor" get [
10         "foo bar" "editor" get set-editor-string
11         "editor" get one-line-elt select-elt
12         "editor" get gadget-selection
13     ] with-grafted-gadget
14 ] unit-test
15
16 { "baz quux" } [
17     <editor> "editor" set
18     "editor" get [
19         "foo bar\nbaz quux" "editor" get set-editor-string
20         "editor" get one-line-elt select-elt
21         "editor" get gadget-selection
22     ] with-grafted-gadget
23 ] unit-test
24
25 { } [
26     <editor> "editor" set
27     "editor" get [
28         "foo bar\nbaz quux" "editor" get set-editor-string
29         4 hand-click# set
30         "editor" get position-caret
31     ] with-grafted-gadget
32 ] unit-test
33
34 { "bar" } [
35     <editor> "editor" set
36     "editor" get [
37         "bar\nbaz quux" "editor" get set-editor-string
38         { 0 3 } "editor" get caret>> set-model
39         "editor" get select-word
40         "editor" get gadget-selection
41     ] with-grafted-gadget
42 ] unit-test
43
44 "hello" <model> <model-field> "field" set
45
46 "field" get [
47     [ "hello" ] [ "field" get field-model>> value>> ] unit-test
48 ] with-grafted-gadget
49
50 { "Hello world." } [ "Hello    \n    world." join-lines ] unit-test
51 { "  Hello world.  " } [ "  Hello    \n    world.  " join-lines ] unit-test
52 { "  Hello world. Goodbye." } [ "  Hello    \n    world.  \n  Goodbye." join-lines ] unit-test
53
54 { } [ <editor> com-join-lines ] unit-test
55 { } [ <editor> "A" over set-editor-string com-join-lines ] unit-test
56 { "A B" } [ <editor> "A\nB" over set-editor-string [ com-join-lines ] [ editor-string ] bi ] unit-test
57 { "A B\nC\nD" } [ <editor> "A\nB\nC\nD" over set-editor-string { 0 0 } over set-caret dup mark>caret [ com-join-lines ] [ editor-string ] bi ] unit-test
58 { "A\nB C\nD" } [ <editor> "A\nB\nC\nD" over set-editor-string { 1 0 } over set-caret dup mark>caret [ com-join-lines ] [ editor-string ] bi ] unit-test
59 { "A\nB\nC D" } [ <editor> "A\nB\nC\nD" over set-editor-string { 2 0 } over set-caret dup mark>caret [ com-join-lines ] [ editor-string ] bi ] unit-test
60
61 { 2 } [ <editor> 20 >>min-rows 20 >>min-cols pref-viewport-dim length ] unit-test
62
63 { 20 } [
64     <editor> 20 >>min-rows 20 >>min-cols
65     dup pref-viewport-dim >>dim
66     visible-lines
67 ] unit-test