1 USING: mirrors tools.test assocs kernel arrays accessors words
2 namespaces math slots parser eval ;
9 { 2 } [ 1 2 <foo> <mirror> assoc-size ] unit-test
11 { { "bar" "baz" } } [ 1 2 <foo> <mirror> keys ] unit-test
13 { 1 t } [ "bar" 1 2 <foo> <mirror> at* ] unit-test
15 { f f } [ "hi" 1 2 <foo> <mirror> at* ] unit-test
18 3 "baz" 1 2 <foo> [ <mirror> set-at ] keep baz>>
21 [ 3 "hi" 1 2 <foo> <mirror> set-at ] must-fail
23 [ 3 "numerator" 1/2 <mirror> set-at ] must-fail
33 [ gensym <mirror> [ "compiled" off ] with-variables ] must-fail
35 TUPLE: declared-mirror-test
36 { a integer initial: 0 } ;
39 3 declared-mirror-test boa <mirror> [
45 [ 3 declared-mirror-test boa <mirror> [ t "a" set ] with-variables ] must-fail
52 { T{ color f 0 0 0 } } [
53 1 2 3 color boa [ <mirror> clear-assoc ] keep
56 ! Test reshaping with a mirror
57 1 2 3 color boa <mirror> "mirror" set
59 { } [ "IN: mirrors.tests USE: math TUPLE: color { green integer } { red integer } { blue integer } ;" eval( -- ) ] unit-test
61 { 1 } [ "red" "mirror" get at ] unit-test
63 { 3 } [ { 1 2 3 } make-mirror assoc-size ] unit-test
64 { 2 } [ "asdf" make-mirror assoc-size ] unit-test
65 { 8 } [ \ + make-mirror assoc-size ] unit-test