Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// are most relevant.
const constants = process.binding('constants');
Object.assign(exports,
constants.os.errors,
constants.os.errno,
constants.os.signals,
constants.fs,
constants.crypto);
28 changes: 21 additions & 7 deletions test/parallel/test-constants.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
'use strict';

require('../common');
const constants = process.binding('constants');
const binding = process.binding('constants');
const constants = require('constants');
const assert = require('assert');

assert.ok(constants);
assert.ok(constants.os);
assert.ok(constants.os.signals);
assert.ok(constants.os.errno);
assert.ok(constants.fs);
assert.ok(constants.crypto);
assert.ok(binding);
assert.ok(binding.os);
assert.ok(binding.os.signals);
assert.ok(binding.os.errno);
assert.ok(binding.fs);
assert.ok(binding.crypto);

['os', 'fs', 'crypto'].forEach((l) => {
Object.keys(binding[l]).forEach((k) => {
if (typeof binding[l][k] === 'object') { //errno and signals
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny tiny nit: space after // in the comment.

Object.keys(binding[l][k]).forEach((j) => {
assert.strictEqual(binding[l][k][j], constants[j]);
});
}
if (l !== 'os') { // top level os constant isn't currently copied
assert.strictEqual(binding[l][k], constants[k]);
}
});
});