1 USING: assocs classes classes.private compiler.units definitions
2 eval generic io.streams.string kernel math multiline namespaces
3 parser sequences sets sorting tools.test vocabs words ;
6 { t } [ 3 object instance? ] unit-test
7 { t } [ 3 fixnum instance? ] unit-test
8 { f } [ 3 float instance? ] unit-test
9 { t } [ 3 number instance? ] unit-test
10 { f } [ 3 null instance? ] unit-test
13 GENERIC: method-forget-test ( obj -- obj )
14 TUPLE: method-forget-class ;
15 M: method-forget-class method-forget-test ;
17 { f } [ \ method-forget-test "methods" word-prop assoc-empty? ] unit-test
18 { } [ [ \ method-forget-class forget ] with-compilation-unit ] unit-test
19 { t } [ \ method-forget-test "methods" word-prop assoc-empty? ] unit-test
22 all-words [ class? ] filter
23 implementors-map get keys
25 [ diff ] [ swap diff ] 2bi
28 ! Long-standing problem
31 ! So the user has some code...
37 TUPLE: z < x ;" <string-reader>
38 "class-intersect-no-method-a" parse-stream drop
41 ! Note that q inlines M: x g ;
46 : q ( -- b ) z new g ;" <string-reader>
47 "class-intersect-no-method-b" parse-stream drop
50 ! Now, the user removes the z class and adds a method,
57 M: j g ;" <string-reader>
58 "class-intersect-no-method-a" parse-stream drop
61 ! And changes the definition of q
66 : q ( -- b ) j new g ;" <string-reader>
67 "class-intersect-no-method-b" parse-stream drop
70 ! Similar problem, but with anonymous classes
76 TUPLE: z ;" <string-reader>
77 "class-intersect-no-method-c" parse-stream drop
84 : q ( a -- b ) dup z? [ g ] unless ;" <string-reader>
85 "class-intersect-no-method-d" parse-stream drop
88 ! Now, the user removes the z class and adds a method,
95 M: j g ;" <string-reader>
96 "class-intersect-no-method-c" parse-stream drop
99 ! Forget the above crap
101 { "classes.test.a" "classes.test.b" "classes.test.c" "classes.test.d" }
102 [ forget-vocab ] each
103 ] with-compilation-unit
105 TUPLE: forgotten-predicate-test ;
107 { } [ [ \ forgotten-predicate-test forget ] with-compilation-unit ] unit-test
108 { f } [ \ forgotten-predicate-test? predicate? ] unit-test
110 GENERIC: generic-predicate? ( a -- b )
112 { } [ "IN: classes.tests TUPLE: generic-predicate ;" eval( -- ) ] unit-test
114 { f } [ \ generic-predicate? generic? ] unit-test
116 ! all-contained-classes
118 { maybe{ integer } integer fixnum bignum }
120 { maybe{ integer } } all-contained-classes
128 integer contained-classes
129 maybe{ integer } contained-classes
136 { "members" { fixnum } }
138 { "participants" { } }
141 f { fixnum } { } f make-class-props
144 { "test" } [ "test" sequence check-instance ] unit-test
145 [ "test" fixnum check-instance ] [ not-an-instance? ] must-fail-with