1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_5/extensions/destructuring-__proto__-target-assignment.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,50 @@ 1.4 +/* 1.5 + * Any copyright is dedicated to the Public Domain. 1.6 + * http://creativecommons.org/licenses/publicdomain/ 1.7 + */ 1.8 + 1.9 +var gTestfile = 'destructuring-__proto__-target--assignment.js'; 1.10 +var BUGNUMBER = 963641; 1.11 +var summary = 1.12 + "{ __proto__: target } should work as a destructuring assignment pattern"; 1.13 + 1.14 +print(BUGNUMBER + ": " + summary); 1.15 + 1.16 +/************** 1.17 + * BEGIN TEST * 1.18 + **************/ 1.19 + 1.20 +function objectWithProtoProperty(v) 1.21 +{ 1.22 + var obj = {}; 1.23 + return Object.defineProperty(obj, "__proto__", 1.24 + { 1.25 + enumerable: true, 1.26 + configurable: true, 1.27 + writable: true, 1.28 + value: v 1.29 + }); 1.30 +} 1.31 + 1.32 +var { __proto__: target } = objectWithProtoProperty(null); 1.33 +assertEq(target, null); 1.34 + 1.35 +({ __proto__: target } = objectWithProtoProperty("aacchhorrt")); 1.36 +assertEq(target, "aacchhorrt"); 1.37 + 1.38 +function nested() 1.39 +{ 1.40 + var { __proto__: target } = objectWithProtoProperty(3.141592654); 1.41 + assertEq(target, 3.141592654); 1.42 + 1.43 + ({ __proto__: target } = objectWithProtoProperty(-0)); 1.44 + assertEq(target, -0); 1.45 +} 1.46 +nested(); 1.47 + 1.48 +/******************************************************************************/ 1.49 + 1.50 +if (typeof reportCompare === "function") 1.51 + reportCompare(true, true); 1.52 + 1.53 +print("Tests complete");