]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma_2/Statements/try-006.js
2 * File Name: try-006.js
4 * Description: The try statement
6 * Throw an exception from within a With block in a try block. Verify
7 * that any expected exceptions are caught.
9 * Author: christine@netscape.com
10 * Date: 11 August 1998
12 var SECTION
= "try-006";
13 var VERSION
= "ECMA_2";
14 var TITLE
= "The try statement";
17 writeHeaderToLog( SECTION
+ " "+ TITLE
);
20 var testcases
= new Array();
23 * This is the "check" function for test objects that will
26 function throwException() {
27 throw EXCEPTION_STRING
+": " + this.valueOf();
29 var EXCEPTION_STRING
= "Exception thrown:";
32 * This is the "check" function for test objects that do not
35 function noException() {
36 return this.valueOf();
42 TryWith( new TryObject( "hello", throwException
, true ));
43 TryWith( new TryObject( "hola", noException
, false ));
52 * This is the object that will be the "this" in a with block.
54 function TryObject( value
, fun
, exception
) {
56 this.exception
= exception
;
58 this.valueOf
= new Function ( "return this.value" );
63 * This function has the try block that has a with block within it.
64 * Test cases are added in this function. Within the with block, the
65 * object's "check" function is called. If the test object's exception
66 * property is true, we expect the result to be the exception value.
67 * If exception is false, then we expect the result to be the value of
70 function TryWith( object
) {
79 testcases
[tc
++] = new TestCase(
81 "TryWith( " + object
.value
+" )",
82 (object
.exception
? EXCEPTION_STRING
+": " + object
.valueOf() : object
.valueOf()),