3 # Copyright (c) 2005 Jonas Fonseca
6 test_description
='Test dumping of SGML documents.
8 Test that DOM documents are consistently dumped to SGML.
9 Note, this also test whether attribute nodes are sorted
15 test_sgml_dump_exact
() {
19 sgml-parser
--dump --src "$src" > output
20 echo -n "$src" > expected
22 test_expect_success
"$desc" 'cmp output expected'
25 test_sgml_dump_equals
() {
30 sgml-parser
--dump --src "$src" > output
31 echo -n "$out" > expected
33 test_expect_success
"$desc" 'cmp output expected'
37 ################################################################
38 # Parse various SGML node types.
40 test_sgml_dump_exact \
41 'Parse a small document.' \
42 '<html><body><p>Hello World!</p></body></html>'
44 test_sgml_dump_exact \
45 'Parse an enclosed comment.' \
46 '<root><!-- Hello World! --></root>'
48 test_sgml_dump_exact \
49 'Parse comment combinations. (I)' \
50 '<root><!-- <!-- -- > --><!--foo--><!----></root>'
52 test_sgml_dump_exact \
53 'Parse comment combinations. (II).' \
54 '<!-- comment -->s<!-->-->t<!----->u'
56 test_sgml_dump_exact \
57 'Parse empty comment.' \
60 test_sgml_dump_exact \
61 'Parse an enclosed CDATA section.' \
62 '<root><![CDATA[...] ]>...]]></root>'
64 test_sgml_dump_exact \
65 'Parse non-enclosed CDATA section.' \
68 test_sgml_dump_exact \
70 '<e a="1" b="2" c=""></e>'
72 test_sgml_dump_exact \
73 'Parse XML stylesheet processing instructions.' \
74 '<?xml-stylesheet type="text/xsl" href="url"?>'
76 test_sgml_dump_exact \
77 'Parse entity references.' \
80 #############################################################################
81 # Test tidy up dumping
83 test_sgml_dump_equals \
85 '<root><child attr="value" /><child2></><child3 >a</></root>' \
86 '<root><child attr="value"></child><child2></child2><child3>a</child3></root>'
88 test_sgml_dump_equals \
89 'Parse attributes with garbage.' \
90 "<root a=b c='d' e'f' g= h i = j k =></root>" \
91 "<root a=\"b\" c='d' g=\"h\" i=\"j\" k></root>"
93 test_sgml_dump_equals \
94 'Parse bad comment. (II)' \
95 '<!--a--!>bad comment' \
98 test_sgml_dump_equals \
99 'Parse empty notation.' \
103 test_sgml_dump_equals \
104 'Parse a bad CDATA section.' \
108 test_sgml_dump_equals \
109 'Parse tag soup elements. (I)' \
110 '<parent attr="value" <child:1></><child:2</>a</parent>' \
111 '<parent attr="value"><child:1></child:1><child:2></child:2>a</parent>'
113 test_sgml_dump_equals \
114 'Parse tag soup elements. (II)' \
115 '< a >< b < c / >< / >' \
116 '<a><b><c></c></b></a>'
118 test_sgml_dump_equals \
119 'Parse attribute with non-quoted values.' \
120 '<root color=#abc path=/to/%61-&\one";files/>...' \
121 '<root color="#abc" path="/to/%61-&\one";files"></root>...'
123 # Just how these should be gracefully handled is not clear to me.
124 test_sgml_dump_equals \
125 'Parse badly formatted entity references.' \
126 '& m33p;-&.:-copy;-&;-&#;-&#xx;' \
127 '& m33p;-&.:-copy;-&;-&#;-&#xx;'
129 test_sgml_dump_equals \
130 'Parse processing instructions.' \
131 '<?xml encoding="UTF8"?>
136 '<?xml encoding="UTF8"?>
138 <?ecmascript var val=2;
141 test_sgml_dump_equals \
142 'Parse XML processing instructions.' \
143 '<?xml version="1.0" />?><?xml />-' \
144 '<?xml version="1.0" />?><?xml />-?>'
146 test_sgml_dump_equals \
147 'Parse exotic processing instructions.' \
148 '<?xml ?+>+?>-?>-<?js?>-<??>-' \
149 '<?xml ?+>+?>-?>-<?js ?>-<? ?>-'
151 test_sgml_dump_equals \
152 'Parse incorrect processing instructions. (I)' \
153 '<?js<?>-<?<??>-<?xml <=";&?>-<?' \
154 '<?js <?>-<? <??>-<?xml <=";&?>-' \
156 test_sgml_dump_equals \
157 'Parse incorrect processing instructions. (II)' \
161 test_sgml_dump_equals \
162 'Skip spaces not inside text.' \
171 '<root ns:attr="value"><?target data?></root>'