Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
1 /// Copyright (c) 2012 Ecma International. All rights reserved.
2 /// Ecma International makes this code available under the terms and conditions set
3 /// forth on http://hg.ecmascript.org/tests/test262/raw-file/tip/LICENSE (the
4 /// "Use Terms"). Any redistribution of this code must retain the above
5 /// copyright and this notice and otherwise comply with the Use Terms.
6 /**
7 * @path ch13/13.2/13.2-17-1.js
8 * @description Function Object has 'constructor' as its own property, it is not enumerable and does not invoke the setter defined on Function.prototype.constructor (Step 17)
9 */
12 function testcase() {
13 var desc = Object.getOwnPropertyDescriptor(Object.prototype, "constructor");
14 try {
15 var getFunc = function () {
16 return 100;
17 };
19 var data = "data";
20 var setFunc = function (value) {
21 data = value;
22 };
24 Object.defineProperty(Object.prototype, "constructor", {
25 get: getFunc,
26 set: setFunc,
27 configurable: true
28 });
30 var fun = function () {};
32 var verifyValue = false;
33 verifyValue = typeof fun.prototype.constructor === "function";
35 var verifyEnumerable = false;
36 for (var p in fun.prototype) {
37 if (p === "constructor" && fun.prototype.hasOwnProperty("constructor")) {
38 verifyEnumerable = true;
39 }
40 }
42 var verifyWritable = false;
43 fun.prototype.constructor = 12;
44 verifyWritable = (fun.prototype.constructor === 12);
46 var verifyConfigurable = false;
47 delete fun.prototype.constructor;
48 verifyConfigurable = fun.hasOwnProperty("constructor");
50 return verifyValue && verifyWritable && !verifyEnumerable && !verifyConfigurable && data === "data";
51 } finally {
52 Object.defineProperty(Object.prototype, "constructor", desc);
53 }
54 }
55 runTestCase(testcase);