Imported Upstream version 1.0.0
[platform/upstream/js.git] / js / src / tests / ecma / Statements / 12.6.3-11.js
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4  *
5  * The contents of this file are subject to the Mozilla Public License Version
6  * 1.1 (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  * http://www.mozilla.org/MPL/
9  *
10  * Software distributed under the License is distributed on an "AS IS" basis,
11  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12  * for the specific language governing rights and limitations under the
13  * License.
14  *
15  * The Original Code is Mozilla Communicator client code, released
16  * March 31, 1998.
17  *
18  * The Initial Developer of the Original Code is
19  * Netscape Communications Corporation.
20  * Portions created by the Initial Developer are Copyright (C) 1998
21  * the Initial Developer. All Rights Reserved.
22  *
23  * Contributor(s):
24  *
25  * Alternatively, the contents of this file may be used under the terms of
26  * either the GNU General Public License Version 2 or later (the "GPL"), or
27  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28  * in which case the provisions of the GPL or the LGPL are applicable instead
29  * of those above. If you wish to allow use of your version of this file only
30  * under the terms of either the GPL or the LGPL, and not to allow others to
31  * use your version of this file under the terms of the MPL, indicate your
32  * decision by deleting the provisions above and replace them with the notice
33  * and other provisions required by the GPL or the LGPL. If you do not delete
34  * the provisions above, a recipient may use your version of this file under
35  * the terms of any one of the MPL, the GPL or the LGPL.
36  *
37  * ***** END LICENSE BLOCK ***** */
38
39
40 /**
41    File Name:          12.6.3-11.js
42    ECMA Section:       12.6.3 The for...in Statement
43    Description:
44    The production IterationStatement : for ( LeftHandSideExpression in Expression )
45    Statement is evaluated as follows:
46
47    1.  Evaluate the Expression.
48    2.  Call GetValue(Result(1)).
49    3.  Call ToObject(Result(2)).
50    4.  Let C be "normal completion".
51    5.  Get the name of the next property of Result(3) that doesn't have the
52    DontEnum attribute. If there is no such property, go to step 14.
53    6.  Evaluate the LeftHandSideExpression (it may be evaluated repeatedly).
54    7.  Call PutValue(Result(6), Result(5)).  PutValue( V, W ):
55    1.  If Type(V) is not Reference, generate a runtime error.
56    2.  Call GetBase(V).
57    3.  If Result(2) is null, go to step 6.
58    4.  Call the [[Put]] method of Result(2), passing GetPropertyName(V)
59    for the property name and W for the value.
60    5.  Return.
61    6.  Call the [[Put]] method for the global object, passing
62    GetPropertyName(V) for the property name and W for the value.
63    7.  Return.
64    8.  Evaluate Statement.
65    9.  If Result(8) is a value completion, change C to be "normal completion
66    after value V" where V is the value carried by Result(8).
67    10. If Result(8) is a break completion, go to step 14.
68    11. If Result(8) is a continue completion, go to step 5.
69    12. If Result(8) is a return completion, return Result(8).
70    13. Go to step 5.
71    14. Return C.
72
73    Author:             christine@netscape.com
74    Date:               11 september 1997
75 */
76 var SECTION = "12.6.3-11";
77 var VERSION = "ECMA_1";
78 startTest();
79 var TITLE   = "The for..in statement";
80
81 writeHeaderToLog( SECTION + " "+ TITLE);
82
83
84 //    5.  Get the name of the next property of Result(3) that doesn't have the
85 //        DontEnum attribute. If there is no such property, go to step 14.
86
87 var result = "";
88
89 for ( p in Number ) { result += String(p) };
90
91 new TestCase( SECTION,
92               "result = \"\"; for ( p in Number ) { result += String(p) };",
93               "",
94               result );
95
96 test();
97