1 USING: alien arrays definitions generic assocs hashtables io
2 io.streams.string kernel math namespaces parser prettyprint
3 sequences strings tools.test vectors words quotations classes
4 classes.private classes.union classes.mixin classes.predicate
5 classes.algebra vectors definitions source-files compiler.units
6 kernel.private sorting vocabs memory eval accessors ;
9 [ t ] [ 3 object instance? ] unit-test
10 [ t ] [ 3 fixnum instance? ] unit-test
11 [ f ] [ 3 float instance? ] unit-test
12 [ t ] [ 3 number instance? ] unit-test
13 [ f ] [ 3 null instance? ] unit-test
14 [ t ] [ "hi" \ hi-tag instance? ] unit-test
17 GENERIC: method-forget-test ( obj -- obj )
18 TUPLE: method-forget-class ;
19 M: method-forget-class method-forget-test ;
21 [ f ] [ \ method-forget-test "methods" word-prop assoc-empty? ] unit-test
22 [ ] [ [ \ method-forget-class forget ] with-compilation-unit ] unit-test
23 [ t ] [ \ method-forget-test "methods" word-prop assoc-empty? ] unit-test
26 all-words [ class? ] filter
27 implementors-map get keys
28 [ natural-sort ] bi@ =
32 [ ] [ "IN: classes.tests TUPLE: forget-me ;" eval ] unit-test
33 [ ] [ f \ word set-global ] unit-test
34 [ ] [ "IN: classes.tests USE: kernel USE: classes.algebra forget-me tuple class<= drop" eval ] unit-test
35 [ ] [ "IN: classes.tests FORGET: forget-me" eval ] unit-test
38 [ [ name>> "forget-me" = ] [ vocabulary>> "classes.tests" = ] bi and ] count
41 ! Long-standing problem
44 ! So the user has some code...
50 TUPLE: z < x ;"> <string-reader>
51 "class-intersect-no-method-a" parse-stream drop
54 ! Note that q inlines M: x g ;
59 : q ( -- b ) z new g ;"> <string-reader>
60 "class-intersect-no-method-b" parse-stream drop
63 ! Now, the user removes the z class and adds a method,
70 M: j g ;"> <string-reader>
71 "class-intersect-no-method-a" parse-stream drop
74 ! And changes the definition of q
79 : q ( -- b ) j new g ;"> <string-reader>
80 "class-intersect-no-method-b" parse-stream drop
83 ! Similar problem, but with anonymous classes
89 TUPLE: z ;"> <string-reader>
90 "class-intersect-no-method-c" parse-stream drop
97 : q ( a -- b ) dup z? [ g ] unless ;"> <string-reader>
98 "class-intersect-no-method-d" parse-stream drop
101 ! Now, the user removes the z class and adds a method,
103 <" IN: classes.test.c
105 GENERIC: g ( a -- b )
108 M: j g ;"> <string-reader>
109 "class-intersect-no-method-c" parse-stream drop
112 TUPLE: forgotten-predicate-test ;
114 [ ] [ [ \ forgotten-predicate-test forget ] with-compilation-unit ] unit-test
115 [ f ] [ \ forgotten-predicate-test? predicate? ] unit-test