]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma_2/Statements/try-007.js
2 * File Name: try-007.js
4 * Description: The try statement
6 * This test has a for-in statement within a try block.
9 * Author: christine@netscape.com
10 * Date: 11 August 1998
12 var SECTION
= "try-007";
13 var VERSION
= "ECMA_2";
14 var TITLE
= "The try statement: for-in";
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 TryForIn( new TryObject( "hello", throwException
, true ));
43 TryForIn( new TryObject( "hola", noException
, false ));
52 * This is the object that will be the "this" in a with block.
53 * The check function is either throwExeption() or noException().
57 function TryObject( value
, fun
, exception
) {
59 this.exception
= exception
;
62 this.valueOf = function () { return this.value
; }
66 * This function has a for-in statement within a try block. Test cases
67 * are added after the try-catch-finally statement. Within the for-in
68 * block, call a function that can throw an exception. Verify that any
69 * exceptions are properly caught.
72 function TryForIn( object
) {
75 if ( typeof object
[p
] == "function" ) {
83 testcases
[tc
++] = new TestCase(
85 "TryForIn( " + object
+ " )",
86 (object
.exception
? EXCEPTION_STRING
+": " + object
.value : object
.value
),