Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3 * Any copyright is dedicated to the Public Domain.
4 * http://creativecommons.org/licenses/publicdomain/
5 * Contributor: Robert Sayre
6 */
9 //-----------------------------------------------------------------------------
10 var BUGNUMBER = 366941;
11 var summary = 'Destructuring enumerations, iterations';
12 var actual = '';
13 var expect = '';
16 //-----------------------------------------------------------------------------
17 test();
18 //-----------------------------------------------------------------------------
20 function test()
21 {
22 enterFunc ('test');
23 printBugNumber(BUGNUMBER);
24 printStatus (summary);
26 var list1 = [[1,2],[3,4],[5,6]];
27 var list2 = [[1,2,3],[4,5,6],[7,8,9]];
29 expect = '1,2;3,4;5,6;';
30 actual = '';
32 for each (var [foo, bar] in list1) {
33 actual += foo + "," + bar + ";";
34 }
36 reportCompare(expect, actual, summary + ': 1');
38 expect = '1,2,3;4,5,6;7,8,9;';
39 actual = '';
40 for each (var [foo, bar, baz] in list2) {
41 actual += foo + "," + bar + "," + baz + ";";
42 }
44 reportCompare(expect, actual, summary + ': 2');
46 function gen(list) {
47 for each (var test in list) {
48 yield test;
49 }
50 }
52 var iter1 = gen(list1);
54 expect = '1,2;3,4;5,6;';
55 actual = '';
57 for (var [foo, bar] in iter1) {
58 actual += foo + "," + bar + ";";
59 }
61 reportCompare(expect, actual, summary + ': 3');
63 // syntax error in js17
64 var iter2 = gen(list2);
65 expect = /SyntaxError: (invalid for.in left-hand side|Left hand side of for..in loop must be an array of length 2 to accept key.value pair.)/;
66 actual = '';
68 try
69 {
70 eval('for (var [foo, bar, baz] in iter2) {' +
71 'actual += foo + "," + bar + "," + baz + ";";' +
72 '}');
73 actual = 'No Error';
74 }
75 catch(ex)
76 {
77 actual = ex + '';
78 }
80 reportMatch(expect, actual, summary + ': 4');
82 exitFunc ('test');
83 }