-
-
Notifications
You must be signed in to change notification settings - Fork 500
Expand file tree
/
Copy pathobject_deprecated.js
More file actions
42 lines (33 loc) · 1.28 KB
/
object_deprecated.js
File metadata and controls
42 lines (33 loc) · 1.28 KB
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
'use strict';
const assert = require('assert');
module.exports = require('../common').runTest(test);
function test (binding) {
if (!('object_deprecated' in binding)) {
return;
}
function assertPropertyIsNot (obj, key, attribute) {
const propDesc = Object.getOwnPropertyDescriptor(obj, key);
assert.ok(propDesc);
assert.ok(!propDesc[attribute]);
}
function testDefineProperties (nameType) {
const obj = {};
binding.object.defineProperties(obj, nameType);
assertPropertyIsNot(obj, 'readonlyAccessor', 'enumerable');
assertPropertyIsNot(obj, 'readonlyAccessor', 'configurable');
assert.strictEqual(obj.readonlyAccessor, true);
assertPropertyIsNot(obj, 'readwriteAccessor', 'enumerable');
assertPropertyIsNot(obj, 'readwriteAccessor', 'configurable');
obj.readwriteAccessor = false;
assert.strictEqual(obj.readwriteAccessor, false);
obj.readwriteAccessor = true;
assert.strictEqual(obj.readwriteAccessor, true);
assertPropertyIsNot(obj, 'function', 'writable');
assertPropertyIsNot(obj, 'function', 'enumerable');
assertPropertyIsNot(obj, 'function', 'configurable');
assert.strictEqual(obj.function(), true);
}
testDefineProperties('literal');
testDefineProperties('string');
testDefineProperties('value');
}