mirror of
https://github.com/nodejs/node.git
synced 2025-05-10 20:34:33 +00:00

PR-URL: https://github.com/nodejs/node/pull/22163 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me>
33 lines
661 B
JavaScript
33 lines
661 B
JavaScript
// Flags: --expose-internals
|
|
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const net = require('net');
|
|
|
|
const { internalBinding } = require('internal/test/binding');
|
|
const { UV_EOF } = internalBinding('uv');
|
|
|
|
const s = new net.Socket({
|
|
handle: {
|
|
readStart: function() {
|
|
setImmediate(() => this.onread(UV_EOF, null));
|
|
},
|
|
close: (cb) => setImmediate(cb)
|
|
},
|
|
writable: false
|
|
});
|
|
assert.strictEqual(s, s.resume());
|
|
|
|
const events = [];
|
|
|
|
s.on('end', () => {
|
|
events.push('end');
|
|
});
|
|
s.on('close', () => {
|
|
events.push('close');
|
|
});
|
|
|
|
process.on('exit', () => {
|
|
assert.deepStrictEqual(events, [ 'end', 'close' ]);
|
|
});
|