js/src/tests/ecma_2/Exceptions/statement-002.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma_2/Exceptions/statement-002.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:          statement-002.js
    1.12 +   Corresponds To:     12.6.3-1.js
    1.13 +   ECMA Section:       12.6.3 The for...in Statement
    1.14 +   Description:
    1.15 +   The production IterationStatement : for ( LeftHandSideExpression in Expression )
    1.16 +   Statement is evaluated as follows:
    1.17 +
    1.18 +   1.  Evaluate the Expression.
    1.19 +   2.  Call GetValue(Result(1)).
    1.20 +   3.  Call ToObject(Result(2)).
    1.21 +   4.  Let C be "normal completion".
    1.22 +   5.  Get the name of the next property of Result(3) that doesn't have the
    1.23 +   DontEnum attribute. If there is no such property, go to step 14.
    1.24 +   6.  Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly).
    1.25 +   7.  Call PutValue(Result(6), Result(5)).  PutValue( V, W ):
    1.26 +   1.  If Type(V) is not Reference, generate a runtime error.
    1.27 +   2.  Call GetBase(V).
    1.28 +   3.  If Result(2) is null, go to step 6.
    1.29 +   4.  Call the [[Put]] method of Result(2), passing GetPropertyName(V)
    1.30 +   for the property name and W for the value.
    1.31 +   5.  Return.
    1.32 +   6.  Call the [[Put]] method for the global object, passing
    1.33 +   GetPropertyName(V) for the property name and W for the value.
    1.34 +   7.  Return.
    1.35 +   8.  Evaluate Statement.
    1.36 +   9.  If Result(8) is a value completion, change C to be "normal completion
    1.37 +   after value V" where V is the value carried by Result(8).
    1.38 +   10. If Result(8) is a break completion, go to step 14.
    1.39 +   11. If Result(8) is a continue completion, go to step 5.
    1.40 +   12. If Result(8) is a return completion, return Result(8).
    1.41 +   13. Go to step 5.
    1.42 +   14. Return C.
    1.43 +
    1.44 +   Author:             christine@netscape.com
    1.45 +   Date:               11 september 1997
    1.46 +*/
    1.47 +var SECTION = "statement-002";
    1.48 +var VERSION = "JS1_4";
    1.49 +var TITLE   = "The for..in statement";
    1.50 +
    1.51 +startTest();
    1.52 +writeHeaderToLog( SECTION + " "+ TITLE);
    1.53 +
    1.54 +var result = "Failed";
    1.55 +var exception = "No exception thrown";
    1.56 +var expect = "Passed";
    1.57 +
    1.58 +try {
    1.59 +  eval(" for ( var i, p in this) { result += this[p]; }");
    1.60 +} catch ( e ) {
    1.61 +  result = expect;
    1.62 +  exception = e.toString();
    1.63 +}
    1.64 +
    1.65 +new TestCase(
    1.66 +  SECTION,
    1.67 +  "more than one member expression" +
    1.68 +  " (threw " + exception +")",
    1.69 +  expect,
    1.70 +  result );
    1.71 +
    1.72 +test();

mercurial