From b70ba5a49edd64280d3e4b2a1f101cf8da8fa297 Mon Sep 17 00:00:00 2001 From: Massimo Andreasi Bassi Date: Mon, 21 Nov 2016 09:51:25 -0500 Subject: [PATCH] Missing property `socket.destroyed` (#12639) * Missing property `socket.destroyed` https://nodejs.org/dist/latest-v4.x/docs/api/net.html#net_socket_destroyed * Added socket.destroyed tests * Moved socket.destroyed to index --- node/index.d.ts | 1 + node/node-tests.ts | 73 ++++++++++++++++++++++++---------------------- 2 files changed, 39 insertions(+), 35 deletions(-) diff --git a/node/index.d.ts b/node/index.d.ts index ea81e61147..ea22eb6486 100644 --- a/node/index.d.ts +++ b/node/index.d.ts @@ -1851,6 +1851,7 @@ declare module "net" { localPort: number; bytesRead: number; bytesWritten: number; + destroyed: boolean; // Extended base methods end(): void; diff --git a/node/node-tests.ts b/node/node-tests.ts index 9873b19e72..9116125b1e 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -47,33 +47,33 @@ namespace global_tests { namespace assert_tests { { assert(1 + 1 - 2 === 0, "The universe isn't how it should."); - + assert.deepEqual({ x: { y: 3 } }, { x: { y: 3 } }, "DEEP WENT DERP"); - + assert.deepStrictEqual({ a: 1 }, { a: 1 }, "uses === comparator"); - + assert.doesNotThrow(() => { const b = false; if (b) { throw "a hammer at your face"; } }, undefined, "What the...*crunch*"); - + assert.equal(3, "3", "uses == comparator"); assert.fail(1, 2, undefined, '>'); - + assert.ifError(0); - + assert.notDeepStrictEqual({ x: { y: "3" } }, { x: { y: 3 } }, "uses !== comparator"); - + assert.notEqual(1, 2, "uses != comparator"); - + assert.notStrictEqual(2, "2", "uses === comparator"); - + assert.ok(true); assert.ok(1); - + assert.strictEqual(1, 1, "uses === comparator"); - + assert.throws(() => { throw "a hammer at your face"; }, undefined, "DODGED IT"); } } @@ -153,21 +153,21 @@ namespace fs_tests { fs.writeFile("thebible.txt", "Do unto others as you would have them do unto you.", assert.ifError); - + fs.write(1234, "test"); - + fs.writeFile("Harry Potter", "\"You be wizzing, Harry,\" jived Dumbledore.", { encoding: "ascii" }, - assert.ifError); + assert.ifError); } { var content: string; var buffer: Buffer; - + content = fs.readFileSync('testfile', 'utf8'); content = fs.readFileSync('testfile', { encoding: 'utf8' }); buffer = fs.readFileSync('testfile'); @@ -177,7 +177,7 @@ namespace fs_tests { fs.readFile('testfile', (err, data) => buffer = data); fs.readFile('testfile', { flag: 'r' }, (err, data) => buffer = data); } - + { var errno: number; fs.readFile('testfile', (err, data) => { @@ -186,28 +186,28 @@ namespace fs_tests { } }); } - + { fs.mkdtemp('/tmp/foo-', (err, folder) => { console.log(folder); // Prints: /tmp/foo-itXde2 }); } - + { var tempDir: string; tempDir = fs.mkdtempSync('/tmp/foo-'); } - + { fs.watch('/tmp/foo-', (event, filename) => { console.log(event, filename); }); - + fs.watch('/tmp/foo-', 'utf8', (event, filename) => { console.log(event, filename); }); - + fs.watch('/tmp/foo-', { recursive: true, persistent: true, @@ -216,22 +216,22 @@ namespace fs_tests { console.log(event, filename); }); } - + { fs.access('/path/to/folder', (err) => { }); - + fs.access(Buffer.from(''), (err) => { }); - + fs.access('/path/to/folder', fs.constants.F_OK | fs.constants.R_OK, (err) => { }); - + fs.access(Buffer.from(''), fs.constants.F_OK | fs.constants.R_OK, (err) => { }); - + fs.accessSync('/path/to/folder'); - + fs.accessSync(Buffer.from('')); - + fs.accessSync('path/to/folder', fs.constants.W_OK | fs.constants.X_OK); - + fs.accessSync(Buffer.from(''), fs.constants.W_OK | fs.constants.X_OK); } } @@ -400,14 +400,14 @@ function bufferTests() { namespace url_tests { { url.format(url.parse('http://www.example.com/xyz')); - + // https://google.com/search?q=you're%20a%20lizard%2C%20gary url.format({ protocol: 'https', host: "google.com", pathname: 'search', query: { q: "you're a lizard, gary" } - }); + }); } { @@ -424,7 +424,7 @@ namespace util_tests { { // Old and new util.inspect APIs util.inspect(["This is nice"], false, 5); - util.inspect(["This is nice"], { colors: true, depth: 5, customInspect: false }); + util.inspect(["This is nice"], { colors: true, depth: 5, customInspect: false }); } } @@ -772,7 +772,7 @@ namespace tls_tests { let _response: Buffer = response; }) _TLSSocket = _TLSSocket.prependOnceListener("secureConnect", () => { }); - } + } } //////////////////////////////////////////////////// @@ -1315,7 +1315,7 @@ namespace string_decoder_tests { namespace child_process_tests { { childProcess.exec("echo test"); - childProcess.spawnSync("echo test"); + childProcess.spawnSync("echo test"); } { @@ -1574,7 +1574,7 @@ namespace process_tests { { var eventEmitter: events.EventEmitter; eventEmitter = process; // Test that process implements EventEmitter... - + var _p: NodeJS.Process = process; _p = p; } @@ -1770,6 +1770,9 @@ namespace net_tests { str = host; }) _socket = _socket.prependOnceListener("timeout", () => { }) + + bool = _socket.destroyed; + _socket.destroy(); } {