File: container

package info (click to toggle)
tcllib 1.20%2Bdfsg-1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 68,064 kB
  • sloc: tcl: 216,842; ansic: 14,250; sh: 2,846; xml: 1,766; yacc: 1,145; pascal: 881; makefile: 107; perl: 84; f90: 84; python: 33; ruby: 13; php: 11
file content (358 lines) | stat: -rw-r--r-- 11,670 bytes parent folder | download | duplicates (6)
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
# -*- tcl -*-
# docidx.testsuite:  tests for the docidx management.
#
# Copyright (c) 2009 Andreas Kupries <andreas_kupries@users.sourceforge.net>
# All rights reserved.
#
# RCS: @(#) $Id: container,v 1.2 2009/04/17 05:42:07 andreas_kupries Exp $

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

set mytestdir tests/data

# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# I. Handling regular serialization of indices, import and export.
#    Import serialization, then re-export.

TestFilesProcess $mytestdir ok serial serial-print -> n label input data expected {
    test doctools-idx-40.$n "doctools::idx deserialize serial, $label, ok" -setup {
	doctools::idx I
    } -body {
	I deserialize = $data
	I invalidate
	doctools::idx::structure print [I serialize]
    } -cleanup {
	I destroy
    } -result $expected
}

# Testing the errors thrown for invalid serializations, at the level
# of index objects. Underneath are the doctools::idx::structure
# commands, so we can and are re-using the test cases which were
# written for them.

foreach {n badserial expected} {
    0 {}
    {error in serialization: dictionary too short, expected exactly one key}
    1 {FOO {}}
    {error in serialization: bad type tag "FOO"}
    2 {doctools::idx {}}
    {error in serialization: dictionary too short, expected exactly four keys}
    3 {doctools::idx {a . b . c . d .}}
    {error in serialization: missing expected key "label"}
    4 {doctools::idx {label . b . c . d .}}
    {error in serialization: missing expected key "title"}
    5 {doctools::idx {label . title . c . d .}}
    {error in serialization: missing expected key "keywords"}
    6 {doctools::idx {label . title . keywords . d .}}
    {error in serialization: missing expected key "references"}
    8 {doctools::idx {label . keywords {k {} k {}} references {} title .}}
    {error in serialization: duplicate keywords}
    10 {doctools::idx {label . keywords {} references {a {url x}} title .}}
    {error in serialization: use and declaration of references not matching}
    11 {doctools::idx {label . keywords {a {b c}} references {} title .}}
    {error in serialization: use and declaration of references not matching}
    12 {doctools::idx {label . keywords {a {b}} references {b {url}} title .}}
    {error in serialization: reference list wrong, need exactly 2}
    13 {doctools::idx {label . keywords {a {b}} references {b {foo B}} title .}}
    {error in serialization: bad reference tag "foo"}
    14 {doctools::idx {label . keywords {a {b}} references {b {url B} b {url A}} title .}}
    {error in serialization: duplicate reference identifiers}
} {
    test doctools-idx-41.$n "doctools::idx deserialize, error" -setup {
	doctools::idx I
    } -body {
	I deserialize = $badserial
    } -cleanup {
	I destroy
    } -returnCodes error -result $expected
}

foreach {n noncanonserial expected} {
    7 {doctools::idx {label . title . keywords {} references {}}}
    {doctools::idx {label . keywords {} references {} title .}}
    9 {doctools::idx {label . keywords {b {} a {}} references {} title .}}
    {doctools::idx {label . keywords {a {} b {}} references {} title .}}
    15 {doctools::idx {label . keywords {a {b c}} references {c {url C} b {url B}} title .}}
    {doctools::idx {label . keywords {a {b c}} references {b {url B} c {url C}} title .}}
} {
    test doctools-idx-42.$n "doctools::idx deserialize, regular to canonical" -setup {
	doctools::idx I
	I deserialize = $noncanonserial
    } -body {
	I serialize
    } -cleanup {
	I destroy
    } -result $expected
}

# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# II. Handling docidx markup as serialization format, import and export.

# Checking that the various forms of docidx markup as generated by the
# export plugin doctools::idx(::export::docidx) are valid input for
# the docidx import plugin. Actually testing that using an import
# manager from the index is working.

foreach {k section} {
    0 {}
    1 -ultracompact
    2 -compact
    3 -indented
    4 -aligned
    5 -indalign
} {
    TestFilesProcess $mytestdir ok docidx$section serial-print -> n label input data expected {
	test doctools-idx-50.$k.$n "doctools::idx deserialize = docidx, $label$section, ok" -setup {
	    doctools::idx I
	    doctools::idx::import IN
	    I importer IN
	} -body {
	    I deserialize = $data docidx
	    doctools::idx::structure print [I serialize]
	} -cleanup {
	    I destroy
	    IN destroy
	} -result $expected
    }
}

# We test the error messages and codes thrown during import for a
# variety of failure possibilities

TestFilesProcess $mytestdir fail docidx emsg -> n label input data expected {
    test doctools-idx-51.$n "doctools::idx deserialize = docidx, $label, error message" -setup {
	# Basic variables and include search paths for use by the tests
	doctools::idx::import IN
	IN config set fox dog
	IN config set lazy jump
	IN include add [TestFilesGlob $mytestdir]
	doctools::idx I
	I importer IN
    } -body {
	I deserialize = $data docidx
    } -cleanup {
	I destroy
	IN destroy
    } -returnCodes error -result $expected
}

TestFilesProcess $mytestdir fail docidx ecode -> n label input data expected {
    test doctools-idx-52.$n "doctools::idx deserialize = docidx, $label, error code" -setup {
	# Basic variables and include search paths for use by the tests
	doctools::idx::import IN
	IN config set fox dog
	IN config set lazy jump
	IN include add [TestFilesGlob $mytestdir]
	doctools::idx I
	I importer IN
    } -body {
	catch { I deserialize = $data docidx }
	set ::errorCode
    } -cleanup {
	I destroy
	IN destroy
    } -result $expected
}

