Updating non-core libraries for monotonic? change
[factor/jcg.git] / core / vocabs / loader / loader-tests.factor
blobcb4a0b50aa9c78f176f162ce25705ced54d78911
1 IN: vocabs.loader.tests
2 USING: vocabs.loader tools.test continuations vocabs math
3 kernel arrays sequences namespaces io.streams.string
4 parser source-files words assocs classes.tuple definitions
5 debugger compiler.units tools.vocabs accessors eval
6 combinators vocabs.parser grouping ;
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
15 [ T{ vocab-link f "vocabs.loader.test" } ]
16 [ "vocabs.loader.test" >vocab-link ] unit-test
18 [ t ]
19 [ "kernel" >vocab-link "kernel" vocab = ] unit-test
21 [ t ] [
22     "kernel" vocab-files
23     "kernel" vocab vocab-files
24     "kernel" <vocab-link> vocab-files
25     3array all-equal?
26 ] unit-test
28 IN: vocabs.loader.test.2
30 : hello 3 ;
32 MAIN: hello
34 IN: vocabs.loader.tests
36 [ { 3 3 3 } ] [
37     "vocabs.loader.test.2" run
38     "vocabs.loader.test.2" vocab run
39     "vocabs.loader.test.2" <vocab-link> run
40     3array
41 ] unit-test
45     "resource:core/vocabs/loader/test/a/a.factor" forget-source
46     "vocabs.loader.test.a" forget-vocab
47 ] with-compilation-unit
49 0 "count-me" set-global
51 2 [
52     [ "vocabs.loader.test.a" require ] must-fail
53     
54     [ f ] [ "vocabs.loader.test.a" vocab source-loaded?>> ] unit-test
55     
56     [ t ] [
57         "resource:core/vocabs/loader/test/a/a.factor"
58         source-file definitions>> dup USE: prettyprint .
59         "v-l-t-a-hello" "vocabs.loader.test.a" lookup dup .
60         swap first key?
61     ] unit-test
62 ] times
64 [ 2 ] [ "count-me" get-global ] unit-test
67     "IN: vocabs.loader.test.a v-l-t-a-hello"
68     <string-reader>
69     "resource:core/vocabs/loader/test/a/a.factor"
70     parse-stream
71 ] [ error>> error>> error>> no-word-error? ] must-fail-with
73 0 "count-me" set-global
75 [ ] [
76     [
77         "vocabs.loader.test.b" forget-vocab
78     ] with-compilation-unit
79 ] unit-test
81 [ f ] [ "vocabs.loader.test.b" vocab-files empty? ] unit-test
83 [ ] [
84     [
85         "vocabs.loader.test.b" vocab-files
86         [ forget-source ] each
87     ] with-compilation-unit
88 ] unit-test
90 [ "vocabs.loader.test.b" require ] must-fail
92 [ 1 ] [ "count-me" get-global ] unit-test
94 [ ] [
95     [
96         "bob" "vocabs.loader.test.b" create [ ] define
97     ] with-compilation-unit
98 ] unit-test
100 [ ] [ "vocabs.loader.test.b" refresh ] unit-test
102 [ 2 ] [ "count-me" get-global ] unit-test
104 [ f ] [ "fred" "vocabs.loader.test.b" lookup undefined? ] unit-test
106 [ ] [
107     [
108         "vocabs.loader.test.b" vocab-files
109         [ forget-source ] each
110     ] with-compilation-unit
111 ] unit-test
113 [ ] [ "vocabs.loader.test.b" changed-vocab ] unit-test
115 [ ] [ "vocabs.loader.test.b" refresh ] unit-test
117 [ 3 ] [ "count-me" get-global ] unit-test
119 [ { "resource:core/kernel/kernel.factor" 1 } ]
120 [ "kernel" <vocab-link> where ] unit-test
122 [ { "resource:core/kernel/kernel.factor" 1 } ]
123 [ "kernel" vocab where ] unit-test
125 [ ] [
126     [
127         "vocabs.loader.test.c" forget-vocab
128         "vocabs.loader.test.d" forget-vocab
129     ] with-compilation-unit
130 ] unit-test
132 [ +done+ ] [
133     [ "vocabs.loader.test.d" require ] [ :1 ] recover
134     "vocabs.loader.test.d" vocab source-loaded?>>
135 ] unit-test
137 : forget-junk
138     [
139         { "2" "a" "b" "d" "e" "f" }
140         [
141             "vocabs.loader.test." prepend forget-vocab
142         ] each
143     ] with-compilation-unit ;
145 forget-junk
147 [ { } ] [
148     "IN: xabbabbja" eval "xabbabbja" vocab-files
149 ] unit-test
151 [ "xabbabbja" forget-vocab ] with-compilation-unit
153 forget-junk
155 [ ] [ [ "vocabs.loader.test.e" forget-vocab ] with-compilation-unit ] unit-test
157 0 "vocabs.loader.test.g" set-global
160     "vocabs.loader.test.f" forget-vocab
161     "vocabs.loader.test.g" forget-vocab
162 ] with-compilation-unit
164 [ ] [ "vocabs.loader.test.g" require ] unit-test
166 [ 1 ] [ "vocabs.loader.test.g" get-global ] unit-test
169     "vocabs.loader.test.h" forget-vocab
170     "vocabs.loader.test.i" forget-vocab
171 ] with-compilation-unit
173 [ ] [ "vocabs.loader.test.h" require ] unit-test
177     "vocabs.loader.test.j" forget-vocab
178     "vocabs.loader.test.k" forget-vocab
179 ] with-compilation-unit
181 [ ] [ [ "vocabs.loader.test.j" require ] [ drop :1 ] recover ] unit-test