js/src/tests/js1_8/regress/regress-366941.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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   var iter2 = gen(list2);
    64   expect = '1,2,3;4,5,6;7,8,9;';
    65   actual = '';
    67   for (var [foo, bar, baz] in iter2) {
    68     actual += foo + "," + bar + "," + baz + ";";
    69   }
    71   reportCompare(expect, actual, summary + ': 4');
    73   exitFunc ('test');
    74 }

mercurial