1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_8/regress/regress-366941.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,74 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* 1.6 + * Any copyright is dedicated to the Public Domain. 1.7 + * http://creativecommons.org/licenses/publicdomain/ 1.8 + * Contributor: Robert Sayre 1.9 + */ 1.10 + 1.11 + 1.12 +//----------------------------------------------------------------------------- 1.13 +var BUGNUMBER = 366941; 1.14 +var summary = 'Destructuring enumerations, iterations'; 1.15 +var actual = ''; 1.16 +var expect = ''; 1.17 + 1.18 + 1.19 +//----------------------------------------------------------------------------- 1.20 +test(); 1.21 +//----------------------------------------------------------------------------- 1.22 + 1.23 +function test() 1.24 +{ 1.25 + enterFunc ('test'); 1.26 + printBugNumber(BUGNUMBER); 1.27 + printStatus (summary); 1.28 + 1.29 + var list1 = [[1,2],[3,4],[5,6]]; 1.30 + var list2 = [[1,2,3],[4,5,6],[7,8,9]]; 1.31 + 1.32 + expect = '1,2;3,4;5,6;'; 1.33 + actual = ''; 1.34 + 1.35 + for each (var [foo, bar] in list1) { 1.36 + actual += foo + "," + bar + ";"; 1.37 + } 1.38 + 1.39 + reportCompare(expect, actual, summary + ': 1'); 1.40 + 1.41 + expect = '1,2,3;4,5,6;7,8,9;'; 1.42 + actual = ''; 1.43 + for each (var [foo, bar, baz] in list2) { 1.44 + actual += foo + "," + bar + "," + baz + ";"; 1.45 + } 1.46 + 1.47 + reportCompare(expect, actual, summary + ': 2'); 1.48 + 1.49 + function gen(list) { 1.50 + for each (var test in list) { 1.51 + yield test; 1.52 + } 1.53 + } 1.54 + 1.55 + var iter1 = gen(list1); 1.56 + 1.57 + expect = '1,2;3,4;5,6;'; 1.58 + actual = ''; 1.59 + 1.60 + for (var [foo, bar] in iter1) { 1.61 + actual += foo + "," + bar + ";"; 1.62 + } 1.63 + 1.64 + reportCompare(expect, actual, summary + ': 3'); 1.65 + 1.66 + var iter2 = gen(list2); 1.67 + expect = '1,2,3;4,5,6;7,8,9;'; 1.68 + actual = ''; 1.69 + 1.70 + for (var [foo, bar, baz] in iter2) { 1.71 + actual += foo + "," + bar + "," + baz + ";"; 1.72 + } 1.73 + 1.74 + reportCompare(expect, actual, summary + ': 4'); 1.75 + 1.76 + exitFunc ('test'); 1.77 +}