keith_miller@apple.com | bcc77f2 | 2016-07-15 06:03:25 +0000 | [diff] [blame] | 1 | // Copyright 2009 the Sputnik authors. All rights reserved. |
| 2 | // This code is governed by the BSD license found in the LICENSE file. |
| 3 | |
| 4 | /*--- |
| 5 | info: > |
| 6 | The production IterationStatement: "for (var VariableDeclarationListNoIn; |
| 7 | Expression; Expression) Statement" |
| 8 | es5id: 12.6.3_A14 |
| 9 | description: Using +,*,/, as the second Expression |
| 10 | ---*/ |
| 11 | |
| 12 | //CHECK#1 |
| 13 | for(var i=0;i<10;i++){} |
| 14 | if (i!==10) $ERROR('#1: i === 10. Actual: i ==='+ i ); |
| 15 | |
| 16 | //CHECK#2 |
| 17 | var j=0; |
| 18 | for(var i=1;i<10;i*=2){ |
| 19 | j++; |
| 20 | } |
| 21 | if (i!==16) $ERROR('#2.1: i === 16. Actual: i ==='+ i ); |
| 22 | if (j!==4) $ERROR('#2.2: j === 4. Actual: j ==='+ j ); |
| 23 | |
| 24 | //CHECK#3 |
| 25 | var j=0; |
| 26 | for(var i=16;i>1;i=i/2){ |
| 27 | j++; |
| 28 | } |
| 29 | if (i!==1) $ERROR('#3.1: i === 1. Actual: i ==='+ i ); |
| 30 | if (j!==4) $ERROR('#3.2: j === 4. Actual: j ==='+ j ); |
| 31 | |
| 32 | //CHECK#4 |
| 33 | var j=0; |
| 34 | for(var i=10;i>1;i--){ |
| 35 | j++; |
| 36 | } |
| 37 | if (i!==1) $ERROR('#4.1: i === 1. Actual: i ==='+ i ); |
| 38 | if (j!==9) $ERROR('#4.2: j === 9. Actual: j ==='+ j ); |
| 39 | |
| 40 | //CHECK#5 |
| 41 | var j=0; |
| 42 | for(var i=2;i<10;i*=i){ |
| 43 | j++; |
| 44 | } |
| 45 | if (i!==16) $ERROR('#5.1: i === 16. Actual: i ==='+ i ); |
| 46 | if (j!==2) $ERROR('#5.2: j === 2. Actual: j ==='+ j ); |