11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ciconst net = require('net'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst truthyValues = [true, 1, 'true', {}, []]; 81cb0ef41Sopenharmony_ciconst falseyValues = [false, 0, '']; 91cb0ef41Sopenharmony_ciconst genSetNoDelay = (desiredArg) => (enable) => { 101cb0ef41Sopenharmony_ci assert.strictEqual(enable, desiredArg); 111cb0ef41Sopenharmony_ci}; 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_cifor (const value of truthyValues) { 141cb0ef41Sopenharmony_ci const server = net.createServer(); 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ci server.listen(0, common.mustCall(function() { 171cb0ef41Sopenharmony_ci const port = server.address().port; 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci const client = net.connect( 201cb0ef41Sopenharmony_ci { port, noDelay: value }, 211cb0ef41Sopenharmony_ci common.mustCall(() => client.end()) 221cb0ef41Sopenharmony_ci ); 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci client._handle.setNoDelay = common.mustCall(genSetNoDelay(true)); 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ci client.on('end', common.mustCall(function() { 271cb0ef41Sopenharmony_ci server.close(); 281cb0ef41Sopenharmony_ci })); 291cb0ef41Sopenharmony_ci })); 301cb0ef41Sopenharmony_ci} 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_cifor (const value of falseyValues) { 331cb0ef41Sopenharmony_ci const server = net.createServer(); 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ci server.listen(0, common.mustCall(function() { 361cb0ef41Sopenharmony_ci const port = server.address().port; 371cb0ef41Sopenharmony_ci 381cb0ef41Sopenharmony_ci const client = net.connect( 391cb0ef41Sopenharmony_ci { port, noDelay: value }, 401cb0ef41Sopenharmony_ci common.mustCall(() => client.end()) 411cb0ef41Sopenharmony_ci ); 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci client._handle.setNoDelay = common.mustNotCall(); 441cb0ef41Sopenharmony_ci 451cb0ef41Sopenharmony_ci client.on('end', common.mustCall(function() { 461cb0ef41Sopenharmony_ci server.close(); 471cb0ef41Sopenharmony_ci })); 481cb0ef41Sopenharmony_ci })); 491cb0ef41Sopenharmony_ci} 50