js/src/tests/ecma_5/extensions/destructuring-__proto__-shorthand-assignment.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /*
     2  * Any copyright is dedicated to the Public Domain.
     3  * http://creativecommons.org/licenses/publicdomain/
     4  */
     6 var gTestfile = 'destructuring-__proto__-shorthand-assignment.js';
     7 var BUGNUMBER = 963641;
     8 var summary = "{ __proto__ } should work as a destructuring assignment pattern";
    10 print(BUGNUMBER + ": " + summary);
    12 /**************
    13  * BEGIN TEST *
    14  **************/
    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 }
    28 var { __proto__ } = objectWithProtoProperty(42);
    29 assertEq(__proto__, 42);
    31 ({ __proto__ } = objectWithProtoProperty(17));
    32 assertEq(__proto__, 17);
    34 function nested()
    35 {
    36   var { __proto__ } = objectWithProtoProperty("fnord");
    37   assertEq(__proto__, "fnord");
    39   ({ __proto__ } = objectWithProtoProperty(undefined));
    40   assertEq(__proto__, undefined);
    41 }
    42 nested();
    44 /******************************************************************************/
    46 if (typeof reportCompare === "function")
    47   reportCompare(true, true);
    49 print("Tests complete");

mercurial