michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/licenses/publicdomain/ michael@0: */ michael@0: michael@0: var gTestfile = 'destructuring-__proto__-target--assignment.js'; michael@0: var BUGNUMBER = 963641; michael@0: var summary = michael@0: "{ __proto__: target } should work as a destructuring assignment pattern"; michael@0: michael@0: print(BUGNUMBER + ": " + summary); michael@0: michael@0: /************** michael@0: * BEGIN TEST * michael@0: **************/ michael@0: michael@0: function objectWithProtoProperty(v) michael@0: { michael@0: var obj = {}; michael@0: return Object.defineProperty(obj, "__proto__", michael@0: { michael@0: enumerable: true, michael@0: configurable: true, michael@0: writable: true, michael@0: value: v michael@0: }); michael@0: } michael@0: michael@0: var { __proto__: target } = objectWithProtoProperty(null); michael@0: assertEq(target, null); michael@0: michael@0: ({ __proto__: target } = objectWithProtoProperty("aacchhorrt")); michael@0: assertEq(target, "aacchhorrt"); michael@0: michael@0: function nested() michael@0: { michael@0: var { __proto__: target } = objectWithProtoProperty(3.141592654); michael@0: assertEq(target, 3.141592654); michael@0: michael@0: ({ __proto__: target } = objectWithProtoProperty(-0)); michael@0: assertEq(target, -0); michael@0: } michael@0: nested(); michael@0: michael@0: /******************************************************************************/ michael@0: michael@0: if (typeof reportCompare === "function") michael@0: reportCompare(true, true); michael@0: michael@0: print("Tests complete");