Debian Codegraph @

rhino/testsrc/tests/js1_8/regress/regress-366941.js

raw symbols SCIP
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6 var gTestfile = 'regress-366941.js';
7
8 //-----------------------------------------------------------------------------
9 var BUGNUMBER = 366941;
10 var summary = 'Destructuring enumerations, iterations';
11 var actual = '';
12 var expect = '';
13
14
15 //-----------------------------------------------------------------------------
16 test();
17 //-----------------------------------------------------------------------------
18
19 function test()
20 {
21 enterFunc ('test');
22 printBugNumber(BUGNUMBER);
23 printStatus (summary);
24
25 var list1 = [[1,2],[3,4],[5,6]];
26 var list2 = [[1,2,3],[4,5,6],[7,8,9]];
27
28 expect = '1,2;3,4;5,6;';
29 actual = '';
30
31 for each (var [foo, bar] in list1) {
32 actual += foo + "," + bar + ";";
33 }
34
35 reportCompare(expect, actual, summary + ': 1');
36
37 expect = '1,2,3;4,5,6;7,8,9;';
38 actual = '';
39 for each (var [foo, bar, baz] in list2) {
40 actual += foo + "," + bar + "," + baz + ";";
41 }
42
43 reportCompare(expect, actual, summary + ': 2');
44
45 function gen(list) {
46 for each (var test in list) {
47 yield test;
48 }
49 }
50
51 var iter1 = gen(list1);
52
53 expect = '1,2;3,4;5,6;';
54 actual = '';
55
56 for (var [foo, bar] in iter1) {
57 actual += foo + "," + bar + ";";
58 }
59
60 reportCompare(expect, actual, summary + ': 3');
61
62 var iter2 = gen(list2);
63 expect = '1,2,3;4,5,6;7,8,9;';
64 actual = '';
65
66 for (var [foo, bar, baz] in iter2) {
67 actual += foo + "," + bar + "," + baz + ";";
68 }
69
70 reportCompare(expect, actual, summary + ': 4');
71
72 exitFunc ('test');
73 }