]> gitweb.factorcode.org Git - factor.git/blob - core/vocabs/loader/loader-tests.factor
factor: rename [ ] [ ] unit-test -> { } [ ] unit-test using a refactoring tool!
[factor.git] / core / vocabs / loader / loader-tests.factor
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
7
8 ! This vocab should not exist, but just in case...
9 { } [
10     [
11         "vocabs.loader.test" forget-vocab
12     ] with-compilation-unit
13 ] unit-test
14
15 { T{ vocab-link f "vocabs.loader.test" } }
16 [ "vocabs.loader.test" >vocab-link ] unit-test
17
18 { t }
19 [ "kernel" >vocab-link "kernel" lookup-vocab = ] unit-test
20
21 IN: vocabs.loader.test.2
22
23 : hello ( -- ) ;
24
25 MAIN: hello
26
27 IN: vocabs.loader.tests
28
29 { } [
30     "vocabs.loader.test.2" run
31     "vocabs.loader.test.2" lookup-vocab run
32     "vocabs.loader.test.2" <vocab-link> run
33 ] unit-test
34
35 [
36     "resource:core/vocabs/loader/test/a/a.factor" forget-source
37     "vocabs.loader.test.a" forget-vocab
38 ] with-compilation-unit
39
40 0 "count-me" set-global
41
42 2 [
43     [ "vocabs.loader.test.a" require ] must-fail
44
45     [ f ] [ "vocabs.loader.test.a" lookup-vocab source-loaded?>> ] unit-test
46
47     [ t ] [
48         "resource:core/vocabs/loader/test/a/a.factor"
49         source-file definitions>> dup USE: prettyprint .
50         "v-l-t-a-hello" "vocabs.loader.test.a" lookup-word dup .
51         swap first in?
52     ] unit-test
53 ] times
54
55 { 2 } [ "count-me" get-global ] unit-test
56
57 [
58     "IN: vocabs.loader.test.a v-l-t-a-hello"
59     <string-reader>
60     "resource:core/vocabs/loader/test/a/a.factor"
61     parse-stream
62 ] [ error>> error>> error>> no-word-error? ] must-fail-with
63
64 0 "count-me" set-global
65
66 { } [
67     [
68         "vocabs.loader.test.b" forget-vocab
69     ] with-compilation-unit
70 ] unit-test
71
72 { f } [ "vocabs.loader.test.b" vocab-files empty? ] unit-test
73
74 { } [
75     [
76         "vocabs.loader.test.b" vocab-files
77         [ forget-source ] each
78     ] with-compilation-unit
79 ] unit-test
80
81 [ "vocabs.loader.test.b" require ] must-fail
82
83 { 1 } [ "count-me" get-global ] unit-test
84
85 { } [
86     [
87         "bob" "vocabs.loader.test.b" create-word [ ] define
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