test262/website/resources/scripts/testcases2/15.2.3.4.json

253 lines
23 KiB
JSON

{
"testCollection": {
"name": "15.2.3.4",
"numTests": 35,
"tests": [
{
"id": "15.2.3.4-0-1",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-0-1.js",
"description": "Object.getOwnPropertyNames must exist as a function",
"test": "assertTrue((typeof(Object.getOwnPropertyNames) === \"function\"));\n"
},
{
"id": "15.2.3.4-0-2",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-0-2.js",
"description": "Object.getOwnPropertyNames must exist as a function taking 1 parameter",
"test": "assertTrue((Object.getOwnPropertyNames.length === 1));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames))"
},
{
"id": "15.2.3.4-1-2",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-1-2.js",
"description": "Object.getOwnPropertyNames throws TypeError if 'O' is undefined",
"test": "assertTrue((function testcase() {\n try {\n Object.getOwnPropertyNames(undefined);\n return false;\n } catch (e) {\n return e instanceof TypeError;\n }\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames))"
},
{
"id": "15.2.3.4-1-3",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-1-3.js",
"description": "Object.getOwnPropertyNames throws TypeError if 'O' is null",
"test": "assertTrue((function testcase() {\n try {\n Object.getOwnPropertyNames(null);\n return false;\n } catch (e) {\n return e instanceof TypeError;\n }\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames))"
},
{
"id": "15.2.3.4-1-4",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-1-4.js",
"description": "Object.getOwnPropertyNames throws TypeError if 'O' is a boolean",
"test": "assertTrue((function testcase() {\n try {\n Object.getOwnPropertyNames(true);\n return false;\n } catch (e) {\n return e instanceof TypeError;\n }\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames))"
},
{
"id": "15.2.3.4-1-5",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-1-5.js",
"description": "Object.getOwnPropertyNames throws TypeError if 'O' is a string",
"test": "assertTrue((function testcase() {\n try {\n Object.getOwnPropertyNames(\"abc\");\n return false;\n } catch (e) {\n return e instanceof TypeError;\n }\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames))"
},
{
"id": "15.2.3.4-1",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-1.js",
"description": "Object.getOwnPropertyNames throws TypeError if type of first param is not Object",
"test": "assertTrue((function testcase() {\n try {\n Object.getOwnPropertyNames(0);\n }\n catch (e) {\n if (e instanceof TypeError) {\n return true;\n }\n }\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames))"
},
{
"id": "15.2.3.4-2-1",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-2-1.js",
"description": "Object.getOwnPropertyNames - returned array is an array according to Array.isArray",
"test": "assertTrue((function testcase() {\n\n var obj = {};\n var result = Object.getOwnPropertyNames(obj);\n\n return Array.isArray(result);\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames) && fnExists(Array.isArray))"
},
{
"id": "15.2.3.4-2-2",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-2-2.js",
"description": "Object.getOwnPropertyNames - returned array is an instance of Array",
"test": "assertTrue((function testcase() {\n var obj = {};\n var result = Object.getOwnPropertyNames(obj);\n\n return result instanceof Array;\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames))"
},
{
"id": "15.2.3.4-2-3",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-2-3.js",
"description": "Object.getOwnPropertyNames - length of returned array is initialized to 0",
"test": "assertTrue((function testcase() {\n\n var obj = {};\n var result = Object.getOwnPropertyNames(obj);\n\n return result.length === 0;\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames))"
},
{
"id": "15.2.3.4-2-4",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-2-4.js",
"description": "Object.getOwnPropertyNames - returned array is the standard built-in constructor",
"test": "assertTrue((function testcase() {\n var oldArray = Array;\n Array = function () {\n throw new Error(\"invoke customer defined Array!\");\n };\n\n var obj = {};\n try {\n var result = Object.getOwnPropertyNames(obj);\n return Object.prototype.toString.call(result) === \"[object Array]\";\n } catch (ex) {\n return false;\n } finally {\n Array = oldArray;\n }\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames))"
},
{
"id": "15.2.3.4-3-1",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-3-1.js",
"description": "Object.getOwnPropertyNames - elements of the returned array start from index 0",
"test": "assertTrue((function testcase() {\n var obj = { prop1: 1001 };\n\n var arr = Object.getOwnPropertyNames(obj);\n\n return arr.hasOwnProperty(0) && arr[0] === \"prop1\";\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames))"
},
{
"id": "15.2.3.4-4-1",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-1.js",
"description": "Object.getOwnPropertyNames returns array of property names (Global)",
"test": "assertTrue((function testcase() {\n var result = Object.getOwnPropertyNames(fnGlobalObject());\n var expResult = [\"NaN\", \"Infinity\", \"undefined\", \"eval\", \"parseInt\", \"parseFloat\", \"isNaN\", \"isFinite\", \"decodeURI\", \"decodeURIComponent\", \"encodeURI\", \"encodeURIComponent\", \"Object\", \"Function\", \"Array\", \"String\", \"Boolean\", \"Number\", \"Date\", \"Date\", \"RegExp\", \"Error\", \"EvalError\", \"RangeError\", \"ReferenceError\", \"SyntaxError\", \"TypeError\", \"URIError\", \"Math\", \"JSON\"];\n\n var result1 = {};\n for (var p in result) {\n result1[result[p]] = true;\n }\n\n for (var p1 in expResult) {\n if (!result1[expResult[p1]]) {\n return false;\n }\n }\n\n return true;\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames))"
},
{
"id": "15.2.3.4-4-2",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-2.js",
"description": "Object.getOwnPropertyNames returns array of property names (Object)",
"test": "assertTrue((function testcase() {\n var result = Object.getOwnPropertyNames(Object);\n var expResult = [\"getPrototypeOf\", \"getOwnPropertyDescriptor\", \"getOwnPropertyNames\", \"create\", \"defineProperty\", \"defineProperties\", \"seal\", \"freeze\", \"preventExtensions\", \"isSealed\", \"isFrozen\", \"isExtensible\", \"keys\", \"prototype\", \"length\"];\n var found;\n\n return arrayContains(result, expResult);\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames))"
},
{
"id": "15.2.3.4-4-36",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-36.js",
"description": "Object.getOwnPropertyNames - inherited data properties are not pushed into the returned array",
"test": "assertTrue((function testcase() {\n\n var proto = { \"parent\": \"parent\" };\n\n var Con = function () { };\n Con.prototype = proto;\n\n var child = new Con();\n\n var result = Object.getOwnPropertyNames(child);\n\n for (var p in result) {\n if (result[p] === \"parent\") {\n return false;\n }\n }\n return true;\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames))"
},
{
"id": "15.2.3.4-4-37",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-37.js",
"description": "Object.getOwnPropertyNames - inherited accessor properties are not pushed into the returned array",
"test": "assertTrue((function testcase() {\n var proto = {};\n Object.defineProperty(proto, \"parent\", {\n get: function () {\n return \"parent\";\n },\n configurable: true\n });\n\n var Con = function () { };\n Con.prototype = proto;\n\n var child = new Con();\n\n var result = Object.getOwnPropertyNames(child);\n\n for (var p in result) {\n if (result[p] === \"parent\") {\n return false;\n }\n }\n return true;\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames) && fnExists(Object.defineProperty))"
},
{
"id": "15.2.3.4-4-38",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-38.js",
"description": "Object.getOwnPropertyNames - own data properties are pushed into the returned array",
"test": "assertTrue((function testcase() {\n\n var obj = { \"a\": \"a\" };\n\n var result = Object.getOwnPropertyNames(obj);\n\n return result[0] === \"a\";\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames))"
},
{
"id": "15.2.3.4-4-39",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-39.js",
"description": "Object.getOwnPropertyNames - own accessor properties are pushed into the returned array",
"test": "assertTrue((function testcase() {\n var obj = {};\n Object.defineProperty(obj, \"a\", {\n get: function () {\n return \"a\";\n },\n configurable: true\n });\n\n var result = Object.getOwnPropertyNames(obj);\n\n return result[0] === \"a\";\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames) && fnExists(Object.defineProperty))"
},
{
"id": "15.2.3.4-4-40",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-40.js",
"description": "Object.getOwnPropertyNames - inherited data property of String object 'O' is not pushed into the returned array",
"test": "assertTrue((function testcase() {\n try {\n var str = new String(\"abc\");\n\n String.prototype.protoProperty = \"protoString\";\n\n var result = Object.getOwnPropertyNames(str);\n\n for (var p in result) {\n if (result[p] === \"protoProperty\") {\n return false;\n }\n }\n\n return true;\n } finally {\n delete String.prototype.protoProperty;\n }\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames))"
},
{
"id": "15.2.3.4-4-41",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-41.js",
"description": "Object.getOwnPropertyNames - inherited accessor property of String object 'O' is not pushed into the returned array",
"test": "assertTrue((function testcase() {\n try {\n var str = new String(\"abc\");\n\n Object.defineProperty(String.prototype, \"protoProperty\", {\n get: function () {\n return \"protoString\";\n },\n configurable: true\n });\n\n var result = Object.getOwnPropertyNames(str);\n\n for (var p in result) {\n if (result[p] === \"protoProperty\") {\n return false;\n }\n }\n return true;\n } finally {\n delete String.prototype.protoProperty;\n }\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames) && fnExists(Object.defineProperty))"
},
{
"id": "15.2.3.4-4-42",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-42.js",
"description": "Object.getOwnPropertyNames - own data property of String object 'O' is pushed into the returned array",
"test": "assertTrue((function testcase() {\n var str = new String(\"abc\");\n\n Object.defineProperty(str, \"ownProperty\", {\n value: \"ownString\",\n configurable: true\n });\n\n var result = Object.getOwnPropertyNames(str);\n\n for (var p in result) {\n if (result[p] === \"ownProperty\") {\n return true;\n }\n }\n\n return false;\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames) && fnExists(Object.defineProperty))"
},
{
"id": "15.2.3.4-4-43",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-43.js",
"description": "Object.getOwnPropertyNames - own accessor property of String object 'O' is pushed into the returned array",
"test": "assertTrue((function testcase() {\n var str = new String(\"abc\");\n\n Object.defineProperty(str, \"ownProperty\", {\n get: function () {\n return \"ownString\";\n },\n configurable: true\n });\n\n var result = Object.getOwnPropertyNames(str);\n\n for (var p in result) {\n if (result[p] === \"ownProperty\") {\n return true;\n }\n }\n\n return false;\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames) && fnExists(Object.defineProperty))"
},
{
"id": "15.2.3.4-4-44",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-44.js",
"description": "Object.getOwnPropertyNames - own index properties of String object are pushed into the returned Array",
"test": "assertTrue((function testcase() {\n\n var str = new String(\"abc\");\n str[5] = \"de\";\n\n var expResult = [\"0\", \"1\", \"2\", \"length\", \"5\"];\n\n var result = Object.getOwnPropertyNames(str);\n\n return compareArray(expResult, result);\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames))"
},
{
"id": "15.2.3.4-4-45",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-45.js",
"description": "Object.getOwnPropertyNames - inherited data property of Array object 'O' is not pushed into the returned array.",
"test": "assertTrue((function testcase() {\n try {\n var arr = [0, 1, 2];\n\n Array.prototype.protoProperty = \"protoArray\";\n\n var result = Object.getOwnPropertyNames(arr);\n\n for (var p in result) {\n if (result[p] === \"protoProperty\") {\n return false;\n }\n }\n return true;\n } finally {\n delete Array.prototype.protoProperty;\n }\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames))"
},
{
"id": "15.2.3.4-4-46",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-46.js",
"description": "Object.getOwnPropertyNames - inherited accessor property of Array object 'O' is not pushed into the returned array.",
"test": "assertTrue((function testcase() {\n try {\n var arr = [0, 1, 2];\n\n Object.defineProperty(Array.prototype, \"protoProperty\", {\n get: function () {\n return \"protoArray\";\n },\n configurable: true\n });\n\n var result = Object.getOwnPropertyNames(arr);\n\n for (var p in result) {\n if (result[p] === \"protoProperty\") {\n return false;\n }\n }\n return true;\n } finally {\n delete Array.prototype.protoProperty;\n }\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames) && fnExists(Object.defineProperty))"
},
{
"id": "15.2.3.4-4-47",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-47.js",
"description": "Object.getOwnPropertyNames - own data property of Array object 'O' is pushed into the returned array",
"test": "assertTrue((function testcase() {\n var arr = [0, 1, 2];\n arr.ownProperty = \"ownArray\";\n\n var result = Object.getOwnPropertyNames(arr);\n\n for (var p in result) {\n if (result[p] === \"ownProperty\") {\n return true;\n }\n }\n\n return false;\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames))"
},
{
"id": "15.2.3.4-4-48",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-48.js",
"description": "Object.getOwnPropertyNames - own accessor property of Array object 'O' is pushed into the returned array.",
"test": "assertTrue((function testcase() {\n var arr = [0, 1, 2];\n\n Object.defineProperty(arr, \"ownProperty\", {\n get: function () {\n return \"ownArray\";\n },\n configurable: true\n });\n\n var result = Object.getOwnPropertyNames(arr);\n\n for (var p in result) {\n if (result[p] === \"ownProperty\") {\n return true;\n }\n }\n\n return false;\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames) && fnExists(Object.defineProperty))"
},
{
"id": "15.2.3.4-4-49",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-49.js",
"description": "Object.getOwnPropertyNames - own index properties of Array objcect are pushed into the returned Array",
"test": "assertTrue((function testcase() {\n var arr = [0, 1, 2];\n\n var expResult = [\"0\", \"1\", \"2\", \"length\"];\n\n var result = Object.getOwnPropertyNames(arr);\n\n return compareArray(expResult, result);\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames))"
},
{
"id": "15.2.3.4-4-50",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-50.js",
"description": "Object.getOwnPropertyNames - non-enumerable own property of 'O' is pushed into the returned Array",
"test": "assertTrue((function testcase() {\n var obj = {};\n\n Object.defineProperty(obj, \"nonEnumerableProp\", {\n value: 10,\n enumerable: false,\n configurable: true\n });\n\n var result = Object.getOwnPropertyNames(obj);\n\n return result[0] === \"nonEnumerableProp\";\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames) && fnExists(Object.defineProperty))"
},
{
"id": "15.2.3.4-4-b-1",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-b-1.js",
"description": "Object.getOwnPropertyNames - descriptor of resultant array is all true",
"test": "assertTrue((function testcase() {\n var obj = new Object();\n obj.x = 1;\n obj.y = 2;\n var result = Object.getOwnPropertyNames(obj);\n var desc = Object.getOwnPropertyDescriptor(result,\"0\");\n if (desc.enumerable === true &&\n desc.configurable === true &&\n desc.writable === true) {\n return true;\n }\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames))"
},
{
"id": "15.2.3.4-4-b-2",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-b-2.js",
"description": "Object.getOwnPropertyNames - all own properties are pushed into the returned array",
"test": "assertTrue((function testcase() {\n var obj = { \"a\": \"a\" };\n\n Object.defineProperty(obj, \"b\", {\n get: function () {\n return \"b\";\n },\n enumerable: false,\n configurable: true\n });\n\n Object.defineProperty(obj, \"c\", {\n get: function () {\n return \"c\";\n },\n enumerable: true,\n configurable: true\n });\n\n Object.defineProperty(obj, \"d\", {\n value: \"d\",\n enumerable: false,\n configurable: true\n });\n\n var result = Object.getOwnPropertyNames(obj);\n var expResult = [\"a\", \"b\", \"c\", \"d\"];\n\n return compareArray(expResult, result);\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames) && fnExists(Object.defineProperty))"
},
{
"id": "15.2.3.4-4-b-3",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-b-3.js",
"description": "Object.getOwnPropertyNames - own property named empty('') is pushed into the returned array",
"test": "assertTrue((function testcase() {\n var obj = { \"\": \"empty\" };\n\n var result = Object.getOwnPropertyNames(obj);\n\n for (var p in result) {\n if (result[p] === \"\") {\n return true;\n }\n }\n\n return false;\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames))"
},
{
"id": "15.2.3.4-4-b-4",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-b-4.js",
"description": "Object.getOwnPropertyNames - elements of the returned array are writable",
"test": "assertTrue((function testcase() {\n var obj = { \"a\": \"a\" };\n\n var result = Object.getOwnPropertyNames(obj);\n\n try {\n var beforeOverride = (result[0] === \"a\");\n result[0] = \"b\";\n var afterOverride = (result[0] === \"b\");\n\n return beforeOverride && afterOverride;\n } catch (ex) {\n return false;\n }\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames))"
},
{
"id": "15.2.3.4-4-b-5",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-b-5.js",
"description": "Object.getOwnPropertyNames - elements of the returned array are enumerable",
"test": "assertTrue((function testcase() {\n var obj = { \"a\": \"a\" };\n\n var result = Object.getOwnPropertyNames(obj);\n\n for (var p in result) {\n if (result[p] === \"a\") {\n return true;\n }\n }\n\n return false;\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames))"
},
{
"id": "15.2.3.4-4-b-6",
"path": "TestCases/chapter15/15.2/15.2.3/15.2.3.4/15.2.3.4-4-b-6.js",
"description": "Object.getOwnPropertyNames - elements of the returned array are configurable",
"test": "assertTrue((function testcase() {\n var obj = { \"a\": \"a\" };\n\n var result = Object.getOwnPropertyNames(obj);\n\n var beforeDeleted = (result.hasOwnProperty(\"0\"));\n delete result[0];\n var afterDeleted = (result.hasOwnProperty(\"0\"));\n\n return beforeDeleted && !afterDeleted;\n }).call(this));\n",
"precondition": "(fnExists(Object.getOwnPropertyNames))"
}
]
}
}