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
77
78
79
80
81
82
83
84
85
86
87
88
89
|
// |reftest| skip-if(!this.hasOwnProperty("Record"))
var rec = Record({ x: 1, y: 2, a: 3 });
var desc = Object.getOwnPropertyDescriptor(rec, "x");
assertEq(desc.value, 1);
assertEq(desc.writable, false);
assertEq(desc.enumerable, true);
assertEq(desc.configurable, false);
assertEq(Object.getOwnPropertyDescriptor(rec, "z"), undefined);
var recO = Object(rec);
assertThrowsInstanceOf(
() => Object.defineProperty(rec, "x", { value: 1 }),
TypeError,
"#{ \"a\": 3, \"x\": 1, \"y\": 2 } is not a non-null object"
);
assertThrowsInstanceOf(
() => Object.defineProperty(recO, "b", {}),
TypeError,
"can't define property \"b\": Record is not extensible"
);
assertThrowsInstanceOf(
() => Object.defineProperty(recO, Symbol(), {}),
TypeError,
"can't define property \"b\": Record is not extensible"
);
assertThrowsInstanceOf(
() => Object.defineProperty(recO, "x", { value: 2 }),
TypeError,
'"x" is read-only'
);
Object.defineProperty(recO, "x", { value: 1 });
assertThrowsInstanceOf(
() => Object.defineProperty(recO, "x", { value: 2, writable: true }),
TypeError,
'Invalid record property descriptor'
);
assertThrowsInstanceOf(
() => Object.defineProperty(recO, "x", { value: 2, enumerable: false }),
TypeError,
'Invalid record property descriptor'
);
assertThrowsInstanceOf(
() => Object.defineProperty(recO, "x", { value: 2, configurable: true }),
TypeError,
'Invalid record property descriptor'
);
assertEq(Object.prototype.propertyIsEnumerable.call(rec, "x"), true);
assertEq(Object.prototype.propertyIsEnumerable.call(rec, "x"), true);
assertEq(Object.prototype.propertyIsEnumerable.call(rec, "w"), false);
assertEq(Object.prototype.propertyIsEnumerable.call(rec, "w"), false);
assertEq(Object.prototype.propertyIsEnumerable.call(recO, "x"), true);
assertEq(Object.prototype.propertyIsEnumerable.call(recO, "x"), true);
assertEq(Object.prototype.propertyIsEnumerable.call(recO, "w"), false);
assertEq(Object.prototype.propertyIsEnumerable.call(recO, "w"), false);
assertEq(Object.prototype.hasOwnProperty.call(rec, "x"), true);
assertEq(Object.prototype.hasOwnProperty.call(rec, "x"), true);
assertEq(Object.prototype.hasOwnProperty.call(rec, "w"), false);
assertEq(Object.prototype.hasOwnProperty.call(rec, "w"), false);
assertEq(Object.prototype.hasOwnProperty.call(recO, "x"), true);
assertEq(Object.prototype.hasOwnProperty.call(recO, "x"), true);
assertEq(Object.prototype.hasOwnProperty.call(recO, "w"), false);
assertEq(Object.prototype.hasOwnProperty.call(recO, "w"), false);
assertEq("x" in recO, true);
assertEq("w" in recO, false);
assertEq(delete rec.x, false);
assertEq(delete rec.x, false);
assertEq(delete rec.w, true);
assertEq(delete rec.w, true);
assertEq(delete recO.x, false);
assertEq(delete recO.x, false);
assertEq(delete recO.w, true);
assertEq(delete recO.w, true);
if (typeof reportCompare === "function") reportCompare(0, 0);
|