1/** 2 * File Name: forin-002.js 3 * ECMA Section: 4 * Description: The forin-001 statement 5 * 6 * Verify that the property name is assigned to the property on the left 7 * hand side of the for...in expression. 8 * 9 * Author: christine@netscape.com 10 * Date: 28 August 1998 11 */ 12 var SECTION = "forin-002"; 13 var VERSION = "ECMA_2"; 14 var TITLE = "The for...in statement"; 15 16 startTest(); 17 writeHeaderToLog( SECTION + " "+ TITLE); 18 19 var tc = 0; 20 var testcases = new Array(); 21 22 function MyObject( value ) { 23 this.value = value; 24 this.valueOf = new Function ( "return this.value" ); 25 this.toString = new Function ( "return this.value + \"\"" ); 26 this.toNumber = new Function ( "return this.value + 0" ); 27 this.toBoolean = new Function ( "return Boolean( this.value )" ); 28 } 29 30 ForIn_1(this); 31 ForIn_2(this); 32 33 ForIn_1(new MyObject(true)); 34 ForIn_2(new MyObject(new Boolean(true))); 35 36 ForIn_2(3); 37 38 test(); 39 40 /** 41 * For ... In in a With Block 42 * 43 */ 44 function ForIn_1( object) { 45 with ( object ) { 46 for ( property in object ) { 47 testcases[tc++] = new TestCase( 48 SECTION, 49 "with loop in a for...in loop. ("+object+")["+property +"] == "+ 50 "eval ( " + property +" )", 51 true, 52 object[property] == eval(property) ); 53 } 54 } 55 } 56 57 /** 58 * With block in a For...In loop 59 * 60 */ 61 function ForIn_2(object) { 62 for ( property in object ) { 63 with ( object ) { 64 testcases[tc++] = new TestCase( 65 SECTION, 66 "with loop in a for...in loop. ("+object+")["+property +"] == "+ 67 "eval ( " + property +" )", 68 true, 69 object[property] == eval(property) ); 70 } 71 } 72 } 73 74