W3C home > Mailing lists > Public > www-dom-ts@w3.org > December 2003

Writing tests with multiple exception codes

From: Curt Arnold <carnold@houston.rr.com>
Date: Mon, 29 Dec 2003 20:02:18 -0600
Message-ID: <3FF0DCAA.3020600@houston.rr.com>
To: www-dom-ts@w3.org

One of my tasks from the last WG conference call was to describe how to 
write tests when an operation may throw more than one error code.  
Examples of such tests are nodeinsertbefore05, 06, and 10.  The basic 
formulation is like: 

    <insertBefore obj="doc" var="inserted" newChild="newDocType" 
     <fail id="throw_DOMException"/>
        <DOMException code="HIERARCHY_REQUEST_ERR"/>
        <DOMException code="NOT_SUPPORTED_ERR"/>

If the operation does not throw an exception, it hits the <fail/> method 
which unconditionally fails the test.  If a DOMException is thrown with 
either of the specified codes, then the try block is left.  If 
DOMException with a different code is thrown, the exception appears not 
to be caught (it is actually caught and rethrown) which will cause the 
test to fail.  The test-to-java transform produces the following code 
for that fragment:

      try {
      inserted = doc.insertBefore(newDocType, docType);
      catch (DOMException ex) {
                  switch (ex.code) {
      case 3 :
      case 9 :
          throw ex;
Received on Monday, 29 December 2003 21:02:17 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:34:06 UTC