summaryrefslogtreecommitdiffstats
path: root/tcllib/modules/doctools2toc/import.test
blob: e8bf0e47eff9a4daf64cb898a3da302e56e51c51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
# -*- tcl -*-
# -- toc_import.test:
# -- Tests for package "doctools::toc::import": Management of import plugins.
#
# Copyright (c) 2009 by Andreas Kupries <andreas_kupries@users.sourceforge.net>
# All rights reserved.
#
# RCS: @(#) $Id: import.test,v 1.1 2009/04/18 21:14:18 andreas_kupries Exp $

# -------------------------------------------------------------------------

source [file join \
	[file dirname [file dirname [file join [pwd] [info script]]]] \
	devtools testutilities.tcl]

testsNeedTcl     8.4
testsNeedTcltest 2

support {
    use struct/list.tcl         struct::list
    use snit/snit.tcl           snit
    use fileutil/fileutil.tcl   fileutil
    use log/logger.tcl          logger
    use pluginmgr/pluginmgr.tcl pluginmgr

    use      doctools2base/config.tcl    doctools::config
    use      doctools2base/paths.tcl     doctools::paths

    source [tcllibPath doctools2base/tests/common]
}
testing {
    useLocalKeep import.tcl doctools::toc::import
}

# -------------------------------------------------------------------------

setup_plugins

# -------------------------------------------------------------------------

