]> gitweb.factorcode.org Git - factor.git/blob - basis/ui/traverse/traverse-tests.factor
Fix permission bits
[factor.git] / basis / ui / traverse / traverse-tests.factor
1 USING: accessors ui.gadgets ui.gadgets.labels namespaces make
2 sequences kernel math arrays tools.test io ui.gadgets.panes
3 ui.traverse definitions compiler.units ;
4 IN: ui.traverse.tests
5
6 M: array children>> ;
7
8 GENERIC: (flatten-tree) ( node -- )
9
10 M: node (flatten-tree)
11     children>> [ (flatten-tree) ] each ;
12
13 M: object (flatten-tree) , ;
14
15 : flatten-tree ( seq -- newseq )
16     [ [ (flatten-tree) ] each ] { } make ;
17
18 : gadgets-in-range ( frompath topath gadget -- seq )
19     gadget-subtree flatten-tree ;
20
21 [ { "a" "b" "c" "d" } ] [
22     { 0 } { } { "a" "b" "c" "d" } gadgets-in-range
23 ] unit-test
24
25 [ { "a" "b" } ] [
26     { } { 1 } { "a" "b" "c" "d" } gadgets-in-range
27 ] unit-test
28
29 [ { "a" } ] [
30     { 0 } { 0 } { "a" "b" "c" "d" } gadgets-in-range
31 ] unit-test
32
33 [ { "a" "b" "c" } ] [
34     { 0 } { 2 } { "a" "b" "c" "d" } gadgets-in-range
35 ] unit-test
36
37 [ { "a" "b" "c" "d" } ] [
38     { 0 } { 3 } { "a" "b" "c" "d" } gadgets-in-range
39 ] unit-test
40
41 [ { "a" "b" "c" "d" } ] [
42     { 0 0 } { 0 3 } { { "a" "b" "c" "d" } } gadgets-in-range
43 ] unit-test
44
45 [ { "b" "c" "d" "e" } ] [
46     { 0 1 } { 1 } { { "a" "b" "c" "d" } "e" } gadgets-in-range
47 ] unit-test
48
49 [ { "b" "c" "d" "e" "f" } ] [
50     { 0 1 } { 1 1 } { { "a" "b" "c" "d" } { "e" "f" "g" } } gadgets-in-range
51 ] unit-test
52
53 [ { "b" "c" "d" { "e" "f" "g" } "h" "i" } ] [
54     { 0 1 } { 2 1 } { { "a" "b" "c" "d" } { "e" "f" "g" } { "h" "i" } } gadgets-in-range
55 ] unit-test
56
57 [ { "b" "c" "d" { "e" "f" "g" } "h" } ] [
58     { 0 1 } { 2 0 0 } { { "a" "b" "c" "d" } { "e" "f" "g" } { { "h" "i" } "j" } } gadgets-in-range
59 ] unit-test
60
61 [ { "b" "c" "d" { "e" "f" "g" } "h" "i" } ] [
62     { 0 1 } { 2 0 1 } { { "a" "b" "c" "d" } { "e" "f" "g" } { { "h" "i" } "j" } } gadgets-in-range
63 ] unit-test
64
65 [ { array children>> } forget ] with-compilation-unit