1 USING: arrays generic kernel math models namespaces sequences assocs
\r
2 tools.test models.compose accessors locals ;
\r
3 IN: models.compose.tests
\r
9 "a" get "b" get 2array <compose> "c" set
\r
12 [ ] [ "c" get activate-model ] unit-test
\r
14 [ { 1 2 } ] [ "c" get value>> ] unit-test
\r
16 [ ] [ 3 "b" get set-model ] unit-test
\r
18 [ { 1 3 } ] [ "c" get value>> ] unit-test
\r
20 [ ] [ { 4 5 } "c" get set-model ] unit-test
\r
22 [ { 4 5 } ] [ "c" get value>> ] unit-test
\r
24 [ ] [ "c" get deactivate-model ] unit-test
\r
26 TUPLE: an-observer { i integer } ;
\r
28 M: an-observer model-changed nip [ 1+ ] change-i drop ;
\r
31 [let* | m1 [ 1 <model> ]
\r
33 c [ { m1 m2 } <compose> ]
\r
34 o1 [ an-observer new ]
\r
35 o2 [ an-observer new ] |
\r
37 o1 m1 add-connection
\r
38 o2 m2 add-connection
\r
42 "OH HAI" m1 set-model
\r