File: document.test

package info (click to toggle)
tclxml 3.3~svn11-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 4,392 kB
  • ctags: 1,362
  • sloc: ansic: 13,292; tcl: 11,656; xml: 3,269; sh: 559; makefile: 17
file content (573 lines) | stat: -rw-r--r-- 24,510 bytes parent folder | download | duplicates (3)
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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
# Commands covered:  ::dom::document
#
# This file contains a collection of tests for one or more of the 
# TclDOM commands.  Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 2008 Explain
# Copyright (c) 1998-2004 Zveno Pty Ltd.
#
# $Id: document.test,v 1.11 2004/02/25 20:10:30 balls Exp $

package require tcltest
source [file join [tcltest::workingDirectory] tcldomutils.tcl]

testPackage dom

namespace eval ::dom::documentTest {
    namespace import -force ::tcltest::*

    variable SETUP {
	set doc [::dom::create]
	set top [$doc createElement Test]
	::dom::node appendChild $doc $top
    }

    variable CLEANUP {
	dom::destroy $doc
    }

    test document-1.1 {cget -doctype} -setup $SETUP -constraints {dom_c} -body {
	::dom::document cget $doc -doctype
    } -cleanup $CLEANUP -result {}
    test document-1.1 {cget -doctype} -setup $SETUP -constraints {dom_tcl} -body {
	string equal [::dom::document cget $doc -doctype] {}
    } -cleanup $CLEANUP -result 0
    test document-1.1.1 {cget -doctype} -setup $SETUP -constraints {dom_c} -body {
	$doc cget -doctype
    } -cleanup $CLEANUP -result {}
    test document-1.1.1 {cget -doctype} -setup $SETUP -constraints {dom_tcl} -body {
	string equal [$doc cget -doctype] {}
    } -cleanup $CLEANUP -result 0
    test document-1.2 {cget -implementation} -setup $SETUP -constraints {dom_c} -body {
	::dom::document cget $doc -implementation
    } -cleanup $CLEANUP -result {::dom::DOMImplementation}
    test document-1.2 {cget -implementation} -setup $SETUP -constraints {dom_tcl} -body {
	::dom::document cget $doc -implementation
    } -cleanup $CLEANUP -result {::dom::tcl::DOMImplementation}
    test document-1.2.1 {cget -implementation} -setup $SETUP -constraints {dom_tcl} -body {
	$doc cget -implementation
    } -cleanup $CLEANUP -result {::dom::tcl::DOMImplementation}
    test document-1.2 {cget -implementation} -setup $SETUP -constraints {dom_libxml2} -body {
	::dom::document cget $doc -implementation
    } -cleanup $CLEANUP -result {::dom::libxml2::DOMImplementation}
    test document-1.2.1 {cget -implementation} -setup $SETUP -constraints {dom_libxml2} -body {
	$doc cget -implementation
    } -cleanup $CLEANUP -result {::dom::libxml2::DOMImplementation}
    test document-1.3 {cget -documentElement} -body {
	set doc [dom::create]
	::dom::document cget $doc -documentElement
    } -cleanup $CLEANUP -result {}
    test document-1.3.1 {cget -documentElement} -body {
	set doc [dom::create]
	$doc cget -documentElement
    } -cleanup $CLEANUP -result {}
    test document-1.4 {error: cget too few arguments} -setup $SETUP -match glob -body {
	expectError {
	    ::dom::document cget $doc
	}
    } -cleanup $CLEANUP -result {wrong # args*}
    test document-1.4.1 {error: cget too few arguments} -setup $SETUP -match glob -body {
	expectError {
	    $doc cget
	}
    } -cleanup $CLEANUP -result {wrong # args*}
    test document-1.5 {error: cget too many arguments} -setup $SETUP -match glob -body {
	expectError {
	    ::dom::document cget $doc -foo bar
	}
    } -cleanup $CLEANUP -result {wrong # args*}
    test document-1.5.1 {error: cget too many arguments} -setup $SETUP -match glob -body {
	expectError {
	    $doc cget -foo bar
	}
    } -cleanup $CLEANUP -result {wrong # args*}
    test document-1.6 {error: cget unknown option} -setup $SETUP -match glob -body {
	expectError {
	    ::dom::document cget $doc -foo
	}
    } -cleanup $CLEANUP -result {bad option*}
    test document-1.6.1 {error: cget unknown option} -setup $SETUP -match glob -body {
	expectError {
	    $doc cget -foo
	}
    } -cleanup $CLEANUP -result {bad option*}
    test document-1.7 {cget -version} -constraints {dom_tcl} -setup $SETUP -body {
	::dom::document cget $doc -version
    } -cleanup $CLEANUP -result 1.0
    test document-1.7.1 {cget -version} -constraints {dom_tcl} -setup $SETUP -body {
	$doc cget -version
    } -cleanup $CLEANUP -result 1.0

    test document-2.1 {configure} -body {
	set doc [dom::create]
	::dom::document configure $doc -documentElement
    } -cleanup $CLEANUP -result {}
    test document-2.1.1 {configure} -body {
	set doc [dom::create]
	$doc configure -documentElement
    } -cleanup $CLEANUP -result {}
    test document-2.2 {error: configure read-only option} -setup $SETUP -match glob -body {
	expectError {
	    ::dom::document configure $doc -documentElement $doc
	}
    } -cleanup $CLEANUP -result {attribute * read-only}
    test document-2.2.1 {error: configure read-only option} -setup $SETUP -match glob -body {
	expectError {
	    $doc configure -documentElement $doc
	}
    } -cleanup $CLEANUP -result {attribute * read-only}
    test document-2.3 {configure -version} -constraints {dom_tcl} -setup $SETUP -body {
	::dom::document configure $doc -version 1.0
    } -cleanup $CLEANUP -result {}
    test document-2.3.1 {configure -version} -constraints {dom_tcl} -setup $SETUP -body {
	$doc configure -version 1.0
    } -cleanup $CLEANUP -result {}
    test document-2.4 {error: configure -version} -constraints {dom_tcl} -setup $SETUP -match glob -body {
	expectError {
	    ::dom::document configure $doc -version 1.1
	}
    } -cleanup $CLEANUP -result *
    test document-2.4.1 {error: configure -version} -constraints {dom_tcl} -setup $SETUP -match glob -body {
	expectError {
	    $doc configure -version 1.1
	}
    } -cleanup $CLEANUP -result *
    test document-2.5 {configure -encoding} -constraints {dom_tcl} -setup $SETUP -body {
	::dom::document configure $doc -encoding ISO-8859-1
	::dom::document cget $doc -encoding
    } -cleanup $CLEANUP -result ISO-8859-1
    test document-2.5.1 {configure -encoding} -constraints {dom_tcl} -setup $SETUP -body {
	$doc configure -encoding ISO-8859-1
	$doc cget -encoding
    } -cleanup $CLEANUP -result ISO-8859-1
    test document-2.6 {configure -standalone} -constraints {dom_tcl} -setup $SETUP -body {
	::dom::document configure $doc -standalone 1
	::dom::document cget $doc -standalone
    } -cleanup $CLEANUP -result yes
    test document-2.6.1 {configure -standalone} -constraints {dom_tcl} -setup $SETUP -body {
	$doc configure -standalone 1
	$doc cget -standalone
    } -cleanup $CLEANUP -result yes

    test document-3.1 {create document element} -body {
	set doc [dom::create]
	set top [::dom::document createElement $doc Test]
	::dom::node appendChild $doc $top
	ok
    } -cleanup $CLEANUP -result {}
    test document-3.1.1 {create document element} -body {
	set doc [dom::create]
	set top [$doc createElement Test]
	::dom::node appendChild $doc $top
	ok
    } -cleanup $CLEANUP -result {}
    test document-3.2 {element node type} -setup $SETUP -body {
	::dom::node cget $top -nodeType
    } -cleanup $CLEANUP -result element
    test document-3.2.1 {element node type} -setup $SETUP -body {
	$top cget -nodeType
    } -cleanup $CLEANUP -result element
    test document-3.3 {element name} -setup $SETUP -body {
	::dom::node cget $top -nodeName
    } -cleanup $CLEANUP -result Test
    test document-3.3.1 {element name} -setup $SETUP -body {
	$top cget -nodeName
    } -cleanup $CLEANUP -result Test
    test document-3.4 {document element set} -setup $SETUP -body {
	$top isSameNode [::dom::document cget $doc -documentElement]
    } -cleanup $CLEANUP -result 1
    test document-3.4.1 {document element set} -setup $SETUP -body {
	$top isSameNode [$doc cget -documentElement]
    } -cleanup $CLEANUP -result 1
    test document-3.5 {error: no element name} -setup $SETUP -match glob -body {
	expectError {
	    ::dom::document createElement $doc
	}
    } -cleanup $CLEANUP -result {wrong # args*}
    test document-3.5.1 {error: no element name} -setup $SETUP -match glob -body {
	expectError {
	    $doc createElement
	}
    } -cleanup $CLEANUP -result {wrong # args*}
    test document-3.6 {error: invalid element name} -setup $SETUP -match glob -body {
	expectError {
    	    ::dom::document createElement $top {Has Space}
	}
    } -cleanup $CLEANUP -result {invalid * name *}
    test document-3.6.1 {error: invalid element name} -constraints {not_implemented} -setup $SETUP -match glob -body {
	expectError {
    	    $top createElement {Has Space}
	}
    } -cleanup $CLEANUP -result {invalid * name *}
    test document-3.7 {error: too many arguments} -setup $SETUP -match glob -body {
	expectError {
	    ::dom::document createElement $doc Foo Bar
	}
    } -cleanup $CLEANUP -result {wrong # args*}
    test document-3.7.1 {error: too many arguments} -constraints {not_implemented} -setup $SETUP -match glob -body {
	expectError {
	    $doc createElement Foo Bar
	}
    } -cleanup $CLEANUP -result {wrong # args*}
    test document-3.8 {create node command} -setup {
	set doc [dom::create]
	set node [dom::document createElement $doc Test]
    } -body {
	string equal [info commands $node] {}
    } -result 0 -cleanup $CLEANUP
    test document-3.9 {create unconnected element} -setup {
	set doc [dom::create]
	set docel [dom::document createElement $doc Test]
    } -body {
	set new [$doc createElement New]
	ok
    } -result {} -cleanup $CLEANUP

    test document-4.1 {create documentFragment} -setup $SETUP -body {
	set frag [::dom::document createDocumentFragment $top]
	ok
    } -cleanup $CLEANUP -result {}
    test document-4.1.1 {create documentFragment} -setup $SETUP -body {
	set frag [$doc createDocumentFragment]
	ok
    } -cleanup $CLEANUP -result {}
    test document-4.2 {documentFragment node type} -setup $SETUP -body {
	set frag [::dom::document createDocumentFragment $top]
	::dom::node cget $frag -nodeType
    } -cleanup $CLEANUP -result documentFragment
    test document-4.2.1 {documentFragment node type} -setup $SETUP -body {
	set frag [::dom::document createDocumentFragment $top]
	$frag cget -nodeType
    } -cleanup $CLEANUP -result documentFragment
    test document-4.3 {error: documentFragment too many arguments} -setup $SETUP -match glob -body {
	expectError {
	    ::dom::document createDocumentFragment $top Foo
	}
    } -cleanup $CLEANUP -result {wrong # args*}
    test document-4.3.1 {error: documentFragment too many arguments} -constraints {not_implemented} -setup $SETUP -match glob -body {
	expectError {
	    $doc createDocumentFragment Foo
	}
    } -cleanup $CLEANUP -result {wrong # args*}

    test document-5.1 {create textNode} -setup $SETUP -body {
	set text [::dom::document createTextNode $top {Sample Data}]
	ok;
    } -cleanup $CLEANUP -result {}
    test document-5.1.1 {create textNode} -setup $SETUP -body {
	set text [$doc createTextNode {Sample Data}]
	ok;
    } -cleanup $CLEANUP -result {}
    test document-5.2 {textNode node type} -setup $SETUP -body {
	set text [$doc createTextNode {Sample Data}]
	::dom::node cget $text -nodeType
    } -cleanup $CLEANUP -result textNode
    test document-5.2.1 {textNode node type} -setup $SETUP -body {
	set text [$doc createTextNode {Sample Data}]
	$text cget -nodeType
    } -cleanup $CLEANUP -result textNode
    test document-5.3 {textNode node name} -setup $SETUP -body {
	set text [$doc createTextNode {Sample Data}]
	::dom::node cget $text -nodeName
    } -cleanup $CLEANUP -result {#text}
    test document-5.3.1 {textNode node name} -setup $SETUP -body {
	set text [$doc createTextNode {Sample Data}]
	$text cget -nodeName
    } -cleanup $CLEANUP -result {#text}
    test document-5.4 {textNode node value} -setup $SETUP -body {
	set text [$doc createTextNode {Sample Data}]
	::dom::node cget $text -nodeValue
    } -cleanup $CLEANUP -result {Sample Data}
    test document-5.4.1 {textNode node value} -setup $SETUP -body {
	set text [$doc createTextNode {Sample Data}]
	$text cget -nodeValue
    } -cleanup $CLEANUP -result {Sample Data}
    test document-5.5 {error: textNode too few arguments} -setup $SETUP -match glob -body {
	expectError {
	    ::dom::document createTextNode $top
	}
    } -cleanup $CLEANUP -result {wrong # args*}
    test document-5.5.1 {error: textNode too few arguments} -setup $SETUP -match glob -body {
	expectError {
	    $doc createTextNode
	}
    } -cleanup $CLEANUP -result {wrong # args*}
    test document-5.6 {error: textNode too many arguments} -setup $SETUP -match glob -body {
	expectError {
	    ::dom::document createTextNode $top {More Sample Data} Foo
	}
    } -cleanup $CLEANUP -result {wrong # args*}
    test document-5.6.1 {error: textNode too many arguments} -setup $SETUP -match glob -body {
	expectError {
	    $doc createTextNode {More Sample Data} Foo
	}
    } -cleanup $CLEANUP -result {wrong # args*}

    test document-6.1 {create comment} -setup $SETUP -body {
	set comm [::dom::document createComment $top {Comment Data}]
	ok;
    } -cleanup $CLEANUP -result {}
    test document-6.1.1 {create comment} -setup $SETUP -body {
	set comm [$doc createComment {Comment Data}]
	ok;
    } -cleanup $CLEANUP -result {}
    test document-6.2 {comment node type} -setup $SETUP -body {
	set comm [::dom::document createComment $top {Comment Data}]
	::dom::node cget $comm -nodeType
    } -cleanup $CLEANUP -result comment
    test document-6.2.1 {comment node type} -setup $SETUP -body {
	set comm [::dom::document createComment $top {Comment Data}]
	$comm cget -nodeType
    } -cleanup $CLEANUP -result comment
    test document-6.3 {comment node name} -setup $SETUP -body {
	set comm [::dom::document createComment $top {Comment Data}]
	::dom::node cget $comm -nodeName
    } -cleanup $CLEANUP -result {#comment}
    test document-6.3.1 {comment node name} -setup $SETUP -body {
	set comm [::dom::document createComment $top {Comment Data}]
	$comm cget -nodeName
    } -cleanup $CLEANUP -result {#comment}
    test document-6.4 {comment node value} -setup $SETUP -body {
	set comm [::dom::document createComment $top {Comment Data}]
	::dom::node cget $comm -nodeValue
    } -cleanup $CLEANUP -result {Comment Data}
    test document-6.4.1 {comment node value} -setup $SETUP -body {
	set comm [::dom::document createComment $top {Comment Data}]
	$comm cget -nodeValue
    } -cleanup $CLEANUP -result {Comment Data}
    test document-6.5 {error: comment too few arguments} -setup $SETUP -match glob -body {
	expectError {
	    ::dom::document createComment $top
	}
    } -cleanup $CLEANUP -result {wrong # args*}
    test document-6.5.1 {error: comment too few arguments} -setup $SETUP -match glob -body {
	expectError {
	    $doc createComment
	}
    } -cleanup $CLEANUP -result {wrong # args*}
    test document-6.6 {error: comment too many arguments} -setup $SETUP -match glob -body {
	expectError {
	    ::dom::document createComment $top {More Comment Data} Foo
	}
    } -cleanup $CLEANUP -result {wrong # args*}
    test document-6.6.1 {error: comment too many arguments} -setup $SETUP -match glob -body {
	expectError {
	    $doc createComment {More Comment Data} Foo
	}
    } -cleanup $CLEANUP -result {wrong # args*}

    # dom::tcl and dom::libxml2 treat CDATA Sections as plain text

    test document-7.1 {create CDATASection} -setup $SETUP -body {
	set cdata [::dom::document createCDATASection $top {CDATASection <Data>}]
	ok
    } -cleanup $CLEANUP -result {}
    test document-7.1.1 {create CDATASection} -setup $SETUP -body {
	set cdata [$doc createCDATASection {CDATASection <Data>}]
	ok
    } -cleanup $CLEANUP -result {}
    test document-7.2 {CDATASection node type} -constraints {dom_c} -setup $SETUP -body {
	set cdata [::dom::document createCDATASection $top {CDATASection <Data>}]
	::dom::node cget $cdata -nodeType
    } -cleanup $CLEANUP -result CDATASection
    test document-7.2 {CDATASection node type} -constraints {dom_tcl || dom_libxml2} -setup $SETUP -body {
	set cdata [::dom::document createCDATASection $top {CDATASection <Data>}]
	::dom::node cget $cdata -nodeType
    } -cleanup $CLEANUP -result textNode
    test document-7.2.1 {CDATASection node type} -constraints {dom_tcl || dom_libxml2} -setup $SETUP -body {
	set cdata [::dom::document createCDATASection $top {CDATASection <Data>}]
	$cdata cget -nodeType
    } -cleanup $CLEANUP -result textNode
    test document-7.3 {CDATASection node name} -constraints {dom_c} -setup $SETUP -body {
	set cdata [::dom::document createCDATASection $top {CDATASection <Data>}]
	::dom::node cget $cdata -nodeName
    } -cleanup $CLEANUP -result {#cdata-section}
    test document-7.3 {CDATASection node name} -constraints {dom_tcl || dom_libxml2} -setup $SETUP -body {
	set cdata [::dom::document createCDATASection $top {CDATASection <Data>}]
	::dom::node cget $cdata -nodeName
    } -cleanup $CLEANUP -result {#text}
    test document-7.3.1 {CDATASection node name} -constraints {dom_tcl || dom_libxml2} -setup $SETUP -body {
	set cdata [::dom::document createCDATASection $top {CDATASection <Data>}]
	$cdata cget -nodeName
    } -cleanup $CLEANUP -result {#text}
    test document-7.4 {CDATASection node value} -setup $SETUP -body {
	set cdata [::dom::document createCDATASection $top {CDATASection <Data>}]
	::dom::node cget $cdata -nodeValue
    } -cleanup $CLEANUP -result {CDATASection <Data>}
    test document-7.4.1 {CDATASection node value} -setup $SETUP -body {
	set cdata [::dom::document createCDATASection $top {CDATASection <Data>}]
	$cdata cget -nodeValue
    } -cleanup $CLEANUP -result {CDATASection <Data>}
    test document-7.5 {error: CDATASection too few arguments} -setup $SETUP -match glob -body {
	expectError {
	    ::dom::document createCDATASection $top
	}
    } -cleanup $CLEANUP -result {wrong # args*}
    test document-7.5.1 {error: CDATASection too few arguments} -setup $SETUP -match glob -body {
	expectError {
	    $doc createCDATASection
	}
    } -cleanup $CLEANUP -result {wrong # args*}
    test document-7.6 {error: CDATASection too many arguments} -setup $SETUP -match glob -body {
	expectError {
	    ::dom::document createCDATASection $top {More CDATA} Foo
	}
    } -cleanup $CLEANUP -result {wrong # args*}
    test document-7.6.1 {error: CDATASection too many arguments} -setup $SETUP -match glob -body {
	expectError {
	    $doc createCDATASection {More CDATA} Foo
	}
    } -cleanup $CLEANUP -result {wrong # args*}

    test document-8.1 {create processingInstruction} -setup $SETUP -body {
	set pi [::dom::document createProcessingInstruction $top target {PI Data}]
	ok;
    } -cleanup $CLEANUP -result {}
    test document-8.1.1 {create processingInstruction} -setup $SETUP -body {
	set pi [$doc createProcessingInstruction target {PI Data}]
	ok;
    } -cleanup $CLEANUP -result {}
    test document-8.2 {processingInstruction node type} -setup $SETUP -body {
	set pi [::dom::document createProcessingInstruction $top target {PI Data}]
	::dom::node cget $pi -nodeType
    } -cleanup $CLEANUP -result processingInstruction
    test document-8.2.1 {processingInstruction node type} -setup $SETUP -body {
	set pi [::dom::document createProcessingInstruction $top target {PI Data}]
	$pi cget -nodeType
    } -cleanup $CLEANUP -result processingInstruction
    test document-8.3 {processingInstruction node name} -setup $SETUP -body {
	set pi [::dom::document createProcessingInstruction $top target {PI Data}]
	::dom::node cget $pi -nodeName
    } -cleanup $CLEANUP -result target
    test document-8.3.1 {processingInstruction node name} -setup $SETUP -body {
	set pi [::dom::document createProcessingInstruction $top target {PI Data}]
	$pi cget -nodeName
    } -cleanup $CLEANUP -result target
    test document-8.4 {processingInstruction node value} -setup $SETUP -body {
	set pi [::dom::document createProcessingInstruction $top target {PI Data}]
	::dom::node cget $pi -nodeValue
    } -cleanup $CLEANUP -result {PI Data}
    test document-8.4.1 {processingInstruction node value} -setup $SETUP -body {
	set pi [::dom::document createProcessingInstruction $top target {PI Data}]
	$pi cget -nodeValue
    } -cleanup $CLEANUP -result {PI Data}
    test document-8.5 {error: processingInstruction too few arguments} -setup $SETUP -match glob -body {
	expectError {
	    ::dom::document createProcessingInstruction $top
	}
    } -cleanup $CLEANUP -result {wrong # args*}
    test document-8.5.1 {error: processingInstruction too few arguments} -setup $SETUP -match glob -body {
	expectError {
	    $doc createProcessingInstruction
	}
    } -cleanup $CLEANUP -result {wrong # args*}
    test document-8.6 {error: processingInstruction too many arguments} -setup $SETUP -match glob -body {
	expectError {
	    ::dom::document createProcessingInstruction $top target data Extra
	}
    } -cleanup $CLEANUP -result {wrong # args*}
    test document-8.6.1 {error: processingInstruction too many arguments} -setup $SETUP -match glob -body {
	expectError {
	    $doc createProcessingInstruction target data Extra
	}
    } -cleanup $CLEANUP -result {wrong # args*}

# TBD: Attribute
# TBD: EntityReference

    variable SETUP10 {
	set doc [dom::create]
	set top [$doc createElement Test]
	set child1 [$doc createElement Child1]
	$top appendChild $child1
	set child2 [$doc createElement Child2]
	$top appendChild $child2
	set child3 [$doc createElement Test]
	$top appendChild $child3
    }

    test document-10.1 {getElementsByTagName - document element} \
    -constraints {!dom_libxml2} -setup $SETUP -body {
	set docTestElements [::dom::document getElementsByTagName $doc Test]
	list [llength [set $docTestElements]] [$top isSameNode [lindex [set $docTestElements] 0]]
    } -cleanup $CLEANUP -result [list 1 1]
    test document-10.1.1 {getElementsByTagName - document element} \
    -constraints {!dom_libxml2} -setup $SETUP -body {
	set docTestElements [$doc getElementsByTagName Test]
	list [llength [set $docTestElements]] [$top isSameNode [lindex [set $docTestElements] 0]]
    } -cleanup $CLEANUP -result [list 1 1]

    test document-10.3 {getElementsByTagName - continued} \
    -constraints {!dom_libxml2} -setup $SETUP10 -body {
	set docTestElements [$doc getElementsByTagName Test]
	set result [set $docTestElements]
	list [llength $result] [compareNodeList $result [list $top $child3]]
    } -cleanup $CLEANUP -result [list 2 1]

    test document-10.4 {getElementsByTagName - element} \
    -constraints {!dom_libxml2} -setup $SETUP10 -body {
	set result [::dom::document getElementsByTagName $top Child2]
	list [llength [set $result]] [compareNodeList [set $result] [list $child2]]
    } -cleanup $CLEANUP -result [list 1 1]

    test document-10.5 {getElementsByTagName - remove node} \
    -constraints {!dom_libxml2} -setup $SETUP10 -body {
	set docTestElements [$doc getElementsByTagName Test]
	dom::node removeChild $top $child3
	list [llength [set $docTestElements]] [compareNodeList [set $docTestElements] [list $top]]
    } -cleanup $CLEANUP -result [list 1 1]

    test document-10.6 {getElementsByTagName - read-only variable} \
    -constraints {!dom_libxml2} -match glob -setup $SETUP10 -body {
	set docTestElements [$doc getElementsByTagName Test]
	expectError {
	    lappend $docTestElements -foo-
	}
    } -cleanup $CLEANUP -result {*: Read-only variable}

    test document-10.7 {getElementsByTagName - unset variable} -constraints {!dom_libxml2 && knownBug} -setup $SETUP10 -body {
	set docTestElements [$doc getElementsByTagName Test]
	unset $docTestElements
	ok
    } -cleanup $CLEANUP -result {}

    test document-11.1 {importNode} -constraints {dom_c} -body {
	set testXML "<?xml version=\"1.0\"?><Test><a>aaa<b>bbb</b>aaa</a></Test>"
	# bug 3620
	global testXML
	set doc [::dom::DOMImplementation parse $testXML]
	set copy [::dom::DOMImplementation create]
	set root [::dom::document cget $doc -documentElement]
	set result [catch {::dom::document importNode $copy $root -deep 1} node]
	::dom::node insert $copy $node
	set xml [::dom::DOMImplementation serialize $copy]
	list $result $xml
    } -result {0 {<?xml version='1.0'?>
<!DOCTYPE Test>
<Test><a>aaa<b>bbb</b>aaa</a></Test>}}

    variable IMPORTSETUP {
	set doc [dom::parse {<test><element>text</element></test>}]
	set other [dom::parse {<other><element>import me!</element></other>}]
	set replace [dom::selectNode $doc /test/element/text()]
	set parent [$replace parent]
	set with [dom::selectNode $other /other/element/text()]
    }
    variable IMPORTCLEANUP {
	dom::destroy $doc
	dom::destroy $other
    }

    test document-11.2 {importNode} -constraints {dom_c} -setup $IMPORTSETUP -match regexp -body {
	$parent replaceChild [$doc importNode $with -deep 1] $replace
	dom::serialize $doc
    } -cleanup $IMPORTCLEANUP -result {.*<test><element>import me!</element></test>}

    # cleanup
    ::tcltest::cleanupTests
}

namespace delete ::dom::documentTest

return