js/src/tests/ecma/Statements/12.6.3-12.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma/Statements/12.6.3-12.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,69 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +
    1.10 +/**
    1.11 +   File Name:          12.6.3-12.js
    1.12 +   ECMA Section:       12.6.3 The for...in Statement
    1.13 +   Description:
    1.14 +
    1.15 +   This is a regression test for http://bugzilla.mozilla.org/show_bug.cgi?id=9802.
    1.16 +
    1.17 +   The production IterationStatement : for ( LeftHandSideExpression in Expression )
    1.18 +   Statement is evaluated as follows:
    1.19 +
    1.20 +   1.  Evaluate the Expression.
    1.21 +   2.  Call GetValue(Result(1)).
    1.22 +   3.  Call ToObject(Result(2)).
    1.23 +   4.  Let C be "normal completion".
    1.24 +   5.  Get the name of the next property of Result(3) that doesn't have the
    1.25 +   DontEnum attribute. If there is no such property, go to step 14.
    1.26 +   6.  Evaluate the LeftHandSideExpression (it may be evaluated repeatedly).
    1.27 +   7.  Call PutValue(Result(6), Result(5)).  PutValue( V, W ):
    1.28 +   1.  If Type(V) is not Reference, generate a runtime error.
    1.29 +   2.  Call GetBase(V).
    1.30 +   3.  If Result(2) is null, go to step 6.
    1.31 +   4.  Call the [[Put]] method of Result(2), passing GetPropertyName(V)
    1.32 +   for the property name and W for the value.
    1.33 +   5.  Return.
    1.34 +   6.  Call the [[Put]] method for the global object, passing
    1.35 +   GetPropertyName(V) for the property name and W for the value.
    1.36 +   7.  Return.
    1.37 +   8.  Evaluate Statement.
    1.38 +   9.  If Result(8) is a value completion, change C to be "normal completion
    1.39 +   after value V" where V is the value carried by Result(8).
    1.40 +   10. If Result(8) is a break completion, go to step 14.
    1.41 +   11. If Result(8) is a continue completion, go to step 5.
    1.42 +   12. If Result(8) is a return completion, return Result(8).
    1.43 +   13. Go to step 5.
    1.44 +   14. Return C.
    1.45 +
    1.46 +   Author:             christine@netscape.com
    1.47 +   Date:               11 september 1997
    1.48 +*/
    1.49 +var SECTION = "12.6.3-12";
    1.50 +var VERSION = "ECMA_1";
    1.51 +startTest();
    1.52 +var TITLE   = "The for..in statement";
    1.53 +
    1.54 +writeHeaderToLog( SECTION + " "+ TITLE);
    1.55 +
    1.56 +var result = "PASSED";
    1.57 +
    1.58 +for ( aVar in this ) {
    1.59 +  if (aVar == "aVar") {
    1.60 +    result = "FAILED"
    1.61 +      }
    1.62 +};
    1.63 +
    1.64 +new TestCase(
    1.65 +  SECTION,
    1.66 +  "var result=''; for ( aVar in this ) { " +
    1.67 +  "if (aVar == 'aVar') {return a failure}; result",
    1.68 +  "PASSED",
    1.69 +  result );
    1.70 +
    1.71 +test();
    1.72 +

mercurial