test doctools-toc-import-1.0 {import text, wrong#args} -setup {
    doctools::toc::import I
} -body {
    I import text
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::toc::import::Snit_hmethodimport_text type selfns win self text ?format?"}

test doctools-toc-import-1.1 {import text, wrong#args} -setup {
    doctools::toc::import I
} -body {
    I import text T F XX
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::toc::import::Snit_hmethodimport_text type selfns win self text ?format?"}

test doctools-toc-import-2.0 {import file, wrong#args} -setup {
    doctools::toc::import I
} -body {
    I import file
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::toc::import::Snit_hmethodimport_file type selfns win self path ?format?"}

test doctools-toc-import-2.1 {import file, wrong#args} -setup {
    doctools::toc::import I
} -body {
    I import file P F XXX
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::toc::import::Snit_hmethodimport_file type selfns win self path ?format?"}

test doctools-toc-import-3.0 {import object text, wrong#args} -setup {
    doctools::toc::import I
} -body {
    I import object text
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::toc::import::Snit_hmethodimport_object_text type selfns win self obj text ?format?"}

test doctools-toc-import-3.1 {import object text, wrong#args} -setup {
    doctools::toc::import I
} -body {
    I import object text O
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::toc::import::Snit_hmethodimport_object_text type selfns win self obj text ?format?"}

test doctools-toc-import-3.2 {import object text, wrong#args} -setup {
    doctools::toc::import I
} -body {
    I import object text O T F XXX
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::toc::import::Snit_hmethodimport_object_text type selfns win self obj text ?format?"}

test doctools-toc-import-4.0 {import object file, wrong#args} -setup {
    doctools::toc::import I
} -body {
    I import object file
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::toc::import::Snit_hmethodimport_object_file type selfns win self obj path ?format?"}

test doctools-toc-import-4.1 {import object file, wrong#args} -setup {
    doctools::toc::import I
} -body {
    I import object file O
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::toc::import::Snit_hmethodimport_object_file type selfns win self obj path ?format?"}

test doctools-toc-import-4.2 {import object file, wrong#args} -setup {
    doctools::toc::import I
} -body {
    I import object file O P F XXX
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::toc::import::Snit_hmethodimport_object_file type selfns win self obj path ?format?"}

test doctools-toc-import-5.0 {config names, wrong#args} -setup {
    doctools::toc::import I
} -body {
    I config names X
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::config::Snit_methodnames type selfns win self"}

test doctools-toc-import-6.0 {config get, wrong#args} -setup {
    doctools::toc::import I
} -body {
    I config get X
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::config::Snit_methodget type selfns win self"}

test doctools-toc-import-7.0 {config set, wrong#args} -setup {
    doctools::toc::import I
} -body {
    I config set
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::config::Snit_methodset type selfns win self name ?value?"}

test doctools-toc-import-7.1 {config set, wrong#args} -setup {
    doctools::toc::import I
} -body {
    I config set N V X
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::config::Snit_methodset type selfns win self name ?value?"}

# config unset - accepts any number of arguments.

test doctools-toc-import-8.0 {include paths, wrong#args} -setup {
    doctools::toc::import I
} -body {
    I include paths X
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::paths::Snit_methodpaths type selfns win self"}

test doctools-toc-import-9.0 {include clear, wrong#args} -setup {
    doctools::toc::import I
} -body {
    I include clear X
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::paths::Snit_methodclear type selfns win self"}

test doctools-toc-import-10.0 {include add, wrong#args} -setup {
    doctools::toc::import I
} -body {
    I include add
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::paths::Snit_methodadd type selfns win self path"}

test doctools-toc-import-10.1 {include add, wrong#args} -setup {
    doctools::toc::import I
} -body {
    I include add P X
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::paths::Snit_methodadd type selfns win self path"}

test doctools-toc-import-11.0 {include remove, wrong#args} -setup {
    doctools::toc::import I
} -body {
    I include remove
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::paths::Snit_methodremove type selfns win self path"}

test doctools-toc-import-11.1 {include remove, wrong#args} -setup {
    doctools::toc::import I
} -body {
    I include remove P X
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::doctools::paths::Snit_methodremove type selfns win self path"}

# -------------------------------------------------------------------------

test doctools-toc-import-12.0 {config set, define single var} -setup {
    doctools::toc::import I
} -body {
    I config set N V
    I config get
} -cleanup {
    I destroy
} -result {N V}

test doctools-toc-import-12.1 {config set, define multiple vars} -setup {
    doctools::toc::import I
} -body {
    I config set N V
    I config set A B
    dictsort [I config get]
} -cleanup {
    I destroy
} -result {A B N V}

test doctools-toc-import-12.2 {config set, as query} -setup {
    doctools::toc::import I
    I config set N V
} -body {
    I config set N
} -cleanup {
    I destroy
} -result V

test doctools-toc-import-13.0 {config unset, all} -setup {
    doctools::toc::import I
    I config set N V
} -body {
    I config unset
    I config get
} -cleanup {
    I destroy
} -result {}

test doctools-toc-import-13.1 {config unset, by exact name} -setup {
    doctools::toc::import I
    I config set N V
    I config set A B
} -body {
    I config unset N
    I config get
} -cleanup {
    I destroy
} -result {A B}

test doctools-toc-import-13.2 {config unset, by glob pattern} -setup {
    doctools::toc::import I
    I config set N V
    I config set N' V'
    I config set A B
} -body {
    I config unset N*
    I config get
} -cleanup {
    I destroy
} -result {A B}

test doctools-toc-import-14.0 {config names, empty} -setup {
    doctools::toc::import I
} -body {
    I config names
} -cleanup {
    I destroy
} -result {}

test doctools-toc-import-14.1 {config names, with variables} -setup {
    doctools::toc::import I
    I config set N V
    I config set A B
} -body {
    lsort -dict [I config names]
} -cleanup {
    I destroy
} -result {A N}

test doctools-toc-import-15.0 {config get, empty} -setup {
    doctools::toc::import I
} -body {
    I config get
} -cleanup {
    I destroy
} -result {}

test doctools-toc-import-15.1 {config get, with variables} -setup {
    doctools::toc::import I
    I config set N V
    I config set A B
} -body {
    dictsort [I config get]
} -cleanup {
    I destroy
} -result {A B N V}

test doctools-toc-import-16.0 {include paths, empty} -setup {
    doctools::toc::import I
} -body {
    I include paths
} -cleanup {
    I destroy
} -result {}

test doctools-toc-import-16.1 {include paths, several paths, order} -setup {
    doctools::toc::import I
    I include add first
    I include add second
} -body {
    I include paths
} -cleanup {
    I destroy
} -result {first second}

test doctools-toc-import-17.0 {include add, unknown} -setup {
    doctools::toc::import I
} -body {
    I include add A
    I include paths
} -cleanup {
    I destroy
} -result A

test doctools-toc-import-17.1 {include add, already known} -setup {
    doctools::toc::import I
} -body {
    I include add A
    I include add A
    I include paths
} -cleanup {
    I destroy
} -result A

test doctools-toc-import-18.0 {include remove, unknown} -setup {
    doctools::toc::import I
} -body {
    I include add A
    I include remove B
    I include paths
} -cleanup {
    I destroy
} -result A

test doctools-toc-import-18.1 {include remove, known} -setup {
    doctools::toc::import I
} -body {
    I include add A
    I include remove A
    I include paths
} -cleanup {
    I destroy
} -result {}

test doctools-toc-import-19.0 {include clear} -setup {
    doctools::toc::import I
} -body {
    I include add A
    I include add B
    I include clear
    I include paths
} -cleanup {
    I destroy
} -result {}

# toc_import tests, numbering starts at 20
# -------------------------------------------------------------------------

source [localPath tests/import]

#----------------------------------------------------------------------
testsuiteCleanup
return