factor/core/slots/slots-tests.factor

37 lines
1.1 KiB
Factor
Raw Normal View History

IN: slots.tests
2008-06-29 22:37:57 -04:00
USING: math accessors slots strings generic.standard kernel
tools.test generic words parser ;
TUPLE: r/w-test foo ;
2008-06-30 02:44:58 -04:00
TUPLE: r/o-test { foo read-only } ;
[ r/o-test new 123 >>foo ] [ no-method? ] must-fail-with
2008-06-29 22:37:57 -04:00
TUPLE: decl-test { foo integer } ;
[ decl-test new 1.0 >>foo ] [ bad-slot-value? ] must-fail-with
TUPLE: hello length ;
[ 3 ] [ "xyz" length>> ] unit-test
[ "xyz" 4 >>length ] [ no-method? ] must-fail-with
2008-06-29 22:37:57 -04:00
[ t ] [ r/o-test \ foo>> method "foldable" word-prop ] unit-test
[ t ] [ r/o-test \ foo>> method "flushable" word-prop ] unit-test
[ f ] [ r/w-test \ foo>> method "foldable" word-prop ] unit-test
[ t ] [ r/w-test \ foo>> method "flushable" word-prop ] unit-test
! See if declarations are cleared on redefinition
2008-06-30 02:44:58 -04:00
[ ] [ "IN: slots.tests TUPLE: r/w-test { foo read-only } ;" eval ] unit-test
2008-06-29 22:37:57 -04:00
[ t ] [ r/w-test \ foo>> method "foldable" word-prop ] unit-test
[ t ] [ r/w-test \ foo>> method "flushable" word-prop ] unit-test
2008-06-30 02:44:58 -04:00
[ ] [ "IN: slots.tests TUPLE: r/w-test foo ;" eval ] unit-test
2008-06-29 22:37:57 -04:00
[ f ] [ r/w-test \ foo>> method "foldable" word-prop ] unit-test
[ t ] [ r/w-test \ foo>> method "flushable" word-prop ] unit-test