11cb0ef41Sopenharmony_ci// Flags: --expose-internals 21cb0ef41Sopenharmony_ci'use strict'; 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_cirequire('../common'); 51cb0ef41Sopenharmony_ciconst assert = require('assert'); 61cb0ef41Sopenharmony_ciconst { validatePort } = require('internal/validators'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_cifor (let n = 0; n <= 0xFFFF; n++) { 91cb0ef41Sopenharmony_ci validatePort(n); 101cb0ef41Sopenharmony_ci validatePort(`${n}`); 111cb0ef41Sopenharmony_ci validatePort(`0x${n.toString(16)}`); 121cb0ef41Sopenharmony_ci validatePort(`0o${n.toString(8)}`); 131cb0ef41Sopenharmony_ci validatePort(`0b${n.toString(2)}`); 141cb0ef41Sopenharmony_ci} 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci[ 171cb0ef41Sopenharmony_ci -1, 'a', {}, [], false, true, 181cb0ef41Sopenharmony_ci 0xFFFF + 1, Infinity, -Infinity, NaN, 191cb0ef41Sopenharmony_ci undefined, null, '', ' ', 1.1, '0x', 201cb0ef41Sopenharmony_ci '-0x1', '-0o1', '-0b1', '0o', '0b', 211cb0ef41Sopenharmony_ci].forEach((i) => assert.throws(() => validatePort(i), { 221cb0ef41Sopenharmony_ci code: 'ERR_SOCKET_BAD_PORT' 231cb0ef41Sopenharmony_ci})); 24