1/** 2 * File Name: exception-003 3 * ECMA Section: 4 * Description: Tests for JavaScript Standard Exceptions 5 * 6 * Target error. 7 * 8 * Author: christine@netscape.com 9 * Date: 31 August 1998 10 */ 11 var SECTION = "exception-003"; 12 var VERSION = "js1_4"; 13 var TITLE = "Tests for JavaScript Standard Exceptions: TargetError"; 14 15 startTest(); 16 writeHeaderToLog( SECTION + " "+ TITLE); 17 18 var tc = 0; 19 var testcases = new Array(); 20 21 Target_1(); 22 23 test(); 24 25 function Target_1() { 26 result = "failed: no exception thrown"; 27 exception = null; 28 29 try { 30 string = new String("hi"); 31 string.toString = Boolean.prototype.toString; 32 string.toString(); 33 } catch ( e ) { 34 result = "passed: threw exception", 35 exception = e.toString(); 36 } finally { 37 testcases[tc++] = new TestCase( 38 SECTION, 39 "string = new String(\"hi\");"+ 40 "string.toString = Boolean.prototype.toString" + 41 "string.toString() [ exception is " + exception +" ]", 42 "passed: threw exception", 43 result ); 44 } 45 } 46 47