| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
var gTestfile = 'destructuring-scope.js'; |
| 7 |
|
| 8 |
var BUGNUMBER = 'none'; |
| 9 |
var summary = 'Test destructuring assignments for differing scopes'; |
| 10 |
var actual = ''; |
| 11 |
var expect = ''; |
| 12 |
|
| 13 |
printBugNumber(BUGNUMBER); |
| 14 |
printStatus (summary); |
| 15 |
|
| 16 |
function f() { |
| 17 |
var x = 3; |
| 18 |
if (x > 0) { |
| 19 |
let {a:x} = {a:7}; |
| 20 |
if (x != 7) |
| 21 |
throw "fail"; |
| 22 |
} |
| 23 |
if (x != 3) |
| 24 |
throw "fail"; |
| 25 |
} |
| 26 |
|
| 27 |
function g() { |
| 28 |
for (var [a,b] in {x:7}) { |
| 29 |
if (a != "x" || b != 7) |
| 30 |
throw "fail"; |
| 31 |
} |
| 32 |
|
| 33 |
{ |
| 34 |
for (let [a,b] in {y:8}) { |
| 35 |
if (a != "y" || b != 8) |
| 36 |
throw "fail"; |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
if (a != "x" || b != 7) |
| 41 |
throw "fail"; |
| 42 |
} |
| 43 |
|
| 44 |
f(); |
| 45 |
g(); |
| 46 |
|
| 47 |
if (typeof a != "undefined" || typeof b != "undefined" || typeof x != "undefined") |
| 48 |
throw "fail"; |
| 49 |
|
| 50 |
function h() { |
| 51 |
for ([a,b] in {z:9}) { |
| 52 |
if (a != "z" || b != 9) |
| 53 |
throw "fail"; |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
h(); |
| 58 |
|
| 59 |
if (a != "z" || b != 9) |
| 60 |
throw "fail"; |
| 61 |
|
| 62 |
|
| 63 |
reportCompare(expect, actual, summary); |
| 64 |
|