michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/licenses/publicdomain/ michael@0: * Contributor: Robert Sayre michael@0: */ michael@0: michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 366941; michael@0: var summary = 'Destructuring enumerations, iterations'; michael@0: var actual = ''; michael@0: var expect = ''; michael@0: michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: test(); michael@0: //----------------------------------------------------------------------------- michael@0: michael@0: function test() michael@0: { michael@0: enterFunc ('test'); michael@0: printBugNumber(BUGNUMBER); michael@0: printStatus (summary); michael@0: michael@0: var list1 = [[1,2],[3,4],[5,6]]; michael@0: var list2 = [[1,2,3],[4,5,6],[7,8,9]]; michael@0: michael@0: expect = '1,2;3,4;5,6;'; michael@0: actual = ''; michael@0: michael@0: for each (var [foo, bar] in list1) { michael@0: actual += foo + "," + bar + ";"; michael@0: } michael@0: michael@0: reportCompare(expect, actual, summary + ': 1'); michael@0: michael@0: expect = '1,2,3;4,5,6;7,8,9;'; michael@0: actual = ''; michael@0: for each (var [foo, bar, baz] in list2) { michael@0: actual += foo + "," + bar + "," + baz + ";"; michael@0: } michael@0: michael@0: reportCompare(expect, actual, summary + ': 2'); michael@0: michael@0: function gen(list) { michael@0: for each (var test in list) { michael@0: yield test; michael@0: } michael@0: } michael@0: michael@0: var iter1 = gen(list1); michael@0: michael@0: expect = '1,2;3,4;5,6;'; michael@0: actual = ''; michael@0: michael@0: for (var [foo, bar] in iter1) { michael@0: actual += foo + "," + bar + ";"; michael@0: } michael@0: michael@0: reportCompare(expect, actual, summary + ': 3'); michael@0: michael@0: var iter2 = gen(list2); michael@0: expect = '1,2,3;4,5,6;7,8,9;'; michael@0: actual = ''; michael@0: michael@0: for (var [foo, bar, baz] in iter2) { michael@0: actual += foo + "," + bar + "," + baz + ";"; michael@0: } michael@0: michael@0: reportCompare(expect, actual, summary + ': 4'); michael@0: michael@0: exitFunc ('test'); michael@0: }