node/test/parallel/test-uv-errmap.js
eladkeyshawn 802171057f
util: add getSystemErrorMap() impl
PR-URL: https://github.com/nodejs/node/pull/38101
Fixes: https://github.com/nodejs/node/issues/37951
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-04-13 08:44:26 -07:00

25 lines
538 B
JavaScript

// Flags: --expose-internals
'use strict';
require('../common');
const assert = require('assert');
const {
getSystemErrorMap,
_errnoException
} = require('util');
const { internalBinding } = require('internal/test/binding');
const uv = internalBinding('uv');
const uvKeys = Object.keys(uv);
const errMap = getSystemErrorMap();
uvKeys.forEach((key) => {
if (!key.startsWith('UV_'))
return;
const err = _errnoException(uv[key]);
const name = uv.errname(uv[key]);
assert.strictEqual(errMap.get(err.errno)[0], name);
});