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