mirror of
https://github.com/nodejs/node.git
synced 2026-11-26 21:58:26 -05:00
There is actually no reason to use `assert.doesNotThrow()` in the tests. If a test throws, just let the error bubble up right away instead of first catching it and then rethrowing it. Backport-PR-URL: https://github.com/nodejs/node/pull/19244 PR-URL: https://github.com/nodejs/node/pull/18669 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
34 lines
834 B
JavaScript
34 lines
834 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const {
|
|
getSystemErrorName,
|
|
_errnoException
|
|
} = require('util');
|
|
|
|
const uv = process.binding('uv');
|
|
const keys = Object.keys(uv);
|
|
|
|
keys.forEach((key) => {
|
|
if (!key.startsWith('UV_'))
|
|
return;
|
|
|
|
const err = _errnoException(uv[key], 'test');
|
|
const name = uv.errname(uv[key]);
|
|
assert.strictEqual(getSystemErrorName(uv[key]), name);
|
|
assert.strictEqual(err.code, name);
|
|
assert.strictEqual(err.code, err.errno);
|
|
assert.strictEqual(err.message, `test ${name}`);
|
|
});
|
|
|
|
[0, 1, 'test', {}, [], Infinity, -Infinity, NaN].forEach((key) => {
|
|
common.expectsError(
|
|
() => _errnoException(key),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
type: TypeError,
|
|
message: 'The "err" argument must be of type negative number'
|
|
});
|
|
});
|