]> gitweb.factorcode.org Git - factor.git/blob - core/vocabs/loader/loader-tests.factor
core: Trim using lists from -tests and clean up a few irregularities.
[factor.git] / core / vocabs / loader / loader-tests.factor
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
6
7 ! This vocab should not exist, but just in case...
8 { } [
9     [
10         "vocabs.loader.test" forget-vocab
11     ] with-compilation-unit
12 ] unit-test
13
14 { T{ vocab-link f "vocabs.loader.test" } }
15 [ "vocabs.loader.test" >vocab-link ] unit-test
16
17 { t }
18 [ "kernel" >vocab-link "kernel" lookup-vocab = ] unit-test
19
20 IN: vocabs.loader.test.2
21
22 : hello ( -- ) ;
23
24 MAIN: hello
25
26 IN: vocabs.loader.tests
27
28 { } [
29     "vocabs.loader.test.2" run
30     "vocabs.loader.test.2" lookup-vocab run
31     "vocabs.loader.test.2" <vocab-link> run
32 ] unit-test
33
34 [
35     "resource:core/vocabs/loader/test/a/a.factor" forget-source
36     "vocabs.loader.test.a" forget-vocab
37 ] with-compilation-unit
38
39 0 "count-me" set-global
40
41 2 [
42     [ "vocabs.loader.test.a" require ] must-fail
43
44     [ f ] [ "vocabs.loader.test.a" lookup-vocab source-loaded?>> ] unit-test
45
46     [ t ] [
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 .
50         swap first in?
51     ] unit-test
52 ] times
53
54 { 2 } [ "count-me" get-global ] unit-test
55
56 [
57     "IN: vocabs.loader.test.a v-l-t-a-hello"
58     <string-reader>
59     "resource:core/vocabs/loader/test/a/a.factor"
60     parse-stream
61 ] [ error>> error>> error>> no-word-error? ] must-fail-with
62
63 0 "count-me" set-global
64
65 { } [
66     [
67         "vocabs.loader.test.b" forget-vocab
68     ] with-compilation-unit
69 ] unit-test
70
71 { f } [ "vocabs.loader.test.b" vocab-files empty? ] unit-test
72
73 { } [
74     [
75         "vocabs.loader.test.b" vocab-files
76         [ forget-source ] each
77     ] with-compilation-unit
78 ] unit-test
79
80 [ "vocabs.loader.test.b" require ] must-fail
81
82 { 1 } [ "count-me" get-global ] unit-test
83
84 { } [
85     [
86         "bob" "vocabs.loader.test.b" create-word
87         [ ] ( -- ) define-declared
88     ] with-compilation-unit
89 ] unit-test
90
91 { } [ "vocabs.loader.test.b" refresh ] unit-test
92
93 { 2 } [ "count-me" get-global ] unit-test
94
95 { f } [ "fred" "vocabs.loader.test.b" lookup-word undefined-word? ] unit-test
96
97 { } [
98     [
99         "vocabs.loader.test.b" vocab-files
100         [ forget-source ] each
101     ] with-compilation-unit
102 ] unit-test
103
104 { } [ "vocabs.loader.test.b" changed-vocab ] unit-test
105
106 { } [ "vocabs.loader.test.b" refresh ] unit-test
107
108 { 3 } [ "count-me" get-global ] unit-test
109
110 { { "resource:core/kernel/kernel.factor" 1 } }
111 [ "kernel" <vocab-link> where ] unit-test
112
113 { { "resource:core/kernel/kernel.factor" 1 } }
114 [ "kernel" lookup-vocab where ] unit-test
115
116 { } [
117     [
118         "vocabs.loader.test.c" forget-vocab
119         "vocabs.loader.test.d" forget-vocab
120     ] with-compilation-unit
121 ] unit-test
122
123 { +done+ } [
124     [ "vocabs.loader.test.d" require ] [ :1 ] recover
125     "vocabs.loader.test.d" lookup-vocab source-loaded?>>
126 ] unit-test
127
128 : forget-junk ( -- )
129     [
130         { "2" "a" "b" "d" "e" "f" }
131         [
132             "vocabs.loader.test." prepend forget-vocab
133         ] each
134     ] with-compilation-unit ;
135
136 forget-junk
137
138 { { } } [
139     "IN: xabbabbja" eval( -- ) "xabbabbja" vocab-files
140 ] unit-test
141
142 [ "xabbabbja" forget-vocab ] with-compilation-unit
143
144 forget-junk
145
146 { } [ [ "vocabs.loader.test.e" forget-vocab ] with-compilation-unit ] unit-test
147
148 0 "vocabs.loader.test.g" set-global
149
150 [
151     "vocabs.loader.test.f" forget-vocab
152     "vocabs.loader.test.g" forget-vocab
153 ] with-compilation-unit
154
155 { } [ "vocabs.loader.test.g" require ] unit-test
156
157 { 1 } [ "vocabs.loader.test.g" get-global ] unit-test
158
159 [
160     "vocabs.loader.test.h" forget-vocab
161     "vocabs.loader.test.i" forget-vocab
162 ] with-compilation-unit
163
164 { } [ "vocabs.loader.test.h" require ] unit-test
165
166
167 [
168     "vocabs.loader.test.j" forget-vocab
169     "vocabs.loader.test.k" forget-vocab
170 ] with-compilation-unit
171
172 { } [ [ "vocabs.loader.test.j" require ] [ drop :1 ] recover ] unit-test
173
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
178
179 [
180     "mno" [ "vocabs.loader.test." swap suffix forget-vocab ] each
181 ] with-compilation-unit
182
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
187
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
191
192 [
193     "mnop" [ "vocabs.loader.test." swap suffix forget-vocab ] each
194 ] with-compilation-unit