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/ 5 * 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. 10 * 11 * The Original Code is Mozilla Communicator client code, released March 12 * 31, 1998. 13 * 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 17 * Rights Reserved. 18 * 19 * Contributor(s): 20 * 21 */ 22 /** 23 File Name: 12.6.3-12.js 24 ECMA Section: 12.6.3 The for...in Statement 25 Description: 26 27 This is a regression test for http://bugzilla.mozilla.org/show_bug.cgi?id=9802. 28 29 The production IterationStatement : for ( LeftHandSideExpression in Expression ) 30 Statement is evaluated as follows: 31 32 1. Evaluate the Expression. 33 2. Call GetValue(Result(1)). 34 3. Call ToObject(Result(2)). 35 4. Let C be "normal completion". 36 5. Get the name of the next property of Result(3) that doesn't have the 37 DontEnum attribute. If there is no such property, go to step 14. 38 6. Evaluate the LeftHandSideExpression (it may be evaluated repeatedly). 39 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): 40 1. If Type(V) is not Reference, generate a runtime error. 41 2. Call GetBase(V). 42 3. If Result(2) is null, go to step 6. 43 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) 44 for the property name and W for the value. 45 5. Return. 46 6. Call the [[Put]] method for the global object, passing 47 GetPropertyName(V) for the property name and W for the value. 48 7. Return. 49 8. Evaluate Statement. 50 9. If Result(8) is a value completion, change C to be "normal completion 51 after value V" where V is the value carried by Result(8). 52 10. If Result(8) is a break completion, go to step 14. 53 11. If Result(8) is a continue completion, go to step 5. 54 12. If Result(8) is a return completion, return Result(8). 55 13. Go to step 5. 56 14. Return C. 57 58 Author: christine (at) netscape.com 59 Date: 11 september 1997 60 */ 61 var SECTION = "12.6.3-12"; 62 var VERSION = "ECMA_1"; 63 startTest(); 64 var TITLE = "The for..in statment"; 65 66 writeHeaderToLog( SECTION + " "+ TITLE); 67 68 var testcases = new Array(); 69 70 var result = "PASSED"; 71 72 for ( aVar in this ) { 73 if (aVar == "aVar") { 74 result = "FAILED" 75 } 76 }; 77 78 testcases[testcases.length] = new TestCase( 79 SECTION, 80 "var result=''; for ( aVar in this ) { " + 81 "if (aVar == 'aVar') {return a failure}; result", 82 "PASSED", 83 result ); 84 85 test(); 86 87 function test() { 88 for ( tc=0; tc < testcases.length; tc++ ) { 89 testcases[tc].passed = writeTestCaseResult( 90 testcases[tc].expect, 91 testcases[tc].actual, 92 testcases[tc].description +" = "+ 93 testcases[tc].actual ); 94 95 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; 96 } 97 stopTest(); 98 return ( testcases ); 99 } 100 101