1// Flags: --expose-internals 2'use strict'; 3 4const common = require('../common'); 5const assert = require('assert'); 6const { 7 assertIsObject, 8 assertWithinRange, 9} = require('internal/http2/util'); 10 11[ 12 undefined, 13 {}, 14 Object.create(null), 15 new Date(), 16 new (class Foo {})(), 17].forEach((input) => { 18 assertIsObject(input, 'foo', 'Object'); 19}); 20 21[ 22 1, 23 false, 24 'hello', 25 NaN, 26 Infinity, 27 [], 28 [{}], 29].forEach((input) => { 30 assert.throws( 31 () => assertIsObject(input, 'foo', 'Object'), 32 { 33 code: 'ERR_INVALID_ARG_TYPE', 34 message: 'The "foo" argument must be of type object.' + 35 common.invalidArgTypeHelper(input) 36 }); 37}); 38 39assertWithinRange('foo', 1, 0, 2); 40 41assert.throws(() => assertWithinRange('foo', 1, 2, 3), 42 { 43 code: 'ERR_HTTP2_INVALID_SETTING_VALUE', 44 message: 'Invalid value for setting "foo": 1' 45 }); 46