blob: cb763c98951c9bf61836efcaa59194f6f7d3380e (
plain)
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
|
load("test-common.js");
try {
o = {};
o.x = 1;
o.y = 2;
o.z = 3;
assert(Object.getOwnPropertyNames(o).length === 3);
assert(delete o.x === true);
assert(o.hasOwnProperty("x") === false);
assert(o.hasOwnProperty("y") === true);
assert(o.hasOwnProperty("z") === true);
assert(Object.getOwnPropertyNames(o).length === 2);
assert(delete o.y === true);
assert(o.hasOwnProperty("x") === false);
assert(o.hasOwnProperty("y") === false);
assert(o.hasOwnProperty("z") === true);
assert(Object.getOwnPropertyNames(o).length === 1);
assert(delete o.z === true);
assert(o.hasOwnProperty("x") === false);
assert(o.hasOwnProperty("y") === false);
assert(o.hasOwnProperty("z") === false);
assert(Object.getOwnPropertyNames(o).length === 0);
a = [3, 5, 7];
assert(Object.getOwnPropertyNames(a).length === 4);
assert(delete a[0] === true);
assert(a.hasOwnProperty(0) === false);
assert(a.hasOwnProperty(1) === true);
assert(a.hasOwnProperty(2) === true);
assert(Object.getOwnPropertyNames(a).length === 3);
assert(delete a[1] === true);
assert(a.hasOwnProperty(0) === false);
assert(a.hasOwnProperty(1) === false);
assert(a.hasOwnProperty(2) === true);
assert(Object.getOwnPropertyNames(a).length === 2);
assert(delete a[2] === true);
assert(a.hasOwnProperty(0) === false);
assert(a.hasOwnProperty(1) === false);
assert(a.hasOwnProperty(2) === false);
assert(Object.getOwnPropertyNames(a).length === 1);
q = {};
Object.defineProperty(q, "foo", { value: 1, writable: false, enumerable: false });
assert(q.foo === 1);
assert(delete q.foo === false);
assert(q.hasOwnProperty("foo") === true);
console.log("PASS");
} catch (e) {
console.log("FAIL: " + e);
}
|