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 grouping ;
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 ] with-compilation-unit ] unit-test
31 "create-test" "scratchpad" lookup "testing" word-prop
35 [ t ] [ \ array? "array?" "arrays" lookup = ] unit-test
37 [ ] [ [ "test-scope" "scratchpad" create drop ] with-compilation-unit ] unit-test
41 "test-scope" "scratchpad" lookup name>>
44 [ t ] [ vocabs array? ] unit-test
45 [ t ] [ vocabs [ words [ word? ] all? ] all? ] unit-test
47 [ f ] [ gensym gensym = ] unit-test
50 [ t ] [ \ a-symbol symbol? ] unit-test
52 ! See if redefining a generic as a colon def clears some
54 GENERIC: testing ( a -- b )
55 "IN: words.tests : testing ( -- ) ;" eval( -- )
57 [ f ] [ \ testing generic? ] unit-test
60 : another-forgotten ( -- ) ;
64 FORGET: another-forgotten
65 : another-forgotten ( -- ) ;
69 [ x ] [ undefined? ] must-fail-with
71 [ ] [ [ "no-loc" "words.tests" create drop ] with-compilation-unit ] unit-test
72 [ f ] [ "no-loc" "words.tests" lookup where ] unit-test
74 [ ] [ "IN: words.tests : no-loc-2 ( -- ) ;" eval( -- ) ] unit-test
75 [ f ] [ "no-loc-2" "words.tests" lookup where ] unit-test
77 [ ] [ "IN: words.tests : test-last ( -- ) ;" eval( -- ) ] unit-test
78 [ "test-last" ] [ word name>> ] unit-test
80 "undef-test" "words.tests" lookup [
81 [ forget ] with-compilation-unit
84 [ "IN: words.tests : undef-test ( -- ) ; << undef-test >>" eval( -- ) ]
85 [ error>> undefined? ] must-fail-with
88 "IN: words.tests GENERIC: symbol-generic ( -- )" eval( -- )
92 "IN: words.tests SYMBOL: symbol-generic" eval( -- )
95 [ t ] [ "symbol-generic" "words.tests" lookup symbol? ] unit-test
96 [ f ] [ "symbol-generic" "words.tests" lookup generic? ] unit-test
99 "IN: words.tests GENERIC: symbol-generic ( a -- b )" <string-reader>
100 "symbol-generic-test" parse-stream drop
104 "IN: words.tests TUPLE: symbol-generic ;" <string-reader>
105 "symbol-generic-test" parse-stream drop
108 [ t ] [ "symbol-generic" "words.tests" lookup symbol? ] unit-test
109 [ f ] [ "symbol-generic" "words.tests" lookup generic? ] unit-test
112 [ ] [ "IN: words.tests : decl-forget-test ( -- ) ; foldable" eval( -- ) ] unit-test
113 [ t ] [ "decl-forget-test" "words.tests" lookup "foldable" word-prop ] unit-test
114 [ ] [ "IN: words.tests : decl-forget-test ( -- ) ;" eval( -- ) ] unit-test
115 [ f ] [ "decl-forget-test" "words.tests" lookup "foldable" word-prop ] unit-test
117 [ ] [ "IN: words.tests : decl-forget-test ( -- ) ; flushable" eval( -- ) ] unit-test
118 [ t ] [ "decl-forget-test" "words.tests" lookup "flushable" word-prop ] unit-test
119 [ ] [ "IN: words.tests : decl-forget-test ( -- ) ;" eval( -- ) ] unit-test
120 [ f ] [ "decl-forget-test" "words.tests" lookup "flushable" word-prop ] unit-test
125 "compiled-uses" word-prop 2 <groups>
126 keys [ "forgotten" word-prop ] filter
130 [ "hi" word-xt ] must-fail