1 USING: accessors compiler.units continuations debugger
2 definitions eval io.streams.string kernel math namespaces parser
3 prettyprint sequences sets source-files tools.test vocabs
4 vocabs.files vocabs.loader vocabs.parser vocabs.refresh words ;
5 IN: vocabs.loader.tests
7 ! This vocab should not exist, but just in case...
10 "vocabs.loader.test" forget-vocab
11 ] with-compilation-unit
14 { T{ vocab-link f "vocabs.loader.test" } }
15 [ "vocabs.loader.test" >vocab-link ] unit-test
18 [ "kernel" >vocab-link "kernel" lookup-vocab = ] unit-test
20 IN: vocabs.loader.test.2
26 IN: vocabs.loader.tests
29 "vocabs.loader.test.2" run
30 "vocabs.loader.test.2" lookup-vocab run
31 "vocabs.loader.test.2" <vocab-link> run
35 "resource:core/vocabs/loader/test/a/a.factor" forget-source
36 "vocabs.loader.test.a" forget-vocab
37 ] with-compilation-unit
39 0 "count-me" set-global
42 [ "vocabs.loader.test.a" require ] must-fail
44 [ f ] [ "vocabs.loader.test.a" lookup-vocab source-loaded?>> ] unit-test
47 "resource:core/vocabs/loader/test/a/a.factor"
48 path>source-file definitions>>
49 "v-l-t-a-hello" "vocabs.loader.test.a" lookup-word dup .
54 { 2 } [ "count-me" get-global ] unit-test
57 "IN: vocabs.loader.test.a v-l-t-a-hello"
59 "resource:core/vocabs/loader/test/a/a.factor"
61 ] [ error>> error>> error>> no-word-error? ] must-fail-with
63 0 "count-me" set-global
67 "vocabs.loader.test.b" forget-vocab
68 ] with-compilation-unit
71 { f } [ "vocabs.loader.test.b" vocab-files empty? ] unit-test
75 "vocabs.loader.test.b" vocab-files
76 [ forget-source ] each
77 ] with-compilation-unit
80 [ "vocabs.loader.test.b" require ] must-fail
82 { 1 } [ "count-me" get-global ] unit-test
86 "bob" "vocabs.loader.test.b" create-word
87 [ ] ( -- ) define-declared
88 ] with-compilation-unit
91 { } [ "vocabs.loader.test.b" refresh ] unit-test
93 { 2 } [ "count-me" get-global ] unit-test
95 { f } [ "fred" "vocabs.loader.test.b" lookup-word undefined-word? ] unit-test
99 "vocabs.loader.test.b" vocab-files
100 [ forget-source ] each
101 ] with-compilation-unit
104 { } [ "vocabs.loader.test.b" changed-vocab ] unit-test
106 { } [ "vocabs.loader.test.b" refresh ] unit-test
108 { 3 } [ "count-me" get-global ] unit-test
110 { { "resource:core/kernel/kernel.factor" 1 } }
111 [ "kernel" <vocab-link> where ] unit-test
113 { { "resource:core/kernel/kernel.factor" 1 } }
114 [ "kernel" lookup-vocab where ] unit-test
118 "vocabs.loader.test.c" forget-vocab
119 "vocabs.loader.test.d" forget-vocab
120 ] with-compilation-unit
124 [ "vocabs.loader.test.d" require ] [ :1 ] recover
125 "vocabs.loader.test.d" lookup-vocab source-loaded?>>
130 { "2" "a" "b" "d" "e" "f" }
132 "vocabs.loader.test." prepend forget-vocab
134 ] with-compilation-unit ;
139 "IN: xabbabbja" eval( -- ) "xabbabbja" vocab-files
142 [ "xabbabbja" forget-vocab ] with-compilation-unit
146 { } [ [ "vocabs.loader.test.e" forget-vocab ] with-compilation-unit ] unit-test
148 0 "vocabs.loader.test.g" set-global
151 "vocabs.loader.test.f" forget-vocab
152 "vocabs.loader.test.g" forget-vocab
153 ] with-compilation-unit
155 { } [ "vocabs.loader.test.g" require ] unit-test
157 { 1 } [ "vocabs.loader.test.g" get-global ] unit-test
160 "vocabs.loader.test.h" forget-vocab
161 "vocabs.loader.test.i" forget-vocab
162 ] with-compilation-unit
164 { } [ "vocabs.loader.test.h" require ] unit-test
168 "vocabs.loader.test.j" forget-vocab
169 "vocabs.loader.test.k" forget-vocab
170 ] with-compilation-unit
172 { } [ [ "vocabs.loader.test.j" require ] [ drop :1 ] recover ] unit-test
174 { } [ "vocabs.loader.test.m" require ] unit-test
175 { f } [ "vocabs.loader.test.n" lookup-vocab ] unit-test
176 { } [ "vocabs.loader.test.o" require ] unit-test
177 { t } [ "vocabs.loader.test.n" lookup-vocab >boolean ] unit-test
180 "mno" [ "vocabs.loader.test." swap suffix forget-vocab ] each
181 ] with-compilation-unit
183 { } [ "vocabs.loader.test.o" require ] unit-test
184 { f } [ "vocabs.loader.test.n" lookup-vocab ] unit-test
185 { } [ "vocabs.loader.test.m" require ] unit-test
186 { t } [ "vocabs.loader.test.n" lookup-vocab >boolean ] unit-test
188 { f } [ "vocabs.loader.test.p" lookup-vocab ] unit-test
189 { } [ "vocabs.loader.test.p.private" require ] unit-test
190 { { "foo" } } [ "vocabs.loader.test.p" vocab-words [ name>> ] map ] unit-test
193 "mnop" [ "vocabs.loader.test." swap suffix forget-vocab ] each
194 ] with-compilation-unit