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 + ] (( -- n )) define-declared
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
53 GENERIC: testing ( a -- b )
54 "IN: words.tests : testing ( -- ) ;" eval( -- )
56 [ f ] [ \ testing generic? ] unit-test
59 : another-forgotten ( -- ) ;
63 FORGET: another-forgotten
64 : another-forgotten ( -- ) ;
68 [ x ] [ undefined? ] must-fail-with
70 [ ] [ "no-loc" "words.tests" create drop ] unit-test
71 [ f ] [ "no-loc" "words.tests" lookup where ] unit-test
73 [ ] [ "IN: words.tests : no-loc-2 ( -- ) ;" eval( -- ) ] unit-test
74 [ f ] [ "no-loc-2" "words.tests" lookup where ] unit-test
76 [ ] [ "IN: words.tests : test-last ( -- ) ;" eval( -- ) ] unit-test
77 [ "test-last" ] [ word name>> ] unit-test
79 "undef-test" "words.tests" lookup [
80 [ forget ] with-compilation-unit
83 [ "IN: words.tests : undef-test ( -- ) ; << undef-test >>" eval( -- ) ]
84 [ error>> undefined? ] must-fail-with
87 "IN: words.tests GENERIC: symbol-generic ( -- )" eval( -- )
91 "IN: words.tests SYMBOL: symbol-generic" eval( -- )
94 [ t ] [ "symbol-generic" "words.tests" lookup symbol? ] unit-test
95 [ f ] [ "symbol-generic" "words.tests" lookup generic? ] unit-test
98 "IN: words.tests GENERIC: symbol-generic ( a -- b )" <string-reader>
99 "symbol-generic-test" parse-stream drop
103 "IN: words.tests TUPLE: symbol-generic ;" <string-reader>
104 "symbol-generic-test" parse-stream drop
107 [ t ] [ "symbol-generic" "words.tests" lookup symbol? ] unit-test
108 [ f ] [ "symbol-generic" "words.tests" lookup generic? ] unit-test
111 [ ] [ "IN: words.tests : decl-forget-test ( -- ) ; foldable" eval( -- ) ] unit-test
112 [ t ] [ "decl-forget-test" "words.tests" lookup "foldable" word-prop ] unit-test
113 [ ] [ "IN: words.tests : decl-forget-test ( -- ) ;" eval( -- ) ] unit-test
114 [ f ] [ "decl-forget-test" "words.tests" lookup "foldable" word-prop ] unit-test
116 [ ] [ "IN: words.tests : decl-forget-test ( -- ) ; flushable" eval( -- ) ] unit-test
117 [ t ] [ "decl-forget-test" "words.tests" lookup "flushable" word-prop ] unit-test
118 [ ] [ "IN: words.tests : decl-forget-test ( -- ) ;" eval( -- ) ] unit-test
119 [ f ] [ "decl-forget-test" "words.tests" lookup "flushable" word-prop ] unit-test
124 "compiled-uses" word-prop
125 keys [ "forgotten" word-prop ] filter
129 [ "hi" word-xt ] must-fail