2 * File Name: forin-002.js
4 * Description: The forin-001 statement
6 * Verify that the property name is assigned to the property on the left
7 * hand side of the for...in expression.
9 * Author: christine@netscape.com
10 * Date: 28 August 1998
12 var SECTION = "forin-002";
13 var VERSION = "ECMA_2";
14 var TITLE = "The for...in statement";
17 writeHeaderToLog( SECTION + " "+ TITLE);
20 var testcases = new Array();
22 function MyObject( 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 )" );
33 ForIn_1(new MyObject(true));
34 ForIn_2(new MyObject(new Boolean(true)));
41 * For ... In in a With Block
44 function ForIn_1( object) {
46 for ( property in object ) {
47 testcases[tc++] = new TestCase(
49 "with loop in a for...in loop. ("+object+")["+property +"] == "+
50 "eval ( " + property +" )",
52 object[property] == eval(property) );
58 * With block in a For...In loop
61 function ForIn_2(object) {
62 for ( property in object ) {
64 testcases[tc++] = new TestCase(
66 "with loop in a for...in loop. ("+object+")["+property +"] == "+
67 "eval ( " + property +" )",
69 object[property] == eval(property) );