mirror of https://github.com/tc39/test262.git
84 lines
8.4 KiB
JSON
84 lines
8.4 KiB
JSON
{
|
|
"testCollection": {
|
|
"name": "13.2",
|
|
"numTests": 10,
|
|
"tests": [
|
|
{
|
|
"id": "13.2-1-s",
|
|
"path": "TestCases/chapter13/13.2/13.2-1-s.js",
|
|
"description": "StrictMode - Writing or reading from a property named 'caller' of function objects is allowed under both strict and normal modes.",
|
|
"test": "assertTrue((function testcase() {\n \"use strict\";\n\n var foo = function () {\n this.caller = 12;\n }\n var obj = new foo();\n return obj.caller === 12;\n }).call(this));\n",
|
|
"strict_only": ""
|
|
},
|
|
{
|
|
"id": "13.2-15-1",
|
|
"path": "TestCases/chapter13/13.2/13.2-15-1.js",
|
|
"description": "Function Object has length as its own property and does not invoke the setter defined on Function.prototype.length (Step 15)",
|
|
"test": "assertTrue((function testcase() {\n var fun = function (x, y) { };\n\n var verifyValue = false;\n verifyValue = (fun.hasOwnProperty(\"length\") && fun.length === 2);\n\n var verifyWritable = false;\n fun.length = 1001;\n verifyWritable = (fun.length === 1001);\n\n var verifyEnumerable = false;\n for (var p in fun) {\n if (p === \"length\") {\n verifyEnumerable = true;\n }\n }\n\n var verifyConfigurable = false;\n delete fun.length;\n verifyConfigurable = fun.hasOwnProperty(\"length\");\n\n return verifyValue && !verifyWritable && !verifyEnumerable && verifyConfigurable;\n }).call(this));\n",
|
|
"precondition": "(fnExists(Object.defineProperty))"
|
|
},
|
|
{
|
|
"id": "13.2-17-1",
|
|
"path": "TestCases/chapter13/13.2/13.2-17-1.js",
|
|
"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)",
|
|
"test": "assertTrue((function testcase() {\n var desc = Object.getOwnPropertyDescriptor(Object.prototype, \"constructor\");\n try {\n var getFunc = function () {\n return 100;\n };\n\n var data = \"data\";\n var setFunc = function (value) {\n data = value;\n };\n\n Object.defineProperty(Object.prototype, \"constructor\", {\n get: getFunc,\n set: setFunc,\n configurable: true\n });\n\n var fun = function () {};\n\n var verifyValue = false;\n verifyValue = typeof fun.prototype.constructor === \"function\";\n\n var verifyEnumerable = false;\n for (var p in fun.prototype) {\n if (p === \"constructor\" && fun.prototype.hasOwnProperty(\"constructor\")) {\n verifyEnumerable = true;\n }\n }\n\n var verifyWritable = false;\n fun.prototype.constructor = 12;\n verifyWritable = (fun.prototype.constructor === 12);\n\n var verifyConfigurable = false;\n delete fun.prototype.constructor;\n verifyConfigurable = fun.hasOwnProperty(\"constructor\");\n\n return verifyValue && verifyWritable && !verifyEnumerable && !verifyConfigurable && data === \"data\";\n } finally {\n Object.defineProperty(Object.prototype, \"constructor\", desc);\n }\n }).call(this));\n",
|
|
"precondition": "(fnExists(Object.defineProperty))"
|
|
},
|
|
{
|
|
"id": "13.2-18-1",
|
|
"path": "TestCases/chapter13/13.2/13.2-18-1.js",
|
|
"description": "Function Object has 'prototype' as its own property, it is not enumerable and does not invoke the setter defined on Function.prototype (Step 18)",
|
|
"test": "assertTrue((function testcase() {\n try {\n var getFunc = function () {\n return 100;\n };\n\n var data = \"data\";\n var setFunc = function (value) {\n data = value;\n };\n Object.defineProperty(Function.prototype, \"prototype\", {\n get: getFunc,\n set: setFunc,\n configurable: true\n });\n\n var fun = function () { };\n\n var verifyValue = false;\n verifyValue = (fun.prototype !== 100 && fun.prototype.toString() === \"[object Object]\");\n\n var verifyEnumerable = false;\n for (var p in fun) {\n if (p === \"prototype\" && fun.hasOwnProperty(\"prototype\")) {\n verifyEnumerable = true;\n }\n }\n\n var verifyConfigurable = false;\n delete fun.prototype;\n verifyConfigurable = fun.hasOwnProperty(\"prototype\");\n\n var verifyWritable = false;\n fun.prototype = 12\n verifyWritable = (fun.prototype === 12);\n\n return verifyValue && verifyWritable && !verifyEnumerable && verifyConfigurable && data === \"data\";\n } finally {\n delete Function.prototype.prototype;\n }\n }).call(this));\n",
|
|
"precondition": "(fnExists(Object.defineProperty))"
|
|
},
|
|
{
|
|
"id": "13.2-2-s",
|
|
"path": "TestCases/chapter13/13.2/13.2-2-s.js",
|
|
"description": "StrictMode - A TypeError is thrown when a strict mode code writes to properties named 'caller' of function instances.",
|
|
"test": "assertTrue((function testcase() {\n \"use strict\";\n try {\n var foo = function () {\n }\n foo.caller = 20;\n return false;\n } catch (ex) {\n return ex instanceof TypeError;\n }\n }).call(this));\n",
|
|
"precondition": "(fnSupportsStrict())",
|
|
"strict_only": ""
|
|
},
|
|
{
|
|
"id": "13.2-3-s",
|
|
"path": "TestCases/chapter13/13.2/13.2-3-s.js",
|
|
"description": "StrictMode - Writing or reading from a property named 'arguments' of function objects is allowed under both strict and normal modes.",
|
|
"test": "assertTrue((function testcase() {\n \"use strict\";\n\n var foo = function () {\n this.arguments = 12;\n } \n var obj = new foo();\n return obj.arguments === 12;\n }).call(this));\n",
|
|
"strict_only": ""
|
|
},
|
|
{
|
|
"id": "13.2-4-s",
|
|
"path": "TestCases/chapter13/13.2/13.2-4-s.js",
|
|
"description": "StrictMode - A TypeError is thrown when a code in strict mode tries to write to 'arguments' of function instances.",
|
|
"test": "assertTrue((function testcase() {\n \"use strict\";\n try {\n var foo = function () {\n }\n foo.arguments = 20;\n return false;\n } catch (ex) {\n return ex instanceof TypeError;\n }\n }).call(this));\n",
|
|
"precondition": "(fnSupportsStrict())",
|
|
"strict_only": ""
|
|
},
|
|
{
|
|
"id": "13.2-5-s",
|
|
"path": "TestCases/chapter13/13.2/13.2-5-s.js",
|
|
"description": "StrictMode - reading a property named 'caller' of function objects is not allowed outside the function",
|
|
"test": "assertTrue((function testcase() {\n var foo = new Function(\"'use strict';\");\n try {\n var temp = foo.caller;\n return false;\n }\n catch (e) {\n return e instanceof TypeError;\n }\n }).call(this));\n",
|
|
"precondition": "(fnSupportsStrict())",
|
|
"strict_only": ""
|
|
},
|
|
{
|
|
"id": "13.2-7-s",
|
|
"path": "TestCases/chapter13/13.2/13.2-7-s.js",
|
|
"description": "StrictMode - enumerating over a function object looking for 'caller' fails outside of the function",
|
|
"test": "assertTrue((function testcase() {\n var foo = new Function(\"'use strict';\");\n \n for (var tempIndex in foo) {\n if (tempIndex === \"caller\") {\n return false;\n }\n }\n return true;\n }).call(this));\n",
|
|
"precondition": "(fnSupportsStrict())",
|
|
"strict_only": ""
|
|
},
|
|
{
|
|
"id": "13.2-8-s",
|
|
"path": "TestCases/chapter13/13.2/13.2-8-s.js",
|
|
"description": "StrictMode - enumerating over a function object looking for 'caller' fails inside the function",
|
|
"test": "assertTrue((function testcase() {\n var foo = new Function(\"'use strict'; for (var tempIndex in this) {if (tempIndex===\\\"caller\\\") {return false;}}; return true;\");\n return foo();\n }).call(this));\n",
|
|
"precondition": "(fnSupportsStrict())",
|
|
"strict_only": ""
|
|
}
|
|
]
|
|
}
|
|
}
|