- From: Curt Arnold <carnold@houston.rr.com>
- Date: Fri, 26 Oct 2001 01:23:12 -0500
- To: <www-dom-ts@w3.org>
- Message-ID: <005101c15de6$b056e2f0$7600a8c0@CurtMicron>
Here is an excerpt from getElementsByTagNameNS02.xml <var name="lname" type="DOMString"/> <var name="result" type="List"/> <var name="expectedResult" type="List"> <member>"emp"</member> <member>"employee"</member> </var> <load var="doc" href="staffNS.xml" willBeModified="false"/> <getElementsByTagNameNS interface="Document" obj="doc" var="newList" namespaceURI="namespaceURI" localName="localName"/> <item interface="NodeList" obj="newList" var="newElement" index="3"/> <prefix obj="newElement" var="prefix"/> <append collection="result" obj="prefix"/> <localName obj="newElement" var="lname"/> <append collection="result" obj="lname"/> <assertEquals actual="result" expected="expectedResult" id="throw_Equals" ignoreCase="false"/> </test> The fragment uses a list comparison to test the return value from Node.prefix and Node.localName. A better way to write this is to have two distinct asserts. Such as: <var name="lname" type="DOMString"/> <load var="doc" href="staffNS.xml" willBeModified="false"/> <getElementsByTagNameNS interface="Document" obj="doc" var="newList" namespaceURI="namespaceURI" localName="localName"/> <item interface="NodeList" obj="newList" var="newElement" index="3"/> <prefix obj="newElement" var="prefix"/> <assertEquals expected='"emp"' actual="prefix" ignoreCase="false" id="prefix"/> <localName obj="newElement" var="lname"/> <assertEquals expected='"employee"' actual="lname" ignoreCase="false" id="lname"/> </test> In addition to being shorter, the diagnostic messages are more meaningful. Other cases that appear to use list comparisons inappropriately are:importNode01, importNode06, importNode07, importNode09, importNode11-14, removeAttributeNS02, setAttributeNS04, setAttributeNS09
Received on Friday, 26 October 2001 02:25:11 UTC