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__-shorthand-assignment.js'; michael@0: var BUGNUMBER = 963641; michael@0: var summary = "{ __proto__ } 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__ } = objectWithProtoProperty(42); michael@0: assertEq(__proto__, 42); michael@0: michael@0: ({ __proto__ } = objectWithProtoProperty(17)); michael@0: assertEq(__proto__, 17); michael@0: michael@0: function nested() michael@0: { michael@0: var { __proto__ } = objectWithProtoProperty("fnord"); michael@0: assertEq(__proto__, "fnord"); michael@0: michael@0: ({ __proto__ } = objectWithProtoProperty(undefined)); michael@0: assertEq(__proto__, undefined); 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");