1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_7/extensions/regress-346642-06.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 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +//----------------------------------------------------------------------------- 1.10 +var BUGNUMBER = 346642; 1.11 +var summary = 'decompilation of destructuring assignment'; 1.12 +var actual = ''; 1.13 +var expect = ''; 1.14 + 1.15 + 1.16 +//----------------------------------------------------------------------------- 1.17 +test(); 1.18 +//----------------------------------------------------------------------------- 1.19 + 1.20 +function test() 1.21 +{ 1.22 + enterFunc ('test'); 1.23 + printBugNumber(BUGNUMBER); 1.24 + printStatus (summary); 1.25 + 1.26 + expect = 3; 1.27 + actual = ''; 1.28 + "" + function() { [] = 3 }; actual = 3; 1.29 + actual = 3; 1.30 + reportCompare(expect, actual, summary + ': 1'); 1.31 + 1.32 + try 1.33 + { 1.34 + var z = 6; 1.35 + var f = eval('(function (){for(let [] = []; false;) let z; return z})'); 1.36 + expect = f(); 1.37 + actual = eval("("+f+")")() 1.38 + reportCompare(expect, actual, summary + ': 2'); 1.39 + } 1.40 + catch(ex) 1.41 + { 1.42 + // See https://bugzilla.mozilla.org/show_bug.cgi?id=408957 1.43 + var summarytrunk = 'let declaration must be direct child of block or top-level implicit block'; 1.44 + expect = 'SyntaxError'; 1.45 + actual = ex.name; 1.46 + reportCompare(expect, actual, summarytrunk); 1.47 + } 1.48 + 1.49 + expect = 3; 1.50 + actual = ''; 1.51 + "" + function () { for(;; [[a]] = [5]) { } }; actual = 3; 1.52 + reportCompare(expect, actual, summary + ': 3'); 1.53 + 1.54 + expect = 3; 1.55 + actual = ''; 1.56 + f = function () { return { set x([a]) { yield; } } } 1.57 + var obj = f(); 1.58 + uneval(obj); actual = 3; 1.59 + reportCompare(expect, actual, summary + ': 4'); 1.60 + 1.61 + expect = 3; 1.62 + actual = ''; 1.63 + "" + function () { [y([a]=b)] = z }; actual = 3; 1.64 + reportCompare(expect, actual, summary + ': 5'); 1.65 + 1.66 + expect = 3; 1.67 + actual = ''; 1.68 + "" + function () { for(;; ([[,]] = p)) { } }; actual = 3; 1.69 + reportCompare(expect, actual, summary + ': 6'); 1.70 + 1.71 + expect = 3; 1.72 + actual = ''; 1.73 + actual = 1; try {for(x in (function ([y]) { })() ) { }}catch(ex){} actual = 3; 1.74 + reportCompare(expect, actual, summary + ': 7'); 1.75 + 1.76 + exitFunc ('test'); 1.77 +}