Skip to content

Commit 5c9aa18

Browse files
bengladdaleax
authored andcommitted
constants: errors -> errno
lib/constants.js was incorrectly copying the constants from the binding, by copying from `contants.os.errors` instead of `constants.os.errno`. PR-URL: #9349 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Prince John Wesley <[email protected]> Reviewed-By: Ron Korving <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 74c3283 commit 5c9aa18

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

lib/constants.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// are most relevant.
66
const constants = process.binding('constants');
77
Object.assign(exports,
8-
constants.os.errors,
8+
constants.os.errno,
99
constants.os.signals,
1010
constants.fs,
1111
constants.crypto);

test/parallel/test-constants.js

+21-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
11
'use strict';
22

33
require('../common');
4-
const constants = process.binding('constants');
4+
const binding = process.binding('constants');
5+
const constants = require('constants');
56
const assert = require('assert');
67

7-
assert.ok(constants);
8-
assert.ok(constants.os);
9-
assert.ok(constants.os.signals);
10-
assert.ok(constants.os.errno);
11-
assert.ok(constants.fs);
12-
assert.ok(constants.crypto);
8+
assert.ok(binding);
9+
assert.ok(binding.os);
10+
assert.ok(binding.os.signals);
11+
assert.ok(binding.os.errno);
12+
assert.ok(binding.fs);
13+
assert.ok(binding.crypto);
14+
15+
['os', 'fs', 'crypto'].forEach((l) => {
16+
Object.keys(binding[l]).forEach((k) => {
17+
if (typeof binding[l][k] === 'object') { // errno and signals
18+
Object.keys(binding[l][k]).forEach((j) => {
19+
assert.strictEqual(binding[l][k][j], constants[j]);
20+
});
21+
}
22+
if (l !== 'os') { // top level os constant isn't currently copied
23+
assert.strictEqual(binding[l][k], constants[k]);
24+
}
25+
});
26+
});

0 commit comments

Comments
 (0)