]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma/Statements/12.6.3-19.js
1 /* The contents of this file are subject to the Netscape Public
2 * License Version 1.1 (the "License"); you may not use this file
3 * except in compliance with the License. You may obtain a copy of
4 * the License at http://www.mozilla.org/NPL/
6 * Software distributed under the License is distributed on an "AS
7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 * implied. See the License for the specific language governing
9 * rights and limitations under the License.
11 * The Original Code is Mozilla Communicator client code, released March
14 * The Initial Developer of the Original Code is Netscape Communications
15 * Corporation. Portions created by Netscape are
16 * Copyright (C) 1998 Netscape Communications Corporation. All
23 File Name: 12.6.3-1.js
24 ECMA Section: 12.6.3 The for...in Statement
26 The production IterationStatement : for ( LeftHandSideExpression in Expression )
27 Statement is evaluated as follows:
29 1. Evaluate the Expression.
30 2. Call GetValue(Result(1)).
31 3. Call ToObject(Result(2)).
32 4. Let C be "normal completion".
33 5. Get the name of the next property of Result(3) that doesn't have the
34 DontEnum attribute. If there is no such property, go to step 14.
35 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly).
36 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ):
37 1. If Type(V) is not Reference, generate a runtime error.
39 3. If Result(2) is null, go to step 6.
40 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V)
41 for the property name and W for the value.
43 6. Call the [[Put]] method for the global object, passing
44 GetPropertyName(V) for the property name and W for the value.
46 8. Evaluate Statement.
47 9. If Result(8) is a value completion, change C to be "normal completion
48 after value V" where V is the value carried by Result(8).
49 10. If Result(8) is a break completion, go to step 14.
50 11. If Result(8) is a continue completion, go to step 5.
51 12. If Result(8) is a return completion, return Result(8).
55 Author: christine@netscape.com
56 Date: 11 september 1997
58 var SECTION
= "12.6.3-4";
59 var VERSION
= "ECMA_1";
61 var TITLE
= "The for..in statment";
63 writeHeaderToLog( SECTION
+ " "+ TITLE
);
65 var testcases
= new Array();
67 // for ( LeftHandSideExpression in Expression )
68 // LeftHandSideExpression:NewExpression:MemberExpression
71 function f() { count
++; return new Array("h","e","l","l","o"); }
74 for ( p
in f() ) { result
+= f()[p
] };
76 testcases
[testcases
.length
] = new TestCase( SECTION
,
77 "count = 0; result = \"\"; "+
78 "function f() { count++; return new Array(\"h\",\"e\",\"l\",\"l\",\"o\"); }"+
79 "for ( p in f() ) { result += f()[p] }; count",
83 testcases
[testcases
.length
] = new TestCase( SECTION
,
90 // LeftHandSideExpression:NewExpression:MemberExpression [ Expression ]
91 // LeftHandSideExpression:NewExpression:MemberExpression . Identifier
92 // LeftHandSideExpression:NewExpression:new MemberExpression Arguments
93 // LeftHandSideExpression:NewExpression:PrimaryExpression:( Expression )
94 // LeftHandSideExpression:CallExpression:MemberExpression Arguments
95 // LeftHandSideExpression:CallExpression Arguments
96 // LeftHandSideExpression:CallExpression [ Expression ]
97 // LeftHandSideExpression:CallExpression . Identifier
102 for ( tc
=0; tc
< testcases
.length
; tc
++ ) {
103 testcases
[tc
].passed
= writeTestCaseResult(
104 testcases
[tc
].expect
,
105 testcases
[tc
].actual
,
106 testcases
[tc
].description
+" = "+
107 testcases
[tc
].actual
);
109 testcases
[tc
].reason
+= ( testcases
[tc
].passed
) ? "" : "wrong value ";
112 return ( testcases
);