1// XMLNode_as.hx:  ActionScript 3 "XMLNode" class, for Gnash.
2//
3// Generated by gen-as3.sh on: 20090514 by "rob". Remove this
4// after any hand editing loosing changes.
5//
6//   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
7//
8// This program is free software; you can redistribute it and/or modify
9// it under the terms of the GNU General Public License as published by
10// the Free Software Foundation; either version 3 of the License, or
11// (at your option) any later version.
12//
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21//
22
23// This test case must be processed by CPP before compiling to include the
24//  DejaGnu.hx header file for the testing framework support.
25
26#if flash9
27import flash.xml.XMLNode;
28import flash.xml.XMLNodeType;
29import flash.display.MovieClip;
30import flash.xml.XMLDocument;
31#else
32import Xml;
33import flash.MovieClip;
34#end
35import flash.Lib;
36import Type;
37import Std;
38import Reflect;
39
40// import our testing API
41import DejaGnu;
42
43// Class must be named with the _as suffix, as that's the same name as the file.
44class XMLNode_as {
45    static function main() {
46	#if flash9
47        var x1:XMLNode = new XMLNode(XMLNodeType.ELEMENT_NODE, null);
48
49        // Make sure we actually get a valid class
50        if (Std.is(x1, XMLNode)) {
51            DejaGnu.pass("XMLNode class exists");
52        } else {
53            DejaGnu.fail("XMLNode class doesn't exist");
54        }
55
56	// Tests to see if all the properties exist. All these do is test for
57	// existance of a property, and don't test the functionality at all. This
58	// is primarily useful only to test completeness of the API implementation.
59
60	if (Std.is(x1.attributes, Dynamic)) {
61	    DejaGnu.pass("XMLNode.attributes property exists");
62 	} else {
63	    DejaGnu.fail("XMLNode.attributes property doesn't exist");
64 	}
65	if (Std.is(x1.childNodes, Array)) {
66	    DejaGnu.pass("XMLNode.childNodes property exists");
67 	} else {
68 	    DejaGnu.fail("XMLNode.childNodes property doesn't exist");
69	}
70	if (Type.typeof(x1.namespaceURI)==ValueType.TNull) {
71	    DejaGnu.pass("XMLNode.namespaceURI property exists");
72	} else {
73	    DejaGnu.fail("XMLNode.namespaceURI property doesn't exist");
74	}
75	if (Type.typeof(x1.nodeName)==ValueType.TNull) {
76	    DejaGnu.pass("XMLNode.nodeName property exists");
77	} else {
78	    DejaGnu.fail("XMLNode.nodeName property doesn't exist");
79	}
80	if (Type.typeof(x1.nodeValue)==ValueType.TNull) {
81	    DejaGnu.pass("XMLNode.nodeValue property exists");
82	} else {
83	    DejaGnu.fail("XMLNode.nodeValue property doesn't exist");
84	}
85	if (x1.prefix == null) {
86	    DejaGnu.pass("XMLNode.prefix property exists");
87	} else {
88	    DejaGnu.fail("XMLNode.prefix property doesn't exist");
89	}
90
91	// Tests to see if all the methods exist. All these do is test for
92	// existance of a method, and don't test the functionality at all. This
93	// is primarily useful only to test completeness of the API implementation.
94	if (Type.typeof(x1.appendChild)==ValueType.TFunction) {
95	    DejaGnu.pass("XMLNode::appendChild() method exists");
96	} else {
97	    DejaGnu.fail("XMLNode::appendChild() method doesn't exist");
98	}
99	if (Type.typeof(x1.cloneNode)==ValueType.TFunction) {
100 	    DejaGnu.pass("XMLNode::cloneNode() method exists");
101	} else {
102 	    DejaGnu.fail("XMLNode::cloneNode() method doesn't exist");
103 	}
104	if (Type.typeof(x1.getNamespaceForPrefix)==ValueType.TFunction) {
105	    DejaGnu.pass("XMLNode::getNamespaceForPrefix() method exists");
106	} else {
107	    DejaGnu.fail("XMLNode::getNamespaceForPrefix() method doesn't exist");
108	}
109	if (Type.typeof(x1.getPrefixForNamespace)==ValueType.TFunction) {
110	    DejaGnu.pass("XMLNode::getPrefixForNamespace() method exists");
111	} else {
112	    DejaGnu.fail("XMLNode::getPrefixForNamespace() method doesn't exist");
113	}
114	if (Type.typeof(x1.hasChildNodes)==TFunction) {
115	    DejaGnu.pass("XMLNode::hasChildNodes() method exists");
116 	} else {
117 	    DejaGnu.fail("XMLNode::hasChildNodes() method doesn't exist");
118 	}
119	if (Type.typeof(x1.insertBefore)==TFunction) {
120	    DejaGnu.pass("XMLNode::insertBefore() method exists");
121	} else {
122	    DejaGnu.fail("XMLNode::insertBefore() method doesn't exist");
123	}
124	if (Type.typeof(x1.removeNode)==TFunction) {
125	    DejaGnu.pass("XMLNode::removeNode() method exists");
126	} else {
127	    DejaGnu.fail("XMLNode::removeNode() method doesn't exist");
128	}
129	if (Type.typeof(x1.toString)==TFunction) {
130	    DejaGnu.pass("XMLNode::toString() method exists");
131	} else {
132	    DejaGnu.fail("XMLNode::toString() method doesn't exist");
133	}
134
135	//imported ming tests ported over for flashv9
136	var doc:XMLNode = new XMLNode(untyped 3, "text constant");
137
138	if (doc != null) {
139		DejaGnu.pass("Succesfully created XMLNode of type textnode");
140	} else {
141		DejaGnu.fail("Couldn't create XMLNode of type textnode (uint 3)");
142	}
143
144	if (Std.is(doc, XMLNode)) {
145		DejaGnu.pass("textnode has the right valuetype");
146	} else {
147		DejaGnu.fail("textnode doesn't have the right valuetype");
148	}
149
150	if (Type.typeof(doc.attributes) == ValueType.TObject) {
151		DejaGnu.pass("XMLNode.textnode.attributes has the correct type.");
152	} else {
153		DejaGnu.fail("XMLNode.textnode.attributes isn't type 'object'");
154	}
155
156	//check that the new object still has the correct functions
157	if (Type.typeof(doc.appendChild) == ValueType.TFunction) {
158		DejaGnu.pass("XMLNode.textnode.appendChild function exists");
159	} else {
160		DejaGnu.fail("XMLNode.textnode.appendChild function doesn't exist after constructing an object");
161	}
162	if (Type.typeof(doc.cloneNode) == ValueType.TFunction) {
163		DejaGnu.pass("XMLNode.textnode.cloneNode function exists");
164	} else {
165		DejaGnu.fail("XMLNode.textnode.cloneNode function doesn't exist after constructing an object");
166	}
167	if (Type.typeof(doc.hasChildNodes) == ValueType.TFunction) {
168		DejaGnu.pass("XMLNode.textnode.hasChildNodes function exists");
169	} else {
170		DejaGnu.fail("XMLNode.textnode.hasChildNodes function doesn't exist after constructing an object");
171	}
172	if (Type.typeof(doc.insertBefore) == ValueType.TFunction) {
173		DejaGnu.pass("XMLNode.textnode.insertBefore function exists");
174	} else {
175		DejaGnu.fail("XMLNode.textnode.insertBefore function doesn't exist after constructing an object");
176	}
177	if (Type.typeof(doc.removeNode) == ValueType.TFunction) {
178		DejaGnu.pass("XMLNode.textnode.removeNode function exists");
179	} else {
180		DejaGnu.fail("XMLNode.textnode.removeNode function doesn't exist after constructing an object");
181	}
182	if (Type.typeof(doc.toString) == ValueType.TFunction) {
183		DejaGnu.pass("XMLNode.textnode.toString function exists");
184	} else {
185		DejaGnu.fail("XMLNode.textnode.toString function doesn't exist after constructing an object");
186	}
187
188	//test functionality of properties
189	doc.nodeName = "foo";
190	if (Std.string(doc.nodeName) == "foo") {
191		DejaGnu.pass("XMLNode.nodeName has correct constant value (foo)");
192	} else {
193		DejaGnu.fail("XMLNode.nodeName doesn't have correct constant value (should be foo)");
194	}
195	if (Std.string(doc.nodeValue) == "text constant") {
196		DejaGnu.pass("XMLNode.nodeValue has correct constant value (textconstant)");
197	} else {
198		DejaGnu.fail("XMLNode.nodeValue doesn't have correct constant value (should be 'textconstant')");
199	}
200
201	//give a new nodeValue field
202	doc.nodeValue = "bar";
203	if (Std.string(doc.nodeValue) == "bar") {
204		DejaGnu.pass("XMLNode.nodeValue has correct constant value (bar)");
205	} else {
206		DejaGnu.fail("XMLNode.nodeValue doesn't have the right value (should be bar)");
207	}
208
209	//doc doesn't have children yet, should return false and null for tests below
210	if (Std.string(doc.hasChildNodes()) == "false") {
211		DejaGnu.pass("XMLNode.hasChildNodes is returning proper value");
212	} else {
213		DejaGnu.fail("XMLNode.hasChildNodes is returning the wrong value (true when should be false)");
214	}
215	if (Std.string(doc.firstChild) == "null") {
216		DejaGnu.pass("XMLNode.firstChild is properly returning null");
217	} else {
218		DejaGnu.fail("XMLNode.firstChild is not properly returning null");
219	}
220	if (Std.string(doc.lastChild) == "null") {
221		DejaGnu.pass("XMLNode.lastChild is properly returning null");
222	} else {
223		DejaGnu.fail("XMLNode.lastChild is not properly returning null");
224	}
225	if (Std.string(doc.parentNode) == "null") {
226		DejaGnu.pass("XMLNode.parentNode is properly returning null");
227	} else {
228		DejaGnu.fail("XMLNode.parentNode is not properly returning null");
229	}
230	if (Std.string(doc.nextSibling) == "null") {
231		DejaGnu.pass("XMLNode.nextSibling is properly returning null");
232	} else {
233		DejaGnu.fail("XMLNode.nextSibling is not properly returning null");
234	}
235	if (Std.string(doc.previousSibling) == "null") {
236		DejaGnu.pass("XMLNode.previousSibling is properly returning null");
237	} else {
238		DejaGnu.fail("XMLNode.previousSibling is not properly returning null");
239	}
240
241	//now test functionality of methods
242	var node1:XMLNode = new XMLNode(untyped 1, "node1");
243	var node2:XMLNode = new XMLNode(untyped 1, "node2");
244	var textnode1:XMLNode = new XMLNode(untyped 3, "first text node");
245	var textnode2:XMLNode = new XMLNode(untyped 3, "second text node");
246
247	if (Std.string(textnode1.nodeType) == "3") {
248		DejaGnu.pass("XMLNode.textnode1 has the correct value");
249	} else {
250		DejaGnu.fail("XMLNode.textnode1 doesn't have the correct value");
251	}
252
253	//append some children to node1 (created above)
254	node1.appendChild(textnode1);
255	node2.appendChild(textnode2);
256	node1.appendChild(node2);
257
258	if (node1.hasChildNodes() == true) {
259		DejaGnu.pass("node1 is properly returning that it has child nodes");
260	} else {
261		DejaGnu.fail("node1 isn't properly returning that it has child nodes");
262	}
263	if (Std.string(node1.firstChild.nodeValue) == "first text node") {
264		DejaGnu.pass("node1::firstChild is returning the right value");
265	} else {
266		DejaGnu.fail("node1::firstChild isn't returning the right value");
267	}
268	if (Type.typeof(node1.lastChild.nodeValue) == ValueType.TNull) {
269		DejaGnu.pass("node1::lastChild.nodeValue is returning the right value");
270	} else {
271		DejaGnu.fail("node1::lastChild.nodeValue is not returning the right value");
272	}
273	if (node2.lastChild.toString() == "second text node") {
274		DejaGnu.pass("node1::lastChild.toString is returning the right value");
275	} else {
276		DejaGnu.fail("node1::lastChild.toString is not returning the right value");
277	}
278
279	//create some more nodes and append them
280	var node3:XMLNode = new XMLNode(untyped 1, "node3");
281	var textnode3:XMLNode = new XMLNode(untyped 3, "third text node");
282	node3.appendChild(textnode3);
283	node1.appendChild(node3);
284
285	//childNodes should be an array
286	if (Std.is(node1.childNodes, Array)) {
287		DejaGnu.pass("childNodes is an array");
288	} else {
289		DejaGnu.fail("childNodes isn't an array");
290	}
291	if (Type.typeof(node1.childNodes.push) == ValueType.TFunction) {
292		DejaGnu.pass("XMLNode can push onto the childNodes array");
293	} else {
294		DejaGnu.fail("XMLNode can't push onto the childNodes array (function not defined)");
295	}
296
297	//node1 should have three children at this point (textnode1, node2, node 3)
298	if (Std.string(node1.childNodes.length) == "3") {
299		DejaGnu.pass("node1.childNodes is returning the proper length");
300	} else {
301		DejaGnu.fail("node1.childNodes is returning the incorrect length");
302	}
303
304	//now it has 4, but the element declared below is not an XMLNode
305	node1.childNodes.push("not a node");
306	if (Std.string(node1.childNodes.length) == "4") {
307		DejaGnu.pass("node1.childNodes is returning the proper length");
308	} else {
309		DejaGnu.fail("node1.childNodes is returning the incorrect length");
310	}
311	if (!Std.is(node1.childNodes[3], XMLNode)) {
312		DejaGnu.pass("Gnash properly handled the bad node input to childNodes");
313	} else {
314		DejaGnu.fail("Gnash didn't properly handle the bad node input to childNodes");
315	}
316
317	//now it has 5. the latest element is an XMLNode, but it does not become lastChild
318	node1.childNodes.push(new XMLNode(untyped 1, "an XMLNode"));
319	if (Std.string(node1.childNodes.length) == "5") {
320		DejaGnu.pass("node1.childNodes is returning the proper length");
321	} else {
322		DejaGnu.fail("node1.childNodes is returning the incorrect length");
323	}
324	if (Std.is(node1.childNodes[4], XMLNode)) {
325		DejaGnu.pass("Gnash properly handled the manual input to childNodes");
326	} else {
327		DejaGnu.fail("Gnash didn't properly handle the manual input to childNodes");
328	}
329	if (Std.string(node1.lastChild.toString()) == "<node3>third text node</node3>") {
330		DejaGnu.pass("node1.lastChild.toString() returned the correct value");
331	} else {
332		DejaGnu.fail("node1.lastChild.toString() did not return the correct value");
333	}
334
335	//since child nodes is an array we should be able to access it as such and sort it as well
336	if (node1.childNodes[0].toString() == "first text node") {
337		DejaGnu.pass("node1.childNodes[0].toString() returned the correct string");
338	} else {
339		DejaGnu.fail("node1.childNodes[0].toString() did not return the correct string");
340	}
341	if (node1.childNodes[2].toString() == "<node3>third text node</node3>") {
342		DejaGnu.pass("node1.childNodes[2].toString() returned the correct string");
343	} else {
344		DejaGnu.fail("node1.childNodes[2].toString() did not return the correct string");
345	}
346	if (node1.childNodes[3].toString() == "not a node") {
347		DejaGnu.pass("node1.childNodes[3].toString() returned the correct string");
348	} else {
349		DejaGnu.fail("node1.childNodes[3].toString() did not return the correct string");
350	}
351	//sorting here
352	Reflect.callMethod(node1.childNodes, Reflect.field(node1.childNodes, "sort"), []);
353	//make sure the array sorted correctly
354	if (node1.childNodes[0].toString() == "<an XMLNode />") {
355		DejaGnu.pass("node1.childNodes[0].toString() returned the correct string");
356	} else {
357		DejaGnu.fail("node1.childNodes[0].toString() did not return the correct string");
358	}
359	if (node1.childNodes[2].toString() == "<node3>third text node</node3>") {
360		DejaGnu.pass("node1.childNodes[2].toString() returned the correct string");
361	} else {
362		DejaGnu.fail("node1.childNodes[2].toString() did not return the correct string");
363	}
364	if (node1.childNodes[3].toString() == "first text node") {
365		DejaGnu.pass("node1.childNodes[3].toString() returned the correct string");
366	} else {
367		DejaGnu.fail("node1.childNodes[3].toString() did not return the correct string");
368	}
369
370	//the array should be able to handle any sort of input
371	node1.childNodes.push(new Date(2009,03,20,04,20,00));
372	if (Std.string(node1.childNodes.length) == "6") {
373		DejaGnu.pass("node1.childNodes is returning the proper length");
374	} else {
375		DejaGnu.fail("node1.childNodes is returning the incorrect length");
376	}
377	if (Std.is(node1.childNodes[5], Date)) {
378		DejaGnu.pass("node1.childNodes[5] is returning correct Date type.");
379	} else {
380		DejaGnu.fail("node1.childNodes[5] has the wrong type (not Date type).");
381	}
382
383	//don't try to access childNodes[5] as ActionScript will throw an error
384	//apparently gnash will handle this, but while testing with gflashplayer
385	//threw an actionscript error
386	node1.lastChild.appendChild(new XMLNode(untyped 1, "datenode"));
387
388	var o = {
389		toString : function() {
390			return "o.toString()";
391		}
392	};
393	if (Std.string(node1.childNodes.length) == "6") {
394		DejaGnu.pass("node1.childNodes is returning the proper length");
395	} else {
396		DejaGnu.fail("node1.childNodes is returning the incorrect length");
397	}
398	//push new o var to the array
399	node1.childNodes.push(o);
400	if (Std.string(node1.childNodes.length) == "7") {
401		DejaGnu.pass("node1.childNodes is returning the proper length");
402	} else {
403		DejaGnu.fail("node1.childNodes is returning the incorrect length");
404	}
405	if (node1.childNodes[6].toString() == "o.toString()") {
406		DejaGnu.pass("node1.childNodes[6].toString() is returning the proper string");
407	} else {
408		DejaGnu.fail("node1.childNodes[6].toString() is returning the incorrect string");
409	}
410
411	//the last child should still be node3
412	//haxe doesn't understand the pointers to these nodes, so check to make sure
413	//the nodes simply don't have the same contents with Std.string (no nodes have
414	//the same contents at this point)
415	if (Std.string(node1.lastChild) != Std.string(node1.childNodes[6])) {
416		DejaGnu.pass("node1.lastChild is returning the correct node");
417	} else {
418		DejaGnu.fail("node1.lastChild is returning the wrong node");
419	}
420	if (node1.lastChild.nodeName == "node3") {
421		DejaGnu.pass("node1.lastChild.nodeName is returning the correct node name");
422	} else {
423		DejaGnu.fail("node1.lastChild.nodeName is returning the wrong node name");
424	}
425	if (node1.firstChild.toString() == "first text node") {
426		DejaGnu.pass("node1.firstChild is returning the correct string");
427	} else {
428		DejaGnu.fail("node1.firstChild is returning the wrong string");
429	}
430
431	//last child should only change when a valid node is added to the list
432	//and 'fake' elements should disappear
433	var node4:XMLNode = new XMLNode(untyped 1, "4node");
434	node1.appendChild(node4);
435	if (node1.lastChild.toString() == "<4node />") {
436		DejaGnu.pass("node1.lastChild is returning the correct string");
437	} else {
438		DejaGnu.fail("node1.lastChild is returning the wrong string");
439	}
440	if (Std.string(node1.childNodes.length) == "8") {
441		DejaGnu.pass("node1.childNodes is returning the proper length");
442	} else {
443		DejaGnu.fail("node1.childNodes is returning the incorrect length");
444	}
445	if (node1.childNodes[node1.childNodes.length - 1].toString() == "<4node />") {
446		DejaGnu.pass("node1.childNodes.length-1 is returning the proper string");
447	} else {
448		DejaGnu.fail("node1.childNodes.length-1 is returning the incorrect string");
449	}
450
451	//sorting here
452	Reflect.callMethod(node1.childNodes, Reflect.field(node1.childNodes, "sort"), []);
453	//sorting should only affect the array itself, not lastChild
454	if (node1.lastChild.toString() == "<4node />") {
455		DejaGnu.pass("node1.lastChild is returning the correct string");
456	} else {
457		DejaGnu.fail("node1.lastChild is returning the wrong string");
458	}
459	if (node1.childNodes[node1.childNodes.length - 1].toString() != "first text node") {
460		DejaGnu.pass("node1.childNodes[node1.childNodes.length - 1] is returning the correct string");
461	} else {
462		DejaGnu.fail("node1.childNodes[node1.childNodes.length - 1] is returning the wrong string");
463	}
464	if (node1.firstChild.nodeValue == "first text node") {
465		DejaGnu.pass("node1.firstChild.nodeValue is returning the correct string");
466	} else {
467		DejaGnu.fail("node1.firstChild.nodeValue is returning the wrong string");
468	}
469	if (Type.typeof(node1.lastChild.nodeValue) == ValueType.TNull) {
470		DejaGnu.pass("node1.lastChild.nodeValue is returning the correct type");
471	} else {
472		DejaGnu.fail("node1.lastChild.nodeValue is returning the wrong type");
473	}
474	if (Type.typeof(node1.firstChild.nodeName) == ValueType.TNull) {
475		DejaGnu.pass("node1.firstChild.nodeName is returning the correct type");
476	} else {
477		DejaGnu.fail("node1.firstChild.nodeName is returning the wrong type");
478	}
479	if (node1.lastChild.nodeName == "4node") {
480		DejaGnu.pass("node1.lastChild.nodeName is returning the correct string");
481	} else {
482		DejaGnu.fail("node1.lastChild.nodeName is returning the wrong string");
483	}
484	if (node2.previousSibling.nodeValue == "first text node") {
485		DejaGnu.pass("node1.previousSibling.nodeValue is returning the correct string");
486	} else {
487		DejaGnu.fail("node1.previousSibling.nodeValue is returning the wrong string");
488	}
489
490	//TODO: Test insertNode and removeNode
491
492	//node2 shouldn't currently have any attributes (denoted by {} as a string)
493	if (Std.string(node2.attributes) == "{}") {
494		DejaGnu.pass("node2.attributes is empty (expected)");
495	} else {
496		DejaGnu.fail("node2.attributes is not empty");
497	}
498	if(Type.typeof(node2.attributes) == ValueType.TObject) {
499		DejaGnu.pass("node2.attributes is returning the correct type");
500	} else {
501		DejaGnu.fail("node2.attributes is returning the wrong type");
502	}
503
504	//insert some attributes
505	node2.attributes[3] = "a3";
506	if (node2.attributes[3] == "a3") {
507		DejaGnu.pass("node2.attributes[3] is returning the correct value");
508	} else {
509		DejaGnu.fail("node2.attributes[3] is returning the wrong value");
510	}
511	if (node2.attributes[untyped "3"] == "a3") {
512		DejaGnu.pass("node2.attributes['3'] is returning the correct value");
513	} else {
514		DejaGnu.fail("node2.attributes['3'] is returning the wrong value");
515	}
516	node2.attributes.aattrib = "aa";
517	if (node2.attributes.aattrib == "aa") {
518		DejaGnu.pass("node2.attributes.aattrib is returning the correct value");
519	} else {
520		DejaGnu.fail("node2.attributes.aattrib is returning the wrong value");
521	}
522	if (node2.attributes[untyped "aattrib"] == "aa") {
523		DejaGnu.pass("node2.attributes['aattrib'] is returning the correct value");
524	} else {
525		DejaGnu.fail("node2.attributes['aattrib'] is returning the wrong value");
526	}
527	if (node2.toString() == '<node2 aattrib="aa" 3="a3">second text node</node2>') {
528		DejaGnu.pass("node2.toString() is returning the correct value");
529	} else {
530		DejaGnu.fail("node2.toString() is returning the wrong value");
531	}
532
533	//create some more nodes to append attributes to
534	var node77:XMLNode = new XMLNode(untyped 1, "tag");
535	node77.attributes.aattrib = "at1";
536	if (node77.toString() == '<tag aattrib="at1" />') {
537		DejaGnu.pass("node77.toString() is returning the correct value");
538	} else {
539		DejaGnu.fail("node77.toString() is returning the wrong value");
540	}
541
542	//check the order attributes are applied
543	node77.attributes.zattrib = "z";
544	node77.attributes.xattrib = "x";
545	node77.attributes.cattrib = "c";
546	node77.attributes.yattrib = "y";
547	node77.attributes.fattrib = "f";
548	node77.attributes[5] = "5";
549	node77.attributes[untyped "$"] = "$";
550	node77.attributes.xattrib = "x2";
551	if (node77.toString() == '<tag zattrib="z" yattrib="y" aattrib="at1" cattrib="c" $="$" xattrib="x2" 5="5" fattrib="f" />') {
552		DejaGnu.pass("node77.toString() is returning the correct value");
553	} else {
554		DejaGnu.fail("node77.toString() is returning the wrong value");
555	}
556
557	//Check namespaces
558
559	//Standard namespace
560	var x:XMLDocument = new XMLDocument('<tag xmlns="standard" attrib="u">text</tag>');
561	var ns:XMLNode = new XMLNode(untyped 1, "tag");
562	ns = x.firstChild;
563	if (ns.nodeName == "tag") {
564		DejaGnu.pass("ns.nodeName is returning the correct value");
565	} else {
566		DejaGnu.fail("ns.nodeName is returning the wrong value");
567	}
568	if (ns.attributes[untyped "attrib"] == "u") {
569		DejaGnu.pass("ns.nodeName['attrib'] is returning the correct value");
570	} else {
571		DejaGnu.fail("ns.nodeName['attrib'] is returning the wrong value");
572	}
573	if (ns.attributes[untyped "xmlns"] == "standard") {
574		DejaGnu.pass("ns.nodeName['xmlns'] is returning the correct value");
575	} else {
576		DejaGnu.fail("ns.nodeName['xmlns'] is returning the wrong value");
577	}
578	if (ns.namespaceURI == "standard") {
579		DejaGnu.pass("ns.namespaceURI is returning the correct value");
580	} else {
581		DejaGnu.fail("ns.namespaceURI is returning the wrong value");
582	}
583	if (ns.getNamespaceForPrefix("") == "standard") {
584		DejaGnu.pass("ns.getNamespaceForPrefix('') is returning the correct value");
585	} else {
586		DejaGnu.fail("ns.getNamespaceForPrefix('') is returning the wrong value");
587	}
588	if (ns.getPrefixForNamespace("standard") == "") {
589		DejaGnu.pass("ns.getPrefixForNamespace('standard') is returning the correct value");
590	} else {
591		DejaGnu.fail("ns.getPrefixForNamespace('standard') is returning the wrong value");
592	}
593	ns.attributes[untyped "xmlns"] = "standard2";
594	if (ns.namespaceURI == "standard2") {
595		DejaGnu.pass("ns.namespaceURI is returning the correct value");
596	} else {
597		DejaGnu.fail("ns.namespaceURI is returning the wrong value");
598	}
599	if (ns.getNamespaceForPrefix("") == "standard2") {
600		DejaGnu.pass("ns.getNamespaceForPrefix('') is returning the correct value");
601	} else {
602		DejaGnu.fail("ns.getNamespaceForPrefix('') is returning the wrong value");
603	}
604
605	//make ns its own firstChild
606	ns = ns.firstChild;
607	if (Std.string(ns.nodeName) == "null") {
608		DejaGnu.pass("ns.nodeName is returning the correct value");
609	} else {
610		DejaGnu.fail("ns.nodeName is returning the wrong value");
611	}
612	if (ns.nodeValue == "text") {
613		DejaGnu.pass("ns.nodeValue is returning the correct value");
614	} else {
615		DejaGnu.fail("ns.nodeValue is returning the wrong value");
616	}
617	if (ns.namespaceURI == null) {
618		DejaGnu.pass("ns.namespaceURI is returning the correct value");
619	} else {
620		DejaGnu.fail("ns.namespaceURI is returning the wrong value");
621	}
622	if (ns.prefix == null) {
623		DejaGnu.pass("ns.prefix is returning the correct value");
624	} else {
625		DejaGnu.fail("ns.prefix is returning the wrong value");
626	}
627
628	//redefine x with new xml tags
629	x = new XMLDocument('<tag xmlns:t="standard"></tag>');
630	ns = x.firstChild;
631	if (ns.namespaceURI == null) {
632		DejaGnu.pass("ns.namespaceURI is returning the correct value");
633	} else {
634		DejaGnu.fail("ns.namespaceURI is returning the wrong value");
635	}
636	if (ns.getNamespaceForPrefix("t") == "standard") {
637		DejaGnu.pass("ns.getNamespaceForPrefix('t') is returning the correct value");
638	} else {
639		DejaGnu.fail("ns.getNamespaceForPrefix('t') is returning the wrong value");
640	}
641	if (ns.getPrefixForNamespace("standard") == "t") {
642		DejaGnu.pass("ns.getPrefixForNamespace('standard') is returning the correct value");
643	} else {
644		DejaGnu.fail("ns.getPrefixForNamespace('standard') is returning the wrong value");
645	}
646
647	//redefine x with new xml tags
648	x = new XMLDocument('<tag xmlns:t="nst"><tag2 xmlns="nss"><tag3 xmlns:r="nsr"></tag3></tag2></tag>');
649	var n:XMLNode = new XMLNode(untyped 1, "tag");
650	n = x.firstChild;
651
652	if (n.nodeName == "tag") {
653		DejaGnu.pass("n.nodeName is returning the correct value");
654	} else {
655		DejaGnu.fail("n.nodeName is returning the wrong value");
656	}
657	if (n.namespaceURI == null) {
658		DejaGnu.pass("ns.namespaceURI is returning the correct value");
659	} else {
660		DejaGnu.fail("ns.namespaceURI is returning the wrong value");
661	}
662	if (n.getNamespaceForPrefix("r") == null) {
663		DejaGnu.pass("n.getNamespaceForPrefix('r') is returning the correct value");
664	} else {
665		DejaGnu.fail("n.getNamespaceForPrefix('r') is returning the wrong value");
666	}
667	if (n.getNamespaceForPrefix("nsr") == null) {
668		DejaGnu.pass("n.getNamespaceForPrefix('nsr') is returning the correct value");
669	} else {
670		DejaGnu.fail("n.getNamespaceForPrefix('nsr') is returning the wrong value");
671	}
672	if (n.getNamespaceForPrefix("t") == "nst") {
673		DejaGnu.pass("n.getNamespaceForPrefix('t') is returning the correct value");
674	} else {
675		DejaGnu.fail("n.getNamespaceForPrefix('t') is returning the wrong value");
676	}
677	if (n.getPrefixForNamespace("nst") == "t") {
678		DejaGnu.pass("n.getPrefixForNamespace('nst') is returning the correct value");
679	} else {
680		DejaGnu.fail("n.getPrefixForNamespace('nst') is returning the wrong value");
681	}
682
683	//make n its own firstChild
684	n = n.firstChild;
685	if (n.nodeName == "tag2") {
686		DejaGnu.pass("n.nodeName is returning the correct value");
687	} else {
688		DejaGnu.fail("n.nodeName is returning the wrong value");
689	}
690	if (n.namespaceURI == "nss") {
691		DejaGnu.pass("n.namespaceURI is returning the correct value");
692	} else {
693		DejaGnu.fail("n.namespaceURI is returning the wrong value");
694	}
695	if (n.getNamespaceForPrefix("r") == null) {
696		DejaGnu.pass("n.getNamespaceForPrefix('r') is returning the correct value");
697	} else {
698		DejaGnu.fail("n.getNamespaceForPrefix('r') is returning the wrong value");
699	}
700	if (n.getPrefixForNamespace("nsr") == null) {
701		DejaGnu.pass("n.getPrefixForNamespace('nsr') is returning the correct value");
702	} else {
703		DejaGnu.fail("n.getPrefixForNamespace('nsr') is returning the wrong value");
704	}
705	if (n.getNamespaceForPrefix("t") == "nst") {
706		DejaGnu.pass("n.getNamespaceForPrefix('t') is returning the correct value");
707	} else {
708		DejaGnu.fail("n.getNamespaceForPrefix('t') is returning the wrong value");
709	}
710	if (n.getPrefixForNamespace("nst") == "t") {
711		DejaGnu.pass("n.getPrefixForNamespace('nst') is returning the correct value");
712	} else {
713		DejaGnu.fail("n.getPrefixForNamespace('nst') is returning the wrong value");
714	}
715
716	//make n its own firstChild
717	n = n.firstChild;
718	if (n.nodeName == "tag3") {
719		DejaGnu.pass("n.nodeName is returning the correct value");
720	} else {
721		DejaGnu.fail("n.nodeName is returning the wrong value");
722	}
723	if (n.namespaceURI == "nss") {
724		DejaGnu.pass("n.namespaceURI is returning the correct value");
725	} else {
726		DejaGnu.fail("n.namespaceURI is returning the wrong value");
727	}
728	if (n.getNamespaceForPrefix("r") == "nsr") {
729		DejaGnu.pass("n.getPrefixForNamespace('nsr') is returning the correct value");
730	} else {
731		DejaGnu.fail("n.getPrefixForNamespace('nsr') is returning the wrong value");
732	}
733	if (n.getPrefixForNamespace("nsr") == "r") {
734		DejaGnu.pass("n.getPrefixForNamespace('nsr') is returning the correct value");
735	} else {
736		DejaGnu.fail("n.getPrefixForNamespace('nsr') is returning the wrong value");
737	}
738	if (n.getNamespaceForPrefix("t") == "nst") {
739		DejaGnu.pass("n.getNamespaceForPrefix('t') is returning the correct value");
740	} else {
741		DejaGnu.fail("n.getNamespaceForPrefix('t') is returning the wrong value");
742	}
743	if (n.getPrefixForNamespace("nst") == "t") {
744		DejaGnu.pass("n.getPrefixForNamespace('nst') is returning the correct value");
745	} else {
746		DejaGnu.fail("n.getPrefixForNamespace('nst') is returning the wrong value");
747	}
748
749	// Poorly formed prefix namespaces become standard namespaces
750	x = new XMLDocument('<tag xmlns:="nst"><tag2 xmlns="nss"><tag3 xmlns:="nsr"></tag3></tag2></tag>');
751	n = x.firstChild.firstChild.firstChild;
752	if (n.nodeName == "tag3") {
753		DejaGnu.pass("n.nodeName is returning the correct value");
754	} else {
755		DejaGnu.fail("n.nodeName is returning the wrong value");
756	}
757	if (n.namespaceURI == "nsr") {
758		DejaGnu.pass("n.namespaceURI is returning the correct value");
759	} else {
760		DejaGnu.fail("n.namespaceURI is returning the wrong value");
761	}
762	if (n.getPrefixForNamespace("nsr") == "") {
763		DejaGnu.pass("n.getPrefixForNamespace('nsr') is returning the correct value");
764	} else {
765		DejaGnu.fail("n.getPrefixForNamespace('nsr') is returning the wrong value");
766	}
767	if (n.getPrefixForNamespace("nst") == "") {
768		DejaGnu.pass("n.getPrefixForNamespace('nst') is returning the correct value");
769	} else {
770		DejaGnu.fail("n.getPrefixForNamespace('nst') is returning the wrong value");
771	}
772
773	//try multiple declarations of standard namespace. this has changed between
774	//as2 and as3. in as2 it would only accept "standard" as the namespace (the first
775	//tag). in as3 it accepts the last declaration of namespace (standard2 below)
776	x = new XMLDocument('<tag xmlns="standard" xmlns="standard2"></tag>');
777	ns = x.firstChild;
778	if (ns.nodeName == "tag") {
779		DejaGnu.pass("ns.nodeName is returning the correct value");
780	} else {
781		DejaGnu.fail("ns.nodeName is returning the wrong value");
782	}
783	if (ns.attributes[untyped "xmlns"] == "standard2") {
784		DejaGnu.pass("ns.attributes['xmlns'] is returning the correct value");
785	} else {
786		DejaGnu.fail("ns.attributes['xmlns'] is returning the wrong value");
787	}
788	if (ns.namespaceURI == "standard2") {
789		DejaGnu.pass("ns.namespaceURI is returning the correct value");
790	} else {
791		DejaGnu.fail("ns.namespaceURI is returning the wrong value");
792	}
793
794	//set values via attributes now
795	x = new XMLDocument('<tag></tag>');
796	ns = x.firstChild;
797	if (ns.nodeName == "tag") {
798		DejaGnu.pass("ns.nodeName is returning the correct value");
799	} else {
800		DejaGnu.fail("ns.nodeName is returning the wrong value");
801	}
802	if (ns.attributes[untyped "xmlns"] == null) {
803		DejaGnu.pass("ns.attributes['xmlns'] is returning the correct value");
804	} else {
805		DejaGnu.fail("ns.attributes['xmlns'] is returning the wrong value");
806	}
807	if (ns.namespaceURI == null) {
808		DejaGnu.pass("ns.namespaceURI is returning the correct value");
809	} else {
810		DejaGnu.fail("ns.namespaceURI is returning the wrong value");
811	}
812	ns.attributes[untyped "xmlns"] = "nss";
813	if (ns.attributes[untyped "xmlns"] == "nss") {
814		DejaGnu.pass("ns.attributes['xmlns'] is returning the correct value");
815	} else {
816		DejaGnu.fail("ns.attributes['xmlns'] is returning the wrong value");
817	}
818	//note this has changed from AS2-AS3. In AS2 the namespaceURI would remain
819	//undefined, but in AS3 the namespaceURI gets the same value as defined in
820	//the xmlns (XML Namespace) tag
821	if (ns.namespaceURI == "nss") {
822		DejaGnu.pass("ns.namespaceURI is returning the correct value");
823	} else {
824		DejaGnu.fail("ns.namespaceURI is returning the wrong value");
825	}
826
827	//instantiate x with a prefix and local name
828	x = new XMLDocument('<fr:tag/>');
829	ns = x.firstChild;
830	if (ns.nodeName == "fr:tag") {
831		DejaGnu.pass("ns.nodeName is returning the correct value");
832	} else {
833		DejaGnu.fail("ns.nodeName is returning the wrong value");
834	}
835	if (ns.localName == "tag") {
836		DejaGnu.pass("ns.localName is returning the correct value");
837	} else {
838		DejaGnu.fail("ns.localName is returning the wrong value");
839	}
840	if (ns.prefix == "fr") {
841		DejaGnu.pass("ns.prefix is returning the correct value");
842	} else {
843		DejaGnu.fail("ns.prefix is returning the wrong value");
844	}
845
846	//instantiate x with two prefixes and local name
847	x = new XMLDocument('<fr:pr:tag/>');
848	ns = x.firstChild;
849	if (ns.nodeName == "fr:pr:tag") {
850		DejaGnu.pass("ns.nodeName is returning the correct value");
851	} else {
852		DejaGnu.fail("ns.nodeName is returning the wrong value");
853	}
854	if (ns.localName == "pr:tag") {
855		DejaGnu.pass("ns.localName is returning the correct value");
856	} else {
857		DejaGnu.fail("ns.localName is returning the wrong value");
858	}
859	if (ns.prefix == "fr") {
860		DejaGnu.pass("ns.prefix is returning the correct value");
861	} else {
862		DejaGnu.fail("ns.prefix is returning the wrong value");
863	}
864
865	//instantiate x with a two prefixs (first empty) and local name
866	x = new XMLDocument('<:fr:tag/>');
867	ns = x.firstChild;
868	if (ns.nodeName == ":fr:tag") {
869		DejaGnu.pass("ns.nodeName is returning the correct value");
870	} else {
871		DejaGnu.fail("ns.nodeName is returning the wrong value");
872	}
873	if (ns.localName == "fr:tag") {
874		DejaGnu.pass("ns.localName is returning the correct value");
875	} else {
876		DejaGnu.fail("ns.localName is returning the wrong value");
877	}
878	if (ns.prefix == "") {
879		DejaGnu.pass("ns.prefix is returning the correct value");
880	} else {
881		DejaGnu.fail("ns.prefix is returning the wrong value");
882	}
883
884	//instantiate x with one empty prefix and local name
885	x = new XMLDocument('<:tag/>');
886	ns = x.firstChild;
887	if (ns.nodeName == ":tag") {
888		DejaGnu.pass("ns.nodeName is returning the correct value");
889	} else {
890		DejaGnu.fail("ns.nodeName is returning the wrong value");
891	}
892	if (ns.localName == "tag") {
893		DejaGnu.pass("ns.localName is returning the correct value");
894	} else {
895		DejaGnu.fail("ns.localName is returning the wrong value");
896	}
897	if (ns.prefix == "") {
898		DejaGnu.pass("ns.prefix is returning the correct value");
899	} else {
900		DejaGnu.fail("ns.prefix is returning the wrong value");
901	}
902
903	//instantiate x with prefix and no local name
904	x = new XMLDocument('<tag:/>');
905	ns = x.firstChild;
906	if (ns.nodeName == "tag:") {
907		DejaGnu.pass("ns.nodeName is returning the correct value");
908	} else {
909		DejaGnu.fail("ns.nodeName is returning the wrong value");
910	}
911	if (ns.localName == "") {
912		DejaGnu.pass("ns.localName is returning the correct value");
913	} else {
914		DejaGnu.fail("ns.localName is returning the wrong value");
915	}
916	if (ns.prefix == "tag") {
917		DejaGnu.pass("ns.prefix is returning the correct value");
918	} else {
919		DejaGnu.fail("ns.prefix is returning the wrong value");
920	}
921
922	//instantiate x with local name and no prefix
923	x = new XMLDocument('<tag/>');
924	ns = x.firstChild;
925	if (ns.nodeName == "tag") {
926		DejaGnu.pass("ns.nodeName is returning the correct value");
927	} else {
928		DejaGnu.fail("ns.nodeName is returning the wrong value");
929	}
930	if (ns.localName == "tag") {
931		DejaGnu.pass("ns.localName is returning the correct value");
932	} else {
933		DejaGnu.fail("ns.localName is returning the wrong value");
934	}
935	if (ns.prefix == "") {
936		DejaGnu.pass("ns.prefix is returning the correct value");
937	} else {
938		DejaGnu.fail("ns.prefix is returning the wrong value");
939	}
940	#end
941
942	#if !flash9
943	//NOTE: haxe doesn't support new XML() initializer
944	DejaGnu.note("going to implement the 8 and lower tests when I figure out how haxe deals with this");
945	#end
946     // Call this after finishing all tests. It prints out the totals.
947	 DejaGnu.done();
948    }
949}
950
951// local Variables:
952// mode: C++
953// indent-tabs-mode: t
954// End:
955
956