]> gitweb.factorcode.org Git - factor.git/blob - core/vocabs/loader/loader-tests.factor
Fix permission bits
[factor.git] / core / vocabs / loader / loader-tests.factor
1 ! Unit tests for vocabs.loader vocabulary
2 IN: vocabs.loader.tests
3 USING: vocabs.loader tools.test continuations vocabs math
4 kernel arrays sequences namespaces io.streams.string
5 parser source-files words assocs classes.tuple definitions
6 debugger compiler.units tools.vocabs accessors eval ;
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" vocab = ] unit-test
20
21 [ t ] [
22     "kernel" vocab-files
23     "kernel" vocab vocab-files
24     "kernel" <vocab-link> vocab-files
25     3array all-equal?
26 ] unit-test
27
28 IN: vocabs.loader.test.2
29
30 : hello 3 ;
31
32 MAIN: hello
33
34 IN: vocabs.loader.tests
35
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
42
43
44 [
45     "resource:core/vocabs/loader/test/a/a.factor" forget-source
46     "vocabs.loader.test.a" forget-vocab
47 ] with-compilation-unit
48
49 0 "count-me" set-global
50
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
63
64 [ 2 ] [ "count-me" get-global ] unit-test
65
66 [
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
72
73 0 "count-me" set-global
74
75 [ ] [
76     [
77         "vocabs.loader.test.b" forget-vocab
78     ] with-compilation-unit
79 ] unit-test
80
81 [ f ] [ "vocabs.loader.test.b" vocab-files empty? ] unit-test
82
83 [ ] [
84     [
85         "vocabs.loader.test.b" vocab-files
86         [ forget-source ] each
87     ] with-compilation-unit
88 ] unit-test
89
90 [ "vocabs.loader.test.b" require ] must-fail
91
92 [ 1 ] [ "count-me" get-global ] unit-test
93
94 [ ] [
95     [
96         "bob" "vocabs.loader.test.b" create [ ] define
97     ] with-compilation-unit
98 ] unit-test
99
100 [ ] [ "vocabs.loader.test.b" refresh ] unit-test
101
102 [ 2 ] [ "count-me" get-global ] unit-test
103
104 [ f ] [ "fred" "vocabs.loader.test.b" lookup undefined? ] unit-test
105
106 [ ] [
107     [
108         "vocabs.loader.test.b" vocab-files
109         [ forget-source ] each
110     ] with-compilation-unit
111 ] unit-test
112
113 [ ] [ "vocabs.loader.test.b" changed-vocab ] unit-test
114
115 [ ] [ "vocabs.loader.test.b" refresh ] unit-test
116
117 [ 3 ] [ "count-me" get-global ] unit-test
118
119 [ { "resource:core/kernel/kernel.factor" 1 } ]
120 [ "kernel" <vocab-link> where ] unit-test
121
122 [ { "resource:core/kernel/kernel.factor" 1 } ]
123 [ "kernel" vocab where ] unit-test
124
125 [ ] [
126     [
127         "vocabs.loader.test.c" forget-vocab
128         "vocabs.loader.test.d" forget-vocab
129     ] with-compilation-unit
130 ] unit-test
131
132 [ t ] [
133     [ "vocabs.loader.test.d" require ] [ :1 ] recover
134     "vocabs.loader.test.d" vocab-source-loaded?
135 ] unit-test
136
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 ;
144
145 forget-junk
146
147 [ { } ] [
148     "IN: xabbabbja" eval "xabbabbja" vocab-files
149 ] unit-test
150
151 [ "xabbabbja" forget-vocab ] with-compilation-unit
152
153 forget-junk