Home | History | Annotate | Download | only in Exceptions
      1 /**
      2     File Name:          statement-003
      3     Corresponds To:     12.6.3-7-n.js
      4     ECMA Section:       12.6.3 The for...in Statement
      5     Description:
      6     The production IterationStatement : for ( LeftHandSideExpression in Expression )
      7     Statement is evaluated as follows:
      8 
      9     1.  Evaluate the Expression.
     10     2.  Call GetValue(Result(1)).
     11     3.  Call ToObject(Result(2)).
     12     4.  Let C be "normal completion".
     13     5.  Get the name of the next property of Result(3) that doesn't have the
     14         DontEnum attribute. If there is no such property, go to step 14.
     15     6.  Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly).
     16     7.  Call PutValue(Result(6), Result(5)).  PutValue( V, W ):
     17         1.  If Type(V) is not Reference, generate a runtime error.
     18         2.  Call GetBase(V).
     19         3.  If Result(2) is null, go to step 6.
     20         4.  Call the [[Put]] method of Result(2), passing GetPropertyName(V)
     21             for the property name and W for the value.
     22         5.  Return.
     23         6.  Call the [[Put]] method for the global object, passing
     24             GetPropertyName(V) for the property name and W for the value.
     25         7.  Return.
     26     8.  Evaluate Statement.
     27     9.  If Result(8) is a value completion, change C to be "normal completion
     28         after value V" where V is the value carried by Result(8).
     29     10. If Result(8) is a break completion, go to step 14.
     30     11. If Result(8) is a continue completion, go to step 5.
     31     12. If Result(8) is a return completion, return Result(8).
     32     13. Go to step 5.
     33     14. Return C.
     34 
     35     Author:             christine (at) netscape.com
     36     Date:               11 september 1997
     37 */
     38     var SECTION = "statement-003";
     39     var VERSION = "JS1_4";
     40     var TITLE   = "The for..in statment";
     41 
     42     startTest();
     43     writeHeaderToLog( SECTION + " "+ TITLE);
     44 
     45     var testcases = new Array();
     46     var tc = 0;
     47 
     48     var result = "Failed";
     49     var exception = "No exception thrown";
     50     var expect = "Passed";
     51 
     52     try {
     53         var o = new MyObject();
     54         var result = 0;
     55 
     56         eval("for ( this in o) {\n"
     57              + "result += this[p];\n"
     58              + "}\n");
     59     } catch ( e ) {
     60         result = expect;
     61         exception = e.toString();
     62     }
     63 
     64     testcases[tc++] = new TestCase(
     65         SECTION,
     66         "bad left-hand side expression" +
     67         " (threw " + exception +")",
     68         expect,
     69         result );
     70 
     71     test();
     72 
     73 function MyObject() {
     74     this.value = 2;
     75     this[0] = 4;
     76     return this;
     77 }
     78