|
1 /* |
|
2 * Any copyright is dedicated to the Public Domain. |
|
3 * http://creativecommons.org/licenses/publicdomain/ |
|
4 */ |
|
5 |
|
6 var gTestfile = 'destructuring-__proto__-target--assignment.js'; |
|
7 var BUGNUMBER = 963641; |
|
8 var summary = |
|
9 "{ __proto__: target } should work as a destructuring assignment pattern"; |
|
10 |
|
11 print(BUGNUMBER + ": " + summary); |
|
12 |
|
13 /************** |
|
14 * BEGIN TEST * |
|
15 **************/ |
|
16 |
|
17 function objectWithProtoProperty(v) |
|
18 { |
|
19 var obj = {}; |
|
20 return Object.defineProperty(obj, "__proto__", |
|
21 { |
|
22 enumerable: true, |
|
23 configurable: true, |
|
24 writable: true, |
|
25 value: v |
|
26 }); |
|
27 } |
|
28 |
|
29 var { __proto__: target } = objectWithProtoProperty(null); |
|
30 assertEq(target, null); |
|
31 |
|
32 ({ __proto__: target } = objectWithProtoProperty("aacchhorrt")); |
|
33 assertEq(target, "aacchhorrt"); |
|
34 |
|
35 function nested() |
|
36 { |
|
37 var { __proto__: target } = objectWithProtoProperty(3.141592654); |
|
38 assertEq(target, 3.141592654); |
|
39 |
|
40 ({ __proto__: target } = objectWithProtoProperty(-0)); |
|
41 assertEq(target, -0); |
|
42 } |
|
43 nested(); |
|
44 |
|
45 /******************************************************************************/ |
|
46 |
|
47 if (typeof reportCompare === "function") |
|
48 reportCompare(true, true); |
|
49 |
|
50 print("Tests complete"); |