node/test/parallel/test-uv-binding-constant.js
Joyee Cheung c56972779b
src: expose uv.errmap to binding
Add a errno -> [error code, uv error message] map to the uv binding
so the error message can be assembled in the JS layer.

PR-URL: https://github.com/nodejs/node/pull/17338
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2017-12-28 03:08:25 +08:00

19 lines
449 B
JavaScript

'use strict';
require('../common');
const assert = require('assert');
const uv = process.binding('uv');
// Ensures that the `UV_...` values in process.binding('uv')
// are constants.
const keys = Object.keys(uv);
keys.forEach((key) => {
if (key.startsWith('UV_')) {
const val = uv[key];
assert.throws(() => uv[key] = 1,
/^TypeError: Cannot assign to read only property/);
assert.strictEqual(uv[key], val);
}
});