2017-09-21 10:07:56 -07:00
|
|
|
// Flags: --expose-internals
|
2017-07-17 10:29:42 -07:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
2019-12-25 18:02:16 +01:00
|
|
|
const assert = require('assert');
|
2017-07-17 10:29:42 -07:00
|
|
|
const {
|
|
|
|
assertIsObject,
|
|
|
|
assertWithinRange,
|
|
|
|
} = require('internal/http2/util');
|
|
|
|
|
|
|
|
[
|
|
|
|
undefined,
|
|
|
|
{},
|
2023-01-09 21:38:36 -08:00
|
|
|
{ __proto__: null },
|
2017-07-17 10:29:42 -07:00
|
|
|
new Date(),
|
2021-03-26 08:51:08 -07:00
|
|
|
new (class Foo {})(),
|
2018-03-19 13:43:24 +01:00
|
|
|
].forEach((input) => {
|
|
|
|
assertIsObject(input, 'foo', 'Object');
|
2017-07-17 10:29:42 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
[
|
|
|
|
1,
|
|
|
|
false,
|
|
|
|
'hello',
|
|
|
|
NaN,
|
|
|
|
Infinity,
|
|
|
|
[],
|
2021-03-26 08:51:08 -07:00
|
|
|
[{}],
|
2018-03-19 13:33:46 +01:00
|
|
|
].forEach((input) => {
|
2019-12-25 18:02:16 +01:00
|
|
|
assert.throws(
|
2019-09-23 08:17:25 +02:00
|
|
|
() => assertIsObject(input, 'foo', 'Object'),
|
|
|
|
{
|
|
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
|
|
message: 'The "foo" argument must be of type object.' +
|
|
|
|
common.invalidArgTypeHelper(input)
|
|
|
|
});
|
2017-07-17 10:29:42 -07:00
|
|
|
});
|
|
|
|
|
2018-02-09 02:32:04 +01:00
|
|
|
assertWithinRange('foo', 1, 0, 2);
|
2017-07-17 10:29:42 -07:00
|
|
|
|
2019-12-25 18:02:16 +01:00
|
|
|
assert.throws(() => assertWithinRange('foo', 1, 2, 3),
|
|
|
|
{
|
|
|
|
code: 'ERR_HTTP2_INVALID_SETTING_VALUE',
|
|
|
|
message: 'Invalid value for setting "foo": 1'
|
|
|
|
});
|