factor/basis/ui/traverse/traverse-tests.factor

64 lines
1.7 KiB
Factor
Raw Normal View History

2017-10-25 22:00:47 -04:00
USING: accessors arrays compiler.units definitions kernel make
sequences tools.test ui.traverse ;
2008-09-01 08:14:43 -04:00
IN: ui.traverse.tests
M: array children>> ;
2007-09-20 18:09:08 -04:00
2017-10-25 22:00:47 -04:00
GENERIC: flatten-tree% ( node -- )
2007-09-20 18:09:08 -04:00
2017-10-25 22:00:47 -04:00
M: node flatten-tree% children>> [ flatten-tree% ] each ;
2007-09-20 18:09:08 -04:00
2017-10-25 22:00:47 -04:00
M: object flatten-tree% , ;
2007-09-20 18:09:08 -04:00
: flatten-tree ( seq -- newseq )
2017-10-25 22:00:47 -04:00
[ [ flatten-tree% ] each ] { } make ;
2007-09-20 18:09:08 -04:00
: gadgets-in-range ( frompath topath gadget -- seq )
gadget-subtree flatten-tree ;
{ { "a" "b" "c" "d" } } [
2007-09-20 18:09:08 -04:00
{ 0 } { } { "a" "b" "c" "d" } gadgets-in-range
] unit-test
{ { "a" "b" } } [
2007-09-20 18:09:08 -04:00
{ } { 1 } { "a" "b" "c" "d" } gadgets-in-range
] unit-test
{ { "a" } } [
2007-09-20 18:09:08 -04:00
{ 0 } { 0 } { "a" "b" "c" "d" } gadgets-in-range
] unit-test
{ { "a" "b" "c" } } [
2007-09-20 18:09:08 -04:00
{ 0 } { 2 } { "a" "b" "c" "d" } gadgets-in-range
] unit-test
{ { "a" "b" "c" "d" } } [
2007-09-20 18:09:08 -04:00
{ 0 } { 3 } { "a" "b" "c" "d" } gadgets-in-range
] unit-test
{ { "a" "b" "c" "d" } } [
2007-09-20 18:09:08 -04:00
{ 0 0 } { 0 3 } { { "a" "b" "c" "d" } } gadgets-in-range
] unit-test
{ { "b" "c" "d" "e" } } [
2007-09-20 18:09:08 -04:00
{ 0 1 } { 1 } { { "a" "b" "c" "d" } "e" } gadgets-in-range
] unit-test
{ { "b" "c" "d" "e" "f" } } [
2007-09-20 18:09:08 -04:00
{ 0 1 } { 1 1 } { { "a" "b" "c" "d" } { "e" "f" "g" } } gadgets-in-range
] unit-test
{ { "b" "c" "d" { "e" "f" "g" } "h" "i" } } [
2007-09-20 18:09:08 -04:00
{ 0 1 } { 2 1 } { { "a" "b" "c" "d" } { "e" "f" "g" } { "h" "i" } } gadgets-in-range
] unit-test
{ { "b" "c" "d" { "e" "f" "g" } "h" } } [
2007-09-20 18:09:08 -04:00
{ 0 1 } { 2 0 0 } { { "a" "b" "c" "d" } { "e" "f" "g" } { { "h" "i" } "j" } } gadgets-in-range
] unit-test
{ { "b" "c" "d" { "e" "f" "g" } "h" "i" } } [
2007-09-20 18:09:08 -04:00
{ 0 1 } { 2 0 1 } { { "a" "b" "c" "d" } { "e" "f" "g" } { { "h" "i" } "j" } } gadgets-in-range
] unit-test
2009-04-06 06:22:28 -04:00
[ M\ array children>> forget ] with-compilation-unit