File: doctype.test

package info (click to toggle)
tclxml 3.3~svn11-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,392 kB
  • sloc: ansic: 13,292; tcl: 11,656; xml: 3,269; sh: 559; makefile: 15
file content (228 lines) | stat: -rw-r--r-- 9,319 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
# Commands covered:  ::dom::doctype
#
# This file contains a collection of tests for one or more of the Tcl
# built-in 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
# http://www.explain.com.au/
# Copyright (c) 2003 Zveno Pty Ltd.
# Copyright (c) 2000 Ajuba Solutions.
# All rights reserved.
#
# RCS: @(#) $Id: doctype.test,v 1.5 2004/02/24 20:16:10 balls Exp $

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

testPackage dom

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

    test doctype-1.1 {argument parsing errors} -constraints {dom_c} -body {
	list [catch {dom::doctype} msg] $msg
    } -result "1 {wrong \# args: should be \"dom::doctype method ?args...?\"}"
    test doctype-1.2 {argument parsing errors} -constraints {dom_c} -body {
	list [catch {dom::doctype foo} msg] $msg
    } -result {1 {bad method "foo": must be cget or configure}}
    test doctype-1.3 {argument parsing errors} -constraints {dom_c} -body {
	list [catch {dom::doctype cget foo} msg] $msg
    } -result {1 {token not found}}
    test doctype-1.4 {argument parsing errors} -constraints {dom_c} -setup {
	set root [dom::DOMImplementation parse {<?xml version="1.0"?><foo/>}]
    } -body {
	list [catch {dom::doctype cget $root} msg] $msg
    } -cleanup {
	dom::DOMImplementation destroy $root
    } -result {1 {not a doctype type node}}
    test doctype-1.5 {argument parsing errors} -constraints {dom_c} -setup {
	set root [dom::DOMImplementation parse {<?xml version="1.0"?><!DOCTYPE foo><foo/>}]
	set doctype [dom::document cget $root -doctype]
    } -body {
	list [catch {dom::doctype cget $doctype} msg] $msg
    } -cleanup {
	dom::DOMImplementation destroy $root
    } -result "1 {wrong \# args: should be \"dom::doctype cget token option\"}"
    test doctype-1.6 {argument parsing errors} -constraints {dom_c} -setup {
	set root [dom::DOMImplementation parse {<?xml version="1.0"?><!DOCTYPE foo><foo/>}]
	set doctype [dom::document cget $root -doctype]
    } -body {
	list [catch {dom::doctype cget $doctype -foo} msg] $msg
    } -cleanup {
	dom::DOMImplementation destroy $root
    } -result {1 {unknown option '-foo', should be -internalSubset, -nodeName, -publicId, or -systemId}}
    test doctype-1.7 {argument parsing errors} -constraints {dom_c} -setup {
	set root [dom::DOMImplementation parse {<?xml version="1.0"?><!DOCTYPE foo><foo/>}]
	set doctype [dom::document cget $root -doctype]
    } -body {
	list [catch {dom::doctype configure $doctype} msg] $msg
    } -cleanup {
	dom::DOMImplementation destroy $root
    } -result {1 {doctype configure method not implemented}}
    test doctype-1.8 {argument parsing errors} -constraints {dom_c} -setup {
	set root [dom::DOMImplementation parse {<?xml version="1.0"?><!DOCTYPE foo><foo/>}]
	set doctype [dom::document cget $root -doctype]
    } -body {
	list [catch {dom::doctype foo $doctype} msg] $msg
    } -cleanup {
	dom::DOMImplementation destroy $root
    } -result {1 {bad method "foo": must be cget or configure}}

    test doctype-2.1 {cget options, -systemId, empty} -constraints {dom_c} -setup {
	set root [dom::DOMImplementation parse {<?xml version="1.0"?><!DOCTYPE foo><foo/>}]
	set doctype [dom::document cget $root -doctype]
    } -body {
	dom::doctype cget $doctype -systemId
    } -cleanup {
	dom::DOMImplementation destroy $root
    } -result {}
    test doctype-2.2 {cget options, -systemId, non-empty SYSTEM} -constraints {dom_c} -setup {
	set root [dom::DOMImplementation parse {<?xml version="1.0"?>
	<!DOCTYPE foo SYSTEM "foo.dtd"><foo/>}]
	set doctype [dom::document cget $root -doctype]
    } -body {
	set result [dom::doctype cget $doctype -systemId]
    } -cleanup {
	dom::DOMImplementation destroy $root
    } -result foo.dtd
    test doctype-2.3 {cget options, -systemId, non-empty PUBLIC} -constraints {dom_c} -setup {
	set root [dom::DOMImplementation parse {<?xml version="1.0"?>
	<!DOCTYPE foo PUBLIC "--Foo--" "foo.dtd"><foo/>}]
	set doctype [dom::document cget $root -doctype]
    } -body {
	dom::doctype cget $doctype -systemId
    } -cleanup {
	dom::DOMImplementation destroy $root
    } -result foo.dtd
    test doctype-2.4 {cget options, -systemId, non-empty internal subset} -constraints {dom_c} -setup {
	set root [dom::DOMImplementation parse {<?xml version="1.0"?>
	<!DOCTYPE foo SYSTEM "foo.dtd" [<!ELEMENT foo ANY>]><foo/>}]
	set doctype [dom::document cget $root -doctype]
    } -body {
	dom::doctype cget $doctype -systemId
    } -cleanup {
	dom::DOMImplementation destroy $root
    } -result foo.dtd

    test doctype-3.1 {cget options, -publicId, empty} -constraints {dom_c} -setup {
	set root [dom::DOMImplementation parse {<?xml version="1.0"?><!DOCTYPE foo><foo/>}]
	set doctype [dom::document cget $root -doctype]
    } -body {
	dom::doctype cget $doctype -publicId
    } -cleanup {
	dom::DOMImplementation destroy $root
    } -result {}
    test doctype-3.2 {cget options, -publicId, non-empty SYSTEM} -constraints {dom_c} -setup {
	set root [dom::DOMImplementation parse {<?xml version="1.0"?>
	<!DOCTYPE foo SYSTEM "foo.dtd"><foo/>}]
	set doctype [dom::document cget $root -doctype]
    } -body {
	dom::doctype cget $doctype -publicId
    } -cleanup {
	dom::DOMImplementation destroy $root
    } -result {}
    test doctype-3.3 {cget options, -publicId, non-empty PUBLIC} -constraints {dom_c} -setup {
	set root [dom::DOMImplementation parse {<?xml version="1.0"?>
	<!DOCTYPE foo PUBLIC "--Foo--" "foo.dtd"><foo/>}]
	set doctype [dom::document cget $root -doctype]
    } -body {
	dom::doctype cget $doctype -publicId
    } -cleanup {
	dom::DOMImplementation destroy $root
    } -result --Foo--
    test doctype-3.4 {cget options, -publicId, non-empty internal subset} -constraints {dom_c} -setup {
	set root [dom::DOMImplementation parse {<?xml version="1.0"?>
	<!DOCTYPE foo PUBLIC "--Foo--" "foo.dtd" [<!ELEMENT foo ANY>]><foo/>}]
	set doctype [dom::document cget $root -doctype]
    } -body {
	dom::doctype cget $doctype -publicId
    } -cleanup {
	dom::DOMImplementation destroy $root
    } -result --Foo--

    test doctype-4.1 {cget options, -nodeName, empty} -constraints {dom_c} -setup {
	set root [dom::DOMImplementation parse {<?xml version="1.0"?><!DOCTYPE foo><foo/>}]
	set doctype [dom::document cget $root -doctype]
    } -body {
	set result [dom::doctype cget $doctype -nodeName]
    } -cleanup {
	dom::DOMImplementation destroy $root
    } -result foo
    test doctype-4.2 {cget options, -nodeName, non-empty SYSTEM} -constraints {dom_c} -setup {
	set root [dom::DOMImplementation parse {<?xml version="1.0"?>
	<!DOCTYPE foo SYSTEM "foo.dtd"><foo/>}]
	set doctype [dom::document cget $root -doctype]
    } -body {
	dom::doctype cget $doctype -nodeName
    } -cleanup {
	dom::DOMImplementation destroy $root
    } -result foo
    test doctype-4.3 {cget options, -nodeName, non-empty PUBLIC} -constraints {dom_c} -setup {
	set root [dom::DOMImplementation parse {<?xml version="1.0"?>
	<!DOCTYPE foo PUBLIC "--Foo--" "foo.dtd"><foo/>}]
	set doctype [dom::document cget $root -doctype]
    } -body {
	dom::doctype cget $doctype -nodeName
    } -cleanup {
	dom::DOMImplementation destroy $root
    } -result foo
    test doctype-4.4 {cget options, -nodeName, non-empty internal subset} -constraints {dom_c} -setup {
	set root [dom::DOMImplementation parse {<?xml version="1.0"?>
	<!DOCTYPE foo PUBLIC "--Foo--" "foo.dtd" [<!ELEMENT foo ANY>]><foo/>}]
	set doctype [dom::document cget $root -doctype]
    } -body {
	dom::doctype cget $doctype -nodeName
    } -cleanup {
	dom::DOMImplementation destroy $root
    } -result foo

    test doctype-5.1 {cget options, -internalSubset} -constraints {dom_c} -setup {
	# Not implemented yet
	set root [dom::DOMImplementation parse {<?xml version="1.0"?>
	<!DOCTYPE foo PUBLIC "--Foo--" "foo.dtd" [<!ELEMENT foo ANY>]><foo/>}]
	set doctype [dom::document cget $root -doctype]
    } -body {
	dom::doctype cget $doctype -internalSubset
    } -cleanup {
	dom::DOMImplementation destroy $root
    } -result {}

    test doctype-6.1 {createDocumentType} -constraints {!dom_libxml2} -body {
	set dt [dom::DOMImplementation createDocumentType test {} {}]
	ok
    } -cleanup {
	dom::destroy $dt
    } -result {}
    test doctype-6.2 {createDocumentType w/- internal subset} -constraints {!dom_libxml2} -body {
	set dt [dom::DOMImplementation createDocumentType test {} {} {
<!ELEMENT test (#PCDATA)>
}]
	ok
    } -cleanup {
	dom::destroy $dt
    } -result {}
    test doctype-6.3 {createDocumentType: use with createDocument} -constraints {!dom_libxml2} -setup {
	set dt [dom::DOMImplementation createDocumentType test {} {}]
    } -body {
	set doc [dom::DOMImplementation createDocument {} test $dt]
	ok
    } -cleanup {
	dom::destroy $doc
	dom::destroy $dt
    } -result {}
    test doctype-6.4 {createDocumentType: use with createDocument} -constraints {!dom_libxml2} -setup {
	set dt [dom::DOMImplementation createDocumentType test {} {}]
	set doc [dom::DOMImplementation createDocument {} test $dt]
    } -body {
	string equal $dt [$doc cget -doctype]
    } -cleanup {
	dom::destroy $doc
	dom::destroy $dt
    } -result 1

    cleanupTests
}
namespace delete ::dom::doctypeTest

return