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