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 [ \ + make-mirror clear-assoc ] [ mirror-slot-removal? ] must-fail-with
53 [ \ + make-mirror [ "name" ] dip delete-at ] [ mirror-slot-removal? ] must-fail-with
55 ! Test reshaping with a mirror
56 1 2 3 color boa <mirror> "mirror" set
58 { } [ "IN: mirrors.tests USE: math TUPLE: color { green integer } { red integer } { blue integer } ;" eval( -- ) ] unit-test
60 { 1 } [ "red" "mirror" get at ] unit-test
62 { 3 } [ { 1 2 3 } make-mirror assoc-size ] unit-test
63 { 4 } [ "asdf" make-mirror assoc-size ] unit-test
64 { 8 } [ \ + make-mirror assoc-size ] unit-test