forked from nodejs/node-addon-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubscript_operator.js
More file actions
19 lines (15 loc) · 955 Bytes
/
subscript_operator.js
File metadata and controls
19 lines (15 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'use strict';
const buildType = process.config.target_defaults.default_configuration;
const assert = require('assert');
test(require(`../build/${buildType}/binding.node`));
test(require(`../build/${buildType}/binding_noexcept.node`));
function test(binding) {
function testProperty(obj, key, value, nativeGetProperty, nativeSetProperty) {
nativeSetProperty(obj, key, value);
assert.strictEqual(nativeGetProperty(obj, key), value);
}
testProperty({}, 'key', 'value', binding.object.subscriptGetWithCStyleString, binding.object.subscriptSetWithCStyleString);
testProperty({ key: 'override me' }, 'key', 'value', binding.object.subscriptGetWithCppStyleString, binding.object.subscriptSetWithCppStyleString);
testProperty({}, 0, 'value', binding.object.subscriptGetAtIndex, binding.object.subscriptSetAtIndex);
testProperty({ key: 'override me' }, 0, 'value', binding.object.subscriptGetAtIndex, binding.object.subscriptSetAtIndex);
}