]> gitweb.factorcode.org Git - factor.git/blob - core/slots/slots-tests.factor
Merge branch 'master' into experimental
[factor.git] / core / slots / slots-tests.factor
1 IN: slots.tests
2 USING: math accessors slots strings generic.standard kernel
3 tools.test generic words parser eval ;
4
5 TUPLE: r/w-test foo ;
6
7 TUPLE: r/o-test { foo read-only } ;
8
9 [ r/o-test new 123 >>foo ] [ no-method? ] must-fail-with
10
11 TUPLE: decl-test { foo integer } ;
12
13 [ decl-test new 1.0 >>foo ] [ bad-slot-value? ] must-fail-with
14
15 TUPLE: hello length ;
16
17 [ 3 ] [ "xyz" length>> ] unit-test
18
19 [ "xyz" 4 >>length ] [ no-method? ] must-fail-with
20
21 [ t ] [ r/o-test \ foo>> method "foldable" word-prop ] unit-test
22 [ t ] [ r/o-test \ foo>> method "flushable" word-prop ] unit-test
23
24 [ f ] [ r/w-test \ foo>> method "foldable" word-prop ] unit-test
25 [ t ] [ r/w-test \ foo>> method "flushable" word-prop ] unit-test
26
27 ! See if declarations are cleared on redefinition
28 [ ] [ "IN: slots.tests TUPLE: r/w-test { foo read-only } ;" eval ] unit-test
29
30 [ t ] [ r/w-test \ foo>> method "foldable" word-prop ] unit-test
31 [ t ] [ r/w-test \ foo>> method "flushable" word-prop ] unit-test
32
33 [ ] [ "IN: slots.tests TUPLE: r/w-test foo ;" eval ] unit-test
34
35 [ f ] [ r/w-test \ foo>> method "foldable" word-prop ] unit-test
36 [ t ] [ r/w-test \ foo>> method "flushable" word-prop ] unit-test