1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_5/extensions/destructuring-__proto__-shorthand-assignment.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,49 @@ 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__-shorthand-assignment.js'; 1.10 +var BUGNUMBER = 963641; 1.11 +var summary = "{ __proto__ } should work as a destructuring assignment pattern"; 1.12 + 1.13 +print(BUGNUMBER + ": " + summary); 1.14 + 1.15 +/************** 1.16 + * BEGIN TEST * 1.17 + **************/ 1.18 + 1.19 +function objectWithProtoProperty(v) 1.20 +{ 1.21 + var obj = {}; 1.22 + return Object.defineProperty(obj, "__proto__", 1.23 + { 1.24 + enumerable: true, 1.25 + configurable: true, 1.26 + writable: true, 1.27 + value: v 1.28 + }); 1.29 +} 1.30 + 1.31 +var { __proto__ } = objectWithProtoProperty(42); 1.32 +assertEq(__proto__, 42); 1.33 + 1.34 +({ __proto__ } = objectWithProtoProperty(17)); 1.35 +assertEq(__proto__, 17); 1.36 + 1.37 +function nested() 1.38 +{ 1.39 + var { __proto__ } = objectWithProtoProperty("fnord"); 1.40 + assertEq(__proto__, "fnord"); 1.41 + 1.42 + ({ __proto__ } = objectWithProtoProperty(undefined)); 1.43 + assertEq(__proto__, undefined); 1.44 +} 1.45 +nested(); 1.46 + 1.47 +/******************************************************************************/ 1.48 + 1.49 +if (typeof reportCompare === "function") 1.50 + reportCompare(true, true); 1.51 + 1.52 +print("Tests complete");