1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_7/expressions/destructuring-scope.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,63 @@ 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 = 'none'; 1.11 +var summary = 'Test destructuring assignments for differing scopes'; 1.12 +var actual = ''; 1.13 +var expect = ''; 1.14 + 1.15 +printBugNumber(BUGNUMBER); 1.16 +printStatus (summary); 1.17 + 1.18 +function f() { 1.19 + var x = 3; 1.20 + if (x > 0) { 1.21 + let {a:x} = {a:7}; 1.22 + if (x != 7) 1.23 + throw "fail"; 1.24 + } 1.25 + if (x != 3) 1.26 + throw "fail"; 1.27 +} 1.28 + 1.29 +function g() { 1.30 + for (var [a,b] in {x:7}) { 1.31 + if (a != "x" || b != 7) 1.32 + throw "fail"; 1.33 + } 1.34 + 1.35 + { 1.36 + for (let [a,b] in {y:8}) { 1.37 + if (a != "y" || b != 8) 1.38 + throw "fail"; 1.39 + } 1.40 + } 1.41 + 1.42 + if (a != "x" || b != 7) 1.43 + throw "fail"; 1.44 +} 1.45 + 1.46 +f(); 1.47 +g(); 1.48 + 1.49 +if (typeof a != "undefined" || typeof b != "undefined" || typeof x != "undefined") 1.50 + throw "fail"; 1.51 + 1.52 +function h() { 1.53 + for ([a,b] in {z:9}) { 1.54 + if (a != "z" || b != 9) 1.55 + throw "fail"; 1.56 + } 1.57 +} 1.58 + 1.59 +h(); 1.60 + 1.61 +if (a != "z" || b != 9) 1.62 + throw "fail"; 1.63 + 1.64 + 1.65 +reportCompare(expect, actual, summary); 1.66 +