Debian Codegraph @

rhino/testsrc/tests/e4x/XML/13.4.3.js

raw symbols SCIP
1 /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 gTestfile = '13.4.3.js';
8
9 START("13.4.3 - XML Properties");
10
11 // Test defaults
12 TEST(1, true, XML.ignoreComments);
13 TEST(2, true, XML.ignoreProcessingInstructions);
14 TEST(3, true, XML.ignoreWhitespace);
15 TEST(4, true, XML.prettyPrinting);
16 TEST(5, 2, XML.prettyIndent);
17
18 // ignoreComments
19 x = <alpha><!-- comment --><bravo>one</bravo></alpha>;
20
21 correct = <alpha><bravo>one</bravo></alpha>;
22
23 TEST(6, correct, x);
24
25 XML.ignoreComments = false;
26
27 x = <alpha><!-- comment --><bravo>one</bravo></alpha>;
28
29 correct =
30 "<alpha>\n" +
31 " <!-- comment -->\n" +
32 " <bravo>one</bravo>\n" +
33 "</alpha>";
34
35 TEST_XML(7, correct, x);
36
37
38 // ignoreProcessingInstructions
39 XML.setSettings();
40 x =
41 <>
42 <alpha>
43 <?foo version="1.0" encoding="utf-8"?>
44 <bravo>one</bravo>
45 </alpha>
46 </>;
47
48 correct =
49 <alpha>
50 <bravo>one</bravo>
51 </alpha>;
52
53 TEST(8, correct, x);
54
55 XML.ignoreProcessingInstructions = false;
56
57 x =
58 <>
59 <alpha>
60 <?foo version="1.0" encoding="utf-8"?>
61 <bravo>one</bravo>
62 </alpha>
63 </>;
64
65 correct =
66 "<alpha>\n" +
67 " <?foo version=\"1.0\" encoding=\"utf-8\"?>\n" +
68 " <bravo>one</bravo>\n" +
69 "</alpha>";
70
71 TEST_XML(9, correct, x);
72
73 // ignoreWhitespace
74 XML.setSettings();
75 x = new XML("<alpha> \t\r\n\r\n<bravo> \t\r\n\r\none</bravo> \t\r\n\r\n</alpha>");
76
77 correct =
78 "<alpha>\n" +
79 " <bravo>one</bravo>\n" +
80 "</alpha>";
81
82 TEST_XML(10, correct, x);
83
84 XML.ignoreWhitespace = false;
85 XML.prettyPrinting = false;
86
87 correct = "<alpha> \n\n<bravo> \n\none</bravo> \n\n</alpha>";
88 x = new XML(correct);
89
90 TEST_XML(11, correct, x);
91
92 // prettyPrinting
93 XML.setSettings();
94
95 x =
96 <alpha>
97 one
98 <bravo>two</bravo>
99 <charlie/>
100 <delta>
101 three
102 <echo>four</echo>
103 </delta>
104 </alpha>;
105
106 correct = "<alpha>\n" +
107 " one\n" +
108 " <bravo>two</bravo>\n" +
109 " <charlie/>\n" +
110 " <delta>\n" +
111 " three\n" +
112 " <echo>four</echo>\n" +
113 " </delta>\n" +
114 "</alpha>";
115
116 TEST(12, correct, x.toString());
117 TEST(13, correct, x.toXMLString());
118
119 XML.prettyPrinting = false;
120
121 correct = "<alpha>one<bravo>two</bravo><charlie/><delta>three<echo>four</echo></delta></alpha>";
122 TEST(14, correct, x.toString());
123 TEST(15, correct, x.toXMLString());
124
125 // prettyIndent
126 XML.prettyPrinting = true;
127 XML.prettyIndent = 3;
128
129 correct = "<alpha>\n" +
130 " one\n" +
131 " <bravo>two</bravo>\n" +
132 " <charlie/>\n" +
133 " <delta>\n" +
134 " three\n" +
135 " <echo>four</echo>\n" +
136 " </delta>\n" +
137 "</alpha>";
138
139 TEST(16, correct, x.toString());
140 TEST(17, correct, x.toXMLString());
141
142 XML.prettyIndent = 0;
143
144 correct = "<alpha>\n" +
145 "one\n" +
146 "<bravo>two</bravo>\n" +
147 "<charlie/>\n" +
148 "<delta>\n" +
149 "three\n" +
150 "<echo>four</echo>\n" +
151 "</delta>\n" +
152 "</alpha>";
153
154 TEST(18, correct, x.toString());
155 TEST(19, correct, x.toXMLString());
156
157 // settings()
158 XML.setSettings();
159 o = XML.settings();
160 TEST(20, true, o.ignoreComments);
161 TEST(21, true, o.ignoreProcessingInstructions);
162 TEST(22, true, o.ignoreWhitespace);
163 TEST(23, true, o.prettyPrinting);
164 TEST(24, 2, o.prettyIndent);
165
166 // setSettings()
167 o = XML.settings();
168 o.ignoreComments = false;
169 o.ignoreProcessingInstructions = false;
170 o.ignoreWhitespace = false;
171 o.prettyPrinting = false;
172 o.prettyIndent = 7;
173
174 XML.setSettings(o);
175 o = XML.settings();
176 TEST(25, false, o.ignoreComments);
177 TEST(26, false, o.ignoreProcessingInstructions);
178 TEST(27, false, o.ignoreWhitespace);
179 TEST(28, false, o.prettyPrinting);
180 TEST(29, 7, o.prettyIndent);
181
182 // setSettings()
183 XML.setSettings();
184 o = XML.settings();
185 TEST(30, true, o.ignoreComments);
186 TEST(31, true, o.ignoreProcessingInstructions);
187 TEST(32, true, o.ignoreWhitespace);
188 TEST(33, true, o.prettyPrinting);
189 TEST(34, 2, o.prettyIndent);
190
191 correct = new XML('');
192
193 // ignoreComments
194 XML.ignoreComments = true;
195 x = <!-- comment -->;
196 TEST(35, correct, x);
197
198 // ignoreProcessingInstructions
199 XML.ignoreProcessingInstructions = true;
200 x = <?pi?>;
201 TEST(36, correct, x);
202
203 END();