var j = 0; 
for(i = 1; i < 10; i = i + 1) { 
    continue; j = j + 1; 
} 

assert(0, j);

var j = 0; 
for(i = 1; i < 10; i = i + 1) { 
    j = j + 1; 
    continue; 
} 

assert(9, j);


var j = 1; 
var i = 1; 
do { 
    i = i + 1; 
    continue; 
    j = j + 1; 
} while(i < 10); 

assert(1, j);

var j = 1; 
var i = 1; 
do { 
    i = i + 1; 
    j = j + 1; 
    continue; 
} while(i < 10); 

assert(10, j);

var j = 0; 
for(i = 1; i < 10; i = i + 1) { 
    break; 
    j = j + 1; 
} 

assert(0, j);

var j = 0;
for(i = 1; i < 10; i = i + 1) { 
    j = j + 1; 
    if(j == 5) 
        break; 
}

assert(5, j);

var j = 1; 
var i = 1; 
do { 
    i = i + 1; 
    break; 
    j = j + 1; 
} while(i < 10); 

assert(1, j);

var j = 1; 
var i = 1; 
do { 
    i = i + 1; 
    j = j + 1; 
    if(j == 5) 
        break; 
} while(i < 10); 

assert(5, j);

var i = 1; 
do 
    i = i + 1; 
while(i < 10);

assert(10, i);

var sum = 0;
var obj = {prop1: 5, prop2: 13, prop3: 8};

var result = "";
for (var i in obj) {
  result += i;
}
assert("prop1prop2prop3", result); 

for each (var item in obj) {
  sum += item;
}
assert(26, sum); 

// multiple init statements

for (var i = one ? index : 0, max = one ? index + 1 : 2; i < max; i++) {
}

Last edited Oct 11, 2009 at 12:58 PM by sebastienros, version 1

Comments

No comments yet.