1// Copyright JS Foundation and other contributors, http://js.foundation 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15var idx = 0; 16for (var [a,b] of [[1,2], [3,4]]) 17{ 18 if (idx == 0) 19 { 20 assert(a === 1); 21 assert(b === 2); 22 idx = 1; 23 } 24 else 25 { 26 assert(a === 3); 27 assert(b === 4); 28 } 29} 30 31assert(a === 3); 32assert(b === 4); 33 34idx = 0; 35for (let [a,b] of [[5,6], [7,8]]) 36{ 37 if (idx == 0) 38 { 39 assert(a === 5); 40 assert(b === 6); 41 idx = 1; 42 } 43 else 44 { 45 assert(a === 7); 46 assert(b === 8); 47 } 48} 49 50assert(a === 3); 51assert(b === 4); 52 53idx = 0; 54for (let [a,b] of [[11,12], [13,14]]) 55{ 56 if (idx == 0) 57 { 58 eval("assert(a === 11)"); 59 eval("assert(b === 12)"); 60 idx = 1; 61 } 62 else 63 { 64 eval("assert(a === 13)"); 65 eval("assert(b === 14)"); 66 } 67} 68 69assert(a === 3); 70assert(b === 4); 71 72try { 73 eval("for (let [a,b] = [1,2] of [[3,4]]) {}"); 74 assert(false); 75} catch (e) { 76 assert(e instanceof SyntaxError); 77} 78