Home | History | Annotate | Download | only in Exceptions
      1 /**
      2  *  File Name:          exception-007
      3  *  ECMA Section:
      4  *  Description:        Tests for JavaScript Standard Exceptions
      5  *
      6  *  DefaultValue error.
      7  *
      8  *  Author:             christine (at) netscape.com
      9  *  Date:               31 August 1998
     10  */
     11     var SECTION = "exception-007";
     12     var VERSION = "js1_4";
     13     var TITLE   = "Tests for JavaScript Standard Exceptions:  TypeError";
     14     var BUGNUMBER="318250";
     15 
     16     startTest();
     17     writeHeaderToLog( SECTION + " "+ TITLE);
     18 
     19     var tc = 0;
     20     var testcases = new Array();
     21 
     22     DefaultValue_1();
     23 
     24     test();
     25 
     26 
     27     /**
     28      * Getting the [[DefaultValue]] of any instances of MyObject
     29      * should result in a runtime error in ToPrimitive.
     30      */
     31 
     32     function MyObject() {
     33         this.toString = void 0;
     34         this.valueOf = new Object();
     35     }
     36 
     37     function DefaultValue_1() {
     38         result = "failed: no exception thrown";
     39         exception = null;
     40 
     41         try {
     42            result = new MyObject() + new MyObject();
     43         } catch ( e ) {
     44             result = "passed:  threw exception",
     45             exception = e.toString();
     46         } finally {
     47             testcases[tc++] = new TestCase(
     48                 SECTION,
     49                 "new MyObject() + new MyObject() [ exception is " + exception +" ]",
     50                 "passed:  threw exception",
     51                 result );
     52         }
     53     }
     54 
     55