1 USING: vocabs.loader tools.test continuations vocabs math
2 kernel arrays sequences namespaces io.streams.string sets
3 parser source-files words assocs classes.tuple definitions
4 debugger compiler.units accessors eval vocabs.hierarchy
5 combinators vocabs.parser grouping vocabs.files vocabs.refresh ;
6 IN: vocabs.loader.tests
8 ! This vocab should not exist, but just in case...
11 "vocabs.loader.test" forget-vocab
12 ] with-compilation-unit
15 { T{ vocab-link f "vocabs.loader.test" } }
16 [ "vocabs.loader.test" >vocab-link ] unit-test
19 [ "kernel" >vocab-link "kernel" lookup-vocab = ] unit-test
21 IN: vocabs.loader.test.2
27 IN: vocabs.loader.tests
30 "vocabs.loader.test.2" run
31 "vocabs.loader.test.2" lookup-vocab run
32 "vocabs.loader.test.2" <vocab-link> run
36 "resource:core/vocabs/loader/test/a/a.factor" forget-source
37 "vocabs.loader.test.a" forget-vocab
38 ] with-compilation-unit
40 0 "count-me" set-global
43 [ "vocabs.loader.test.a" require ] must-fail
45 [ f ] [ "vocabs.loader.test.a" lookup-vocab source-loaded?>> ] unit-test
48 "resource:core/vocabs/loader/test/a/a.factor"
49 path>source-file definitions>> dup USE: prettyprint .
50 "v-l-t-a-hello" "vocabs.loader.test.a" lookup-word dup .
55 { 2 } [ "count-me" get-global ] unit-test
58 "IN: vocabs.loader.test.a v-l-t-a-hello"
60 "resource:core/vocabs/loader/test/a/a.factor"
62 ] [ error>> error>> error>> no-word-error? ] must-fail-with
64 0 "count-me" set-global
68 "vocabs.loader.test.b" forget-vocab
69 ] with-compilation-unit
72 { f } [ "vocabs.loader.test.b" vocab-files empty? ] unit-test
76 "vocabs.loader.test.b" vocab-files
77 [ forget-source ] each
78 ] with-compilation-unit
81 [ "vocabs.loader.test.b" require ] must-fail
83 { 1 } [ "count-me" get-global ] unit-test
87 "bob" "vocabs.loader.test.b" create-word
88 [ ] ( -- ) define-declared
89 ] with-compilation-unit
92 { } [ "vocabs.loader.test.b" refresh ] unit-test
94 { 2 } [ "count-me" get-global ] unit-test
96 { f } [ "fred" "vocabs.loader.test.b" lookup-word undefined-word? ] unit-test
100 "vocabs.loader.test.b" vocab-files
101 [ forget-source ] each
102 ] with-compilation-unit
105 { } [ "vocabs.loader.test.b" changed-vocab ] unit-test
107 { } [ "vocabs.loader.test.b" refresh ] unit-test
109 { 3 } [ "count-me" get-global ] unit-test
111 { { "resource:core/kernel/kernel.factor" 1 } }
112 [ "kernel" <vocab-link> where ] unit-test
114 { { "resource:core/kernel/kernel.factor" 1 } }
115 [ "kernel" lookup-vocab where ] unit-test
119 "vocabs.loader.test.c" forget-vocab
120 "vocabs.loader.test.d" forget-vocab
121 ] with-compilation-unit
125 [ "vocabs.loader.test.d" require ] [ :1 ] recover
126 "vocabs.loader.test.d" lookup-vocab source-loaded?>>
131 { "2" "a" "b" "d" "e" "f" }
133 "vocabs.loader.test." prepend forget-vocab
135 ] with-compilation-unit ;
140 "IN: xabbabbja" eval( -- ) "xabbabbja" vocab-files
143 [ "xabbabbja" forget-vocab ] with-compilation-unit
147 { } [ [ "vocabs.loader.test.e" forget-vocab ] with-compilation-unit ] unit-test
149 0 "vocabs.loader.test.g" set-global
152 "vocabs.loader.test.f" forget-vocab
153 "vocabs.loader.test.g" forget-vocab
154 ] with-compilation-unit
156 { } [ "vocabs.loader.test.g" require ] unit-test
158 { 1 } [ "vocabs.loader.test.g" get-global ] unit-test
161 "vocabs.loader.test.h" forget-vocab
162 "vocabs.loader.test.i" forget-vocab
163 ] with-compilation-unit
165 { } [ "vocabs.loader.test.h" require ] unit-test
169 "vocabs.loader.test.j" forget-vocab
170 "vocabs.loader.test.k" forget-vocab
171 ] with-compilation-unit
173 { } [ [ "vocabs.loader.test.j" require ] [ drop :1 ] recover ] unit-test
175 { } [ "vocabs.loader.test.m" require ] unit-test
176 { f } [ "vocabs.loader.test.n" lookup-vocab ] unit-test
177 { } [ "vocabs.loader.test.o" require ] unit-test
178 { t } [ "vocabs.loader.test.n" lookup-vocab >boolean ] unit-test
181 "mno" [ "vocabs.loader.test." swap suffix forget-vocab ] each
182 ] with-compilation-unit
184 { } [ "vocabs.loader.test.o" require ] unit-test
185 { f } [ "vocabs.loader.test.n" lookup-vocab ] unit-test
186 { } [ "vocabs.loader.test.m" require ] unit-test
187 { t } [ "vocabs.loader.test.n" lookup-vocab >boolean ] unit-test
189 { f } [ "vocabs.loader.test.p" lookup-vocab ] unit-test
190 { } [ "vocabs.loader.test.p.private" require ] unit-test
191 { { "foo" } } [ "vocabs.loader.test.p" vocab-words [ name>> ] map ] unit-test
194 "mnop" [ "vocabs.loader.test." swap suffix forget-vocab ] each
195 ] with-compilation-unit