# Testing the export of docidx markup through attached exporter management, for all possible configurations.

foreach {k nl in al section} {
    0 0 0 0 -ultracompact
    1 1 0 0 -compact
    2 1 1 0 -indented
    3 1 0 1 -aligned
    4 1 1 1 -indalign
    5 0 1 0 -indented
    6 0 0 1 -aligned
    7 0 1 1 -indalign
} {
    TestFilesProcess $mytestdir ok serial docidx$section -> n label input data expected {
	test doctools-idx-53.$k.$n "doctools::idx serialize docidx, ${label}$section, ok" -setup {
	    doctools::idx::export OUT
	    OUT config set newlines $nl
	    OUT config set indented $in
	    OUT config set aligned  $al
	    doctools::idx I
	    I exporter OUT
	} -body {
	    I deserialize = $data
	    stripcomments [I serialize docidx]
	} -cleanup {
	    I destroy
	    OUT destroy
	} -result $expected
    }
}

# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# III. Handling text markup as serialization format, export only

TestFilesProcess $mytestdir ok serial text -> n label input data expected {
    test doctools-idx-54.$n "doctools::idx serialize text, $label, ok" -setup {
	doctools::idx::export OUT
	doctools::idx I
	I exporter OUT
    } -body {
	I deserialize = $data
	I serialize text
    } -cleanup {
	I destroy
	OUT destroy
    } -result $expected
}

# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# IV. Handling json markup as serialization format, import and export.

# We are checking that the various forms of json markup, as can be
# generated by doctools::idx(::export(::json)) are valid input to the
# json parser.
#
# section {} holds the non-canonical input we have to accept and make
# canonical to higher layers.

foreach {k section} {
    0 {}
    1 -ultracompact
    2 -indented
    3 -indalign
} {
    TestFilesProcess $mytestdir ok json$section serial-print -> n label input data expected {
	test doctools-idx-55.$k.$n "doctools::idx deserialize = json, $label$section, ok" -setup {
	    doctools::idx::import IN
	    doctools::idx I
	    I importer IN
	} -body {
	    I deserialize = $data json
	    doctools::idx::structure print [I serialize]
	} -cleanup {
	    I destroy
	    IN destroy
	} -result $expected
    }
}

TestFilesProcess $mytestdir fail json json-emsg -> n label input data expected {
    test doctools-idx-56.$n "doctools::idx deserialize = json, $label, error message" -setup {
	doctools::idx::import IN
	doctools::idx I
	I importer IN
    } -body {
	I deserialize = $data json
    } -cleanup {
	I destroy
	IN destroy
    } -returnCodes error -result $expected
}

foreach {k in al section} {
    0 0 0 -ultracompact
    1 1 0 -indented
    2 0 1 -indalign
    3 1 1 -indalign
} {
    TestFilesProcess $mytestdir ok serial json$section -> n label input data expected {
	test doctools-idx-57.$k.$n "doctools::idx serialize json, $label$section, ok" -setup {
	    doctools::idx::export OUT
	    OUT config set indented $in
	    OUT config set aligned  $al
	    doctools::idx I
	    I exporter OUT
	} -body {
	    I deserialize = $data
	    I serialize json
	} -cleanup {
	    I destroy
	    OUT destroy
	} -result $expected
    }
}

# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# V. Handling html markup as serialization format, export only

foreach {k nl in section} {
    0 0 0 -ultracompact
    1 0 1 -indented
    2 1 0 -compact
    3 1 1 -indented
} {
    TestFilesProcess $mytestdir ok serial html$section -> n label input data expected {
	test doctools-idx-58.$k.$n "doctools::idx serialize html, $label$section, ok" -setup {
	    doctools::idx::export OUT
	    OUT config set newlines $nl
	    OUT config set indented $in
	    OUT config set user _dummy_
	    doctools::idx I
	    I exporter OUT
	} -body {
	    I deserialize = $data
	    striphtmlcomments [I serialize html] 3
	} -cleanup {
	    I destroy
	    OUT destroy
	} -result $expected
    }
}

# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# VI. Handling wiki markup as serialization format, export only

foreach {k style section} {
    0 list  -list
    1 table -table
} {
    TestFilesProcess $mytestdir ok serial wiki$section -> n label input data expected {
	test doctools-idx-59.$k.$n "doctools::idx serialize wiki, $label$section, ok" -setup {
	    doctools::idx::export OUT
	    OUT config set style $style
	    doctools::idx I
	    I exporter OUT
	} -body {
	    I deserialize = $data
	    I serialize wiki
	} -cleanup {
	    I destroy
	    OUT destroy
	} -result $expected
    }
}

# -------------------------------------------------------------------------
# -------------------------------------------------------------------------
# VII. Handling nroff markup as serialization format, export only

foreach {k inline section} {
    0 0 -external
    1 1 -inlined
} {
    TestFilesProcess $mytestdir ok serial nroff$section -> n label input data expected {
	test doctools-idx-60.$k.$n "doctools::idx serialize nroff, $label$section, ok" -setup {
	    doctools::idx::export OUT
	    OUT config set inline $inline
	    doctools::idx I
	    I exporter OUT
	} -body {
	    I deserialize = $data
	    stripnroffcomments [stripmanmacros [I serialize nroff]]
	} -cleanup {
	    I destroy
	    OUT destroy
	} -result $expected
    }
}

# -------------------------------------------------------------------------
return

# TODO :: Test the merging of indices (copy from idx_structure.test)

# -------------------------------------------------------------------------
return