1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
{
"testCollection": {
"name": "15.2.4.5_Object.prototype.hasOwnProperty",
"numTests": 11,
"tests": [
{
"section": "15.2.4.5",
"description": "Checking if varying the Object.prototype.hasOwnProperty.length property fails",
"test": "//CHECK#1\nif (!(Object.prototype.hasOwnProperty.hasOwnProperty('length'))) {\n $FAIL('#1: the Object.prototype.hasOwnProperty has length property.');\n}\n\nvar obj = Object.prototype.hasOwnProperty.length;\n\nObject.prototype.hasOwnProperty.length = function(){return \"shifted\";};\n\n//CHECK#2\nif (Object.prototype.hasOwnProperty.length !== obj) {\n $ERROR('#2: the Object.prototype.hasOwnProperty length property has the attributes ReadOnly.');\n}\n",
"id": "S15.2.4.5_A10"
},
{
"section": "15.2.4.5",
"description": "Checking the Object.prototype.hasOwnProperty.length",
"test": "//CHECK#1\nif (!(Object.prototype.hasOwnProperty.hasOwnProperty(\"length\"))) {\n $ERROR('#1: The length property of the toObject method is 1');\n}\n\n//CHECK#2\nif (Object.prototype.hasOwnProperty.length !== 1) {\n $ERROR('#2: The length property of the toObject method is 1');\n}\n",
"id": "S15.2.4.5_A11"
},
{
"section": "15.2.4.5",
"negative": "",
"test": "Object.prototype.hasOwnProperty.call(undefined, 'foo');\n",
"id": "S15.2.4.5_A12",
"description": "Let O be the result of calling ToObject passing the this value as the argument."
},
{
"section": "15.2.4.5",
"negative": "",
"test": "Object.prototype.hasOwnProperty.call(null, 'foo');\n",
"id": "S15.2.4.5_A13",
"description": "Let O be the result of calling ToObject passing the this value as the argument."
},
{
"section": "15.2.4.5",
"description": "Checking type of the Object.prototype.hasOwnProperty and the returned result",
"test": "//CHECK#1\nif (typeof Object.prototype.hasOwnProperty !== \"function\") {\n $ERROR('#1: hasOwnProperty method is defined');\n}\n\n//CHECK#2\nif (!(Object.prototype.hasOwnProperty(\"hasOwnProperty\"))) {\n $ERROR('#2: hasOwnProperty method works properly');\n}\n//\n",
"id": "S15.2.4.5_A1_T1"
},
{
"section": "15.2.4.5",
"description": "Argument of the hasOwnProperty method is a custom boolean property",
"test": "//CHECK#1\nif (typeof Object.prototype.hasOwnProperty !== \"function\") {\n $ERROR('#1: hasOwnProperty method is defined');\n}\n\nvar obj = {the_property:true};\n\n//CHECK#2\nif (typeof obj.hasOwnProperty !== \"function\") {\n $ERROR('#2: hasOwnProperty method is accessed');\n}\n\n//CHECK#3\nif (obj.hasOwnProperty(\"hasOwnProperty\")) {\n $ERROR('#3: hasOwnProperty method works properly');\n}\n\n//CHECK#4\nif (!(obj.hasOwnProperty(\"the_property\"))) {\n $ERROR('#4: hasOwnProperty method works properly');\n}\n//\n",
"id": "S15.2.4.5_A1_T2"
},
{
"section": "15.2.4.5",
"description": "Argument of the hasOwnProperty method is a custom property of a function object",
"test": "var FACTORY = function(){\n this.aproperty = 1;\n};\n\nvar instance = new FACTORY;\n\n//CHECK#1\nif (typeof Object.prototype.hasOwnProperty !== \"function\") {\n $ERROR('#1: hasOwnProperty method is defined');\n}\n\n//CHECK#2\nif (typeof instance.hasOwnProperty !== \"function\") {\n $ERROR('#2: hasOwnProperty method is accessed');\n}\n\n//CHECK#3\nif (instance.hasOwnProperty(\"toString\")) {\n $ERROR('#3: hasOwnProperty method works properly');\n}\n\n//CHECK#4\nif (!(instance.hasOwnProperty(\"aproperty\"))) {\n $ERROR('#4: hasOwnProperty method works properly');\n}\n\n",
"id": "S15.2.4.5_A1_T3"
},
{
"section": "15.2.4.5, 13.2",
"description": "Checking if obtaining the prototype property of Object.prototype.hasOwnProperty fails",
"test": "//CHECK#1\nif (Object.prototype.hasOwnProperty.prototype !== undefined) {\n $ERROR('#1: Object.prototype.hasOwnProperty has not prototype property'+Object.prototype.hasOwnProperty.prototype);\n}\n//\n",
"id": "S15.2.4.5_A6"
},
{
"section": "15.2.4.5, 13.2",
"description": "Checking if creating \"new Object.prototype.hasOwnProperty\" fails",
"test": "var FACTORY = Object.prototype.hasOwnProperty;\n\ntry {\n instance = new FACTORY;\n $FAIL('#1: Object.prototype.hasOwnProperty can\\'t be used as a constructor');\n} catch (e) {\n $PRINT(e);\n\n}\n",
"id": "S15.2.4.5_A7"
},
{
"section": "15.2.4.5",
"description": "Checking if enumerating the Object.prototype.hasOwnProperty.length property fails",
"test": "//CHECK#0\nif (!(Object.prototype.hasOwnProperty.hasOwnProperty('length'))) {\n $FAIL('#0: the Object.prototype.hasOwnProperty has length property.');\n}\n\n\n// CHECK#1\nif (Object.prototype.hasOwnProperty.propertyIsEnumerable('length')) {\n $ERROR('#1: the Object.prototype.hasOwnProperty.length property has the attributes DontEnum');\n}\n\n// CHECK#2\nfor (p in Object.prototype.hasOwnProperty){\n if (p===\"length\")\n $ERROR('#2: the Object.prototype.hasOwnProperty.length property has the attributes DontEnum');\n}\n//\n",
"id": "S15.2.4.5_A8"
},
{
"section": "15.2.4.5",
"description": "Checking if deleting the Object.prototype.hasOwnProperty.length property fails",
"test": "//CHECK#0\nif (!(Object.prototype.hasOwnProperty.hasOwnProperty('length'))) {\n $FAIL('#0: the Object.prototype.hasOwnProperty has length property');\n}\n\n//CHECK#1\nif (delete Object.prototype.hasOwnProperty.length) {\n $ERROR('#1: The Object.prototype.hasOwnProperty.length property has the attributes DontDelete');\n}\n\n//CHECK#2\nif (!(Object.prototype.hasOwnProperty.hasOwnProperty('length'))) {\n $FAIL('#2: The Object.prototype.hasOwnProperty.length property has the attributes DontDelete');\n}\n",
"id": "S15.2.4.5_A9"
}
]
}
}
|