1 USING: arrays generic assocs kernel math namespaces
2 sequences tools.test words definitions parser quotations
3 vocabs continuations classes.tuple compiler.units
4 io.streams.string accessors eval words.symbol ;
9 "poo" "words.tests" create [ 2 2 + ] define
10 ] with-compilation-unit
11 "poo" "words.tests" lookup execute
14 [ t ] [ t vocabs [ words [ word? and ] each ] each ] unit-test
19 \ plist-test t "sample-property" set-word-prop
20 \ plist-test "sample-property" word-prop
24 \ plist-test f "sample-property" set-word-prop
25 \ plist-test "sample-property" word-prop
28 "create-test" "scratchpad" create { 1 2 } "testing" set-word-prop
30 "create-test" "scratchpad" lookup "testing" word-prop
34 [ t ] [ \ array? "array?" "arrays" lookup = ] unit-test
36 [ ] [ "test-scope" "scratchpad" create drop ] unit-test
40 "test-scope" "scratchpad" lookup name>>
43 [ t ] [ vocabs array? ] unit-test
44 [ t ] [ vocabs [ words [ word? ] all? ] all? ] unit-test
46 [ f ] [ gensym gensym = ] unit-test
49 [ t ] [ \ a-symbol symbol? ] unit-test
51 ! See if redefining a generic as a colon def clears some
54 "IN: words.tests : testing ;" eval
56 [ f ] [ \ testing generic? ] unit-test
63 FORGET: another-forgotten
66 ! I forgot remove-crossref calls!
71 [ t ] [ \ fee usage [ word? ] filter empty? ] unit-test
72 [ t ] [ \ foe usage empty? ] unit-test
73 [ f ] [ \ foe crossref get key? ] unit-test
77 ! xref should not retain references to gensyms
79 [ gensym [ * ] define ] with-compilation-unit
83 \ * usage [ word? ] filter [ crossref? ] all?
90 gensym dup "x" set 1quotation
92 ] with-compilation-unit
95 [ f ] [ "x" get crossref get at ] unit-test
99 GENERIC: xyzzle ( x -- x )
101 M: integer xyzzle a ;
108 GENERIC: freakish ( x -- y )
111 [ t ] [ \ bar \ freakish usage member? ] unit-test
114 [ x ] [ undefined? ] must-fail-with
116 [ ] [ "no-loc" "words.tests" create drop ] unit-test
117 [ f ] [ "no-loc" "words.tests" lookup where ] unit-test
119 [ ] [ "IN: words.tests : no-loc-2 ;" eval ] unit-test
120 [ f ] [ "no-loc-2" "words.tests" lookup where ] unit-test
122 [ ] [ "IN: words.tests : test-last ( -- ) ;" eval ] unit-test
123 [ "test-last" ] [ word name>> ] unit-test
131 quot-uses-a [ 2 3 + ] define
132 ] with-compilation-unit
135 [ { + } ] [ \ quot-uses-a uses ] unit-test
139 quot-uses-b 2 [ 3 + ] curry define
140 ] with-compilation-unit
143 [ { + } ] [ \ quot-uses-b uses ] unit-test
145 "undef-test" "words.tests" lookup [
146 [ forget ] with-compilation-unit
149 [ "IN: words.tests : undef-test ; << undef-test >>" eval ]
150 [ error>> undefined? ] must-fail-with
153 "IN: words.tests GENERIC: symbol-generic" eval
157 "IN: words.tests SYMBOL: symbol-generic" eval
160 [ t ] [ "symbol-generic" "words.tests" lookup symbol? ] unit-test
161 [ f ] [ "symbol-generic" "words.tests" lookup generic? ] unit-test
164 "IN: words.tests GENERIC: symbol-generic" <string-reader>
165 "symbol-generic-test" parse-stream drop
169 "IN: words.tests TUPLE: symbol-generic ;" <string-reader>
170 "symbol-generic-test" parse-stream drop
173 [ t ] [ "symbol-generic" "words.tests" lookup symbol? ] unit-test
174 [ f ] [ "symbol-generic" "words.tests" lookup generic? ] unit-test
177 [ ] [ "IN: words.tests : decl-forget-test ; foldable" eval ] unit-test
178 [ t ] [ "decl-forget-test" "words.tests" lookup "foldable" word-prop ] unit-test
179 [ ] [ "IN: words.tests : decl-forget-test ;" eval ] unit-test
180 [ f ] [ "decl-forget-test" "words.tests" lookup "foldable" word-prop ] unit-test
182 [ ] [ "IN: words.tests : decl-forget-test ; flushable" eval ] unit-test
183 [ t ] [ "decl-forget-test" "words.tests" lookup "flushable" word-prop ] unit-test
184 [ ] [ "IN: words.tests : decl-forget-test ;" eval ] unit-test
185 [ f ] [ "decl-forget-test" "words.tests" lookup "flushable" word-prop ] unit-test
190 "compiled-uses" word-prop
191 keys [ "forgotten" word-prop ] contains?
197 [ word? ] filter [ "forgotten" word-prop ] filter