mirror of
https://github.com/nodejs/node.git
synced 2026-11-25 23:01:06 -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>
43 lines
914 B
JavaScript
43 lines
914 B
JavaScript
// Flags: --expose-internals
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
const {
|
|
assertIsObject,
|
|
assertWithinRange,
|
|
} = require('internal/http2/util');
|
|
|
|
[
|
|
undefined,
|
|
{},
|
|
Object.create(null),
|
|
new Date(),
|
|
new (class Foo {})()
|
|
].forEach((i) => {
|
|
assertIsObject(i, 'foo', 'Object');
|
|
});
|
|
|
|
[
|
|
1,
|
|
false,
|
|
'hello',
|
|
NaN,
|
|
Infinity,
|
|
[],
|
|
[{}]
|
|
].forEach((i) => {
|
|
common.expectsError(() => assertIsObject(i, 'foo', 'Object'),
|
|
{
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
message: /^The "foo" argument must be of type Object$/
|
|
});
|
|
});
|
|
|
|
assertWithinRange('foo', 1, 0, 2);
|
|
|
|
common.expectsError(() => assertWithinRange('foo', 1, 2, 3),
|
|
{
|
|
code: 'ERR_HTTP2_INVALID_SETTING_VALUE',
|
|
message: /^Invalid value for setting "foo": 1$/
|
|
});
|