You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

31 lines
945 B

'use strict';
require('../common');
const constants = process.binding('constants');
const assert = require('assert');
assert.deepStrictEqual(
Object.keys(constants).sort(), ['crypto', 'fs', 'os', 'zlib']
);
assert.deepStrictEqual(
Object.keys(constants.os).sort(), ['UV_UDP_REUSEADDR', 'dlopen', 'errno',
'signals']
);
// Make sure all the constants objects don't inherit from Object.prototype
const inheritedProperties = Object.getOwnPropertyNames(Object.prototype);
function test(obj) {
assert(obj);
assert.strictEqual(Object.prototype.toString.call(obj), '[object Object]');
assert.strictEqual(Object.getPrototypeOf(obj), null);
inheritedProperties.forEach((property) => {
assert.strictEqual(property in obj, false);
});
}
[
constants, constants.crypto, constants.fs, constants.os, constants.zlib,
constants.os.dlopen, constants.os.errno, constants.os.signals
].forEach(test);