| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -205,7 +205,7 @@ export default [ | |||
| 205 | 205 | Array.from({ length: 13 }, (_, i) => String.fromCharCode(0x61 + i, 42)).join(',') | |
| 206 | 206 | },n*,${ | |
| 207 | 207 | // 0x61 is code for 'a', this generates a string enumerating latin letters: 'z*,y*,…' | |
| 208 | - Array.from({ length: 7 }, (_, i) => String.fromCharCode(0x61 + 25 - i, 42)).join(',') | ||
| 208 | + Array.from({ length: 8 }, (_, i) => String.fromCharCode(0x61 + 25 - i, 42)).join(',') | ||
| 209 | 209 | }}.{js,mjs,cjs}`, | |
| 210 | 210 | ], | |
| 211 | 211 | rules: { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,7 +7,7 @@ const net = require('net'); | |||
| 7 | 7 | ||
| 8 | 8 | const HEAD = Buffer.alloc(1024 * 1024, 0); | |
| 9 | 9 | ||
| 10 | - const server = net.createServer((serverSock) => { | ||
| 10 | + const server = net.createServer(common.mustCallAtLeast((serverSock) => { | ||
| 11 | 11 | let recvLen = 0; | |
| 12 | 12 | const recv = []; | |
| 13 | 13 | serverSock.on('data', common.mustCallAtLeast((chunk) => { | |
@@ -21,7 +21,7 @@ const server = net.createServer((serverSock) => { | |||
| 21 | 21 | process.exit(0); | |
| 22 | 22 | } | |
| 23 | 23 | }, 1)); | |
| 24 | - }) | ||
| 24 | + })) | ||
| 25 | 25 | .listen(client); | |
| 26 | 26 | ||
| 27 | 27 | function client() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,11 +2,7 @@ | |||
| 2 | 2 | 'use strict'; | |
| 3 | 3 | ||
| 4 | 4 | const common = require('../common'); | |
| 5 | - const { | ||
| 6 | - ok, | ||
| 7 | - strictEqual, | ||
| 8 | - throws, | ||
| 9 | - } = require('assert'); | ||
| 5 | + const assert = require('assert'); | ||
| 10 | 6 | const { | |
| 11 | 7 | SocketAddress, | |
| 12 | 8 | } = require('net'); | |
@@ -26,19 +22,19 @@ describe('net.SocketAddress...', () => { | |||
| 26 | 22 | ||
| 27 | 23 | it('is cloneable', () => { | |
| 28 | 24 | const sa = new SocketAddress(); | |
| 29 | - strictEqual(sa.address, '127.0.0.1'); | ||
| 30 | - strictEqual(sa.port, 0); | ||
| 31 | - strictEqual(sa.family, 'ipv4'); | ||
| 32 | - strictEqual(sa.flowlabel, 0); | ||
| 25 | + assert.strictEqual(sa.address, '127.0.0.1'); | ||
| 26 | + assert.strictEqual(sa.port, 0); | ||
| 27 | + assert.strictEqual(sa.family, 'ipv4'); | ||
| 28 | + assert.strictEqual(sa.flowlabel, 0); | ||
| 33 | 29 | ||
| 34 | 30 | const mc = new MessageChannel(); | |
| 35 | 31 | mc.port1.onmessage = common.mustCall(({ data }) => { | |
| 36 | - ok(SocketAddress.isSocketAddress(data)); | ||
| 32 | + assert.ok(SocketAddress.isSocketAddress(data)); | ||
| 37 | 33 | ||
| 38 | - strictEqual(data.address, '127.0.0.1'); | ||
| 39 | - strictEqual(data.port, 0); | ||
| 40 | - strictEqual(data.family, 'ipv4'); | ||
| 41 | - strictEqual(data.flowlabel, 0); | ||
| 34 | + assert.strictEqual(data.address, '127.0.0.1'); | ||
| 35 | + assert.strictEqual(data.port, 0); | ||
| 36 | + assert.strictEqual(data.family, 'ipv4'); | ||
| 37 | + assert.strictEqual(data.flowlabel, 0); | ||
| 42 | 38 | ||
| 43 | 39 | mc.port1.close(); | |
| 44 | 40 | }); | |
@@ -47,80 +43,80 @@ describe('net.SocketAddress...', () => { | |||
| 47 | 43 | ||
| 48 | 44 | it('has reasonable defaults', () => { | |
| 49 | 45 | const sa = new SocketAddress({}); | |
| 50 | - strictEqual(sa.address, '127.0.0.1'); | ||
| 51 | - strictEqual(sa.port, 0); | ||
| 52 | - strictEqual(sa.family, 'ipv4'); | ||
| 53 | - strictEqual(sa.flowlabel, 0); | ||
| 46 | + assert.strictEqual(sa.address, '127.0.0.1'); | ||
| 47 | + assert.strictEqual(sa.port, 0); | ||
| 48 | + assert.strictEqual(sa.family, 'ipv4'); | ||
| 49 | + assert.strictEqual(sa.flowlabel, 0); | ||
| 54 | 50 | }); | |
| 55 | 51 | ||
| 56 | 52 | it('interprets simple ipv4 correctly', () => { | |
| 57 | 53 | const sa = new SocketAddress({ | |
| 58 | 54 | address: '123.123.123.123', | |
| 59 | 55 | }); | |
| 60 | - strictEqual(sa.address, '123.123.123.123'); | ||
| 61 | - strictEqual(sa.port, 0); | ||
| 62 | - strictEqual(sa.family, 'ipv4'); | ||
| 63 | - strictEqual(sa.flowlabel, 0); | ||
| 56 | + assert.strictEqual(sa.address, '123.123.123.123'); | ||
| 57 | + assert.strictEqual(sa.port, 0); | ||
| 58 | + assert.strictEqual(sa.family, 'ipv4'); | ||
| 59 | + assert.strictEqual(sa.flowlabel, 0); | ||
| 64 | 60 | }); | |
| 65 | 61 | ||
| 66 | 62 | it('sets the port correctly', () => { | |
| 67 | 63 | const sa = new SocketAddress({ | |
| 68 | 64 | address: '123.123.123.123', | |
| 69 | 65 | port: 80 | |
| 70 | 66 | }); | |
| 71 | - strictEqual(sa.address, '123.123.123.123'); | ||
| 72 | - strictEqual(sa.port, 80); | ||
| 73 | - strictEqual(sa.family, 'ipv4'); | ||
| 74 | - strictEqual(sa.flowlabel, 0); | ||
| 67 | + assert.strictEqual(sa.address, '123.123.123.123'); | ||
| 68 | + assert.strictEqual(sa.port, 80); | ||
| 69 | + assert.strictEqual(sa.family, 'ipv4'); | ||
| 70 | + assert.strictEqual(sa.flowlabel, 0); | ||
| 75 | 71 | }); | |
| 76 | 72 | ||
| 77 | 73 | it('interprets simple ipv6 correctly', () => { | |
| 78 | 74 | const sa = new SocketAddress({ | |
| 79 | 75 | family: 'ipv6' | |
| 80 | 76 | }); | |
| 81 | - strictEqual(sa.address, '::'); | ||
| 82 | - strictEqual(sa.port, 0); | ||
| 83 | - strictEqual(sa.family, 'ipv6'); | ||
| 84 | - strictEqual(sa.flowlabel, 0); | ||
| 77 | + assert.strictEqual(sa.address, '::'); | ||
| 78 | + assert.strictEqual(sa.port, 0); | ||
| 79 | + assert.strictEqual(sa.family, 'ipv6'); | ||
| 80 | + assert.strictEqual(sa.flowlabel, 0); | ||
| 85 | 81 | }); | |
| 86 | 82 | ||
| 87 | 83 | it('uses the flowlabel correctly', () => { | |
| 88 | 84 | const sa = new SocketAddress({ | |
| 89 | 85 | family: 'ipv6', | |
| 90 | 86 | flowlabel: 1, | |
| 91 | 87 | }); | |
| 92 | - strictEqual(sa.address, '::'); | ||
| 93 | - strictEqual(sa.port, 0); | ||
| 94 | - strictEqual(sa.family, 'ipv6'); | ||
| 95 | - strictEqual(sa.flowlabel, 1); | ||
| 88 | + assert.strictEqual(sa.address, '::'); | ||
| 89 | + assert.strictEqual(sa.port, 0); | ||
| 90 | + assert.strictEqual(sa.family, 'ipv6'); | ||
| 91 | + assert.strictEqual(sa.flowlabel, 1); | ||
| 96 | 92 | }); | |
| 97 | 93 | ||
| 98 | 94 | it('validates input correctly', () => { | |
| 99 | 95 | [1, false, 'hello'].forEach((i) => { | |
| 100 | - throws(() => new SocketAddress(i), { | ||
| 96 | + assert.throws(() => new SocketAddress(i), { | ||
| 101 | 97 | code: 'ERR_INVALID_ARG_TYPE' | |
| 102 | 98 | }); | |
| 103 | 99 | }); | |
| 104 | 100 | ||
| 105 | 101 | [1, false, {}, [], 'test'].forEach((family) => { | |
| 106 | - throws(() => new SocketAddress({ family }), { | ||
| 102 | + assert.throws(() => new SocketAddress({ family }), { | ||
| 107 | 103 | code: 'ERR_INVALID_ARG_VALUE' | |
| 108 | 104 | }); | |
| 109 | 105 | }); | |
| 110 | 106 | ||
| 111 | 107 | [1, false, {}, []].forEach((address) => { | |
| 112 | - throws(() => new SocketAddress({ address }), { | ||
| 108 | + assert.throws(() => new SocketAddress({ address }), { | ||
| 113 | 109 | code: 'ERR_INVALID_ARG_TYPE' | |
| 114 | 110 | }); | |
| 115 | 111 | }); | |
| 116 | 112 | ||
| 117 | 113 | [-1, false, {}, []].forEach((port) => { | |
| 118 | - throws(() => new SocketAddress({ port }), { | ||
| 114 | + assert.throws(() => new SocketAddress({ port }), { | ||
| 119 | 115 | code: 'ERR_SOCKET_BAD_PORT' | |
| 120 | 116 | }); | |
| 121 | 117 | }); | |
| 122 | 118 | ||
| 123 | - throws(() => new SocketAddress({ flowlabel: -1 }), { | ||
| 119 | + assert.throws(() => new SocketAddress({ flowlabel: -1 }), { | ||
| 124 | 120 | code: 'ERR_OUT_OF_RANGE' | |
| 125 | 121 | }); | |
| 126 | 122 | }); | |
@@ -135,11 +131,11 @@ describe('net.SocketAddress...', () => { | |||
| 135 | 131 | const flowlabel = 0; | |
| 136 | 132 | const handle = new _SocketAddress(address, port, AF_INET, flowlabel); | |
| 137 | 133 | const addr = new InternalSocketAddress(handle); | |
| 138 | - ok(addr instanceof SocketAddress); | ||
| 139 | - strictEqual(addr.address, address); | ||
| 140 | - strictEqual(addr.port, port); | ||
| 141 | - strictEqual(addr.family, 'ipv4'); | ||
| 142 | - strictEqual(addr.flowlabel, flowlabel); | ||
| 134 | + assert.ok(addr instanceof SocketAddress); | ||
| 135 | + assert.strictEqual(addr.address, address); | ||
| 136 | + assert.strictEqual(addr.port, port); | ||
| 137 | + assert.strictEqual(addr.family, 'ipv4'); | ||
| 138 | + assert.strictEqual(addr.flowlabel, flowlabel); | ||
| 143 | 139 | }); | |
| 144 | 140 | ||
| 145 | 141 | it('SocketAddress.parse() works as expected', () => { | |
@@ -156,9 +152,9 @@ describe('net.SocketAddress...', () => { | |||
| 156 | 152 | ||
| 157 | 153 | good.forEach((i) => { | |
| 158 | 154 | const addr = SocketAddress.parse(i.input); | |
| 159 | - strictEqual(addr.address, i.address); | ||
| 160 | - strictEqual(addr.port, i.port); | ||
| 161 | - strictEqual(addr.family, i.family); | ||
| 155 | + assert.strictEqual(addr.address, i.address); | ||
| 156 | + assert.strictEqual(addr.port, i.port); | ||
| 157 | + assert.strictEqual(addr.family, i.family); | ||
| 162 | 158 | }); | |
| 163 | 159 | ||
| 164 | 160 | const bad = [ | |
@@ -169,7 +165,7 @@ describe('net.SocketAddress...', () => { | |||
| 169 | 165 | ]; | |
| 170 | 166 | ||
| 171 | 167 | bad.forEach((i) => { | |
| 172 | - strictEqual(SocketAddress.parse(i), undefined); | ||
| 168 | + assert.strictEqual(SocketAddress.parse(i), undefined); | ||
| 173 | 169 | }); | |
| 174 | 170 | }); | |
| 175 | 171 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,22 +16,22 @@ if (!process.argv[2]) { | |||
| 16 | 16 | const stdinPipeName = `\\\\.\\pipe\\${pipeNamePrefix}.stdin`; | |
| 17 | 17 | const stdoutPipeName = `\\\\.\\pipe\\${pipeNamePrefix}.stdout`; | |
| 18 | 18 | ||
| 19 | - const stdinPipeServer = net.createServer(function(c) { | ||
| 19 | + const stdinPipeServer = net.createServer(common.mustCall((c) => { | ||
| 20 | 20 | c.on('end', common.mustCall()); | |
| 21 | 21 | c.end('hello'); | |
| 22 | - }); | ||
| 22 | + })); | ||
| 23 | 23 | stdinPipeServer.listen(stdinPipeName); | |
| 24 | 24 | ||
| 25 | 25 | const output = []; | |
| 26 | 26 | ||
| 27 | - const stdoutPipeServer = net.createServer(function(c) { | ||
| 27 | + const stdoutPipeServer = net.createServer(common.mustCallAtLeast((c) => { | ||
| 28 | 28 | c.on('data', function(x) { | |
| 29 | 29 | output.push(x); | |
| 30 | 30 | }); | |
| 31 | 31 | c.on('end', common.mustCall(function() { | |
| 32 | 32 | assert.strictEqual(output.join(''), 'hello'); | |
| 33 | 33 | })); | |
| 34 | - }); | ||
| 34 | + })); | ||
| 35 | 35 | stdoutPipeServer.listen(stdoutPipeName); | |
| 36 | 36 | ||
| 37 | 37 | const args = | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - const { skipIfSQLiteMissing } = require('../common'); | ||
| 2 | + const { skipIfSQLiteMissing, mustCall } = require('../common'); | ||
| 3 | 3 | skipIfSQLiteMissing(); | |
| 4 | 4 | const assert = require('node:assert'); | |
| 5 | 5 | const { DatabaseSync } = require('node:sqlite'); | |
@@ -376,14 +376,14 @@ suite('DatabaseSync.prototype.function()', () => { | |||
| 376 | 376 | ||
| 377 | 377 | test('supported argument types', () => { | |
| 378 | 378 | const db = new DatabaseSync(':memory:'); | |
| 379 | - db.function('arguments', (i, f, s, n, b) => { | ||
| 379 | + db.function('arguments', mustCall((i, f, s, n, b) => { | ||
| 380 | 380 | assert.strictEqual(i, 5); | |
| 381 | 381 | assert.strictEqual(f, 3.14); | |
| 382 | 382 | assert.strictEqual(s, 'foo'); | |
| 383 | 383 | assert.strictEqual(n, null); | |
| 384 | 384 | assert.deepStrictEqual(b, new Uint8Array([254])); | |
| 385 | 385 | return 42; | |
| 386 | - }); | ||
| 386 | + })); | ||
| 387 | 387 | const stmt = db.prepare( | |
| 388 | 388 | 'SELECT arguments(5, 3.14, \'foo\', null, x\'fe\') as result' | |
| 389 | 389 | ); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,6 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | // This tests that piping stdin will cause it to resume() as well. | |
| 3 | - require('../common'); | ||
| 3 | + const common = require('../common'); | ||
| 4 | 4 | const assert = require('assert'); | |
| 5 | 5 | ||
| 6 | 6 | if (process.argv[2] === 'child') { | |
@@ -12,11 +12,11 @@ if (process.argv[2] === 'child') { | |||
| 12 | 12 | child.stdout.on('data', function(c) { | |
| 13 | 13 | buffers.push(c); | |
| 14 | 14 | }); | |
| 15 | - child.stdout.on('close', function() { | ||
| 15 | + child.stdout.on('close', common.mustCall(() => { | ||
| 16 | 16 | const b = Buffer.concat(buffers).toString(); | |
| 17 | 17 | assert.strictEqual(b, 'Hello, world\n'); | |
| 18 | 18 | console.log('ok'); | |
| 19 | - }); | ||
| 19 | + })); | ||
| 20 | 20 | child.stdin.write('Hel'); | |
| 21 | 21 | child.stdin.write('lo,'); | |
| 22 | 22 | child.stdin.write(' wo'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - require('../common'); | ||
| 2 | + const common = require('../common'); | ||
| 3 | 3 | const tmpdir = require('../common/tmpdir'); | |
| 4 | 4 | const assert = require('assert'); | |
| 5 | 5 | const fs = require('fs'); | |
@@ -19,7 +19,7 @@ const stream = fs.createWriteStream(stderrOutputPath); | |||
| 19 | 19 | // non-built-in module. | |
| 20 | 20 | fs.writeFileSync(fakeModulePath, '', 'utf8'); | |
| 21 | 21 | ||
| 22 | - stream.on('open', () => { | ||
| 22 | + stream.on('open', common.mustCall(() => { | ||
| 23 | 23 | spawnSync(process.execPath, { | |
| 24 | 24 | input: `require(${JSON.stringify(fakeModulePath)})`, | |
| 25 | 25 | stdio: ['pipe', 'pipe', stream] | |
@@ -33,4 +33,4 @@ stream.on('open', () => { | |||
| 33 | 33 | stream.end(); | |
| 34 | 34 | fs.unlinkSync(stderrOutputPath); | |
| 35 | 35 | fs.unlinkSync(fakeModulePath); | |
| 36 | - }); | ||
| 36 | + })); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - require('../common'); | ||
| 2 | + const common = require('../common'); | ||
| 3 | 3 | const assert = require('assert'); | |
| 4 | 4 | ||
| 5 | 5 | if (process.argv[2] === 'child') | |
@@ -23,10 +23,10 @@ function parent() { | |||
| 23 | 23 | err += c; | |
| 24 | 24 | }); | |
| 25 | 25 | ||
| 26 | - child.on('close', function(code, signal) { | ||
| 26 | + child.on('close', common.mustCall((code, signal) => { | ||
| 27 | 27 | assert.strictEqual(code, 0); | |
| 28 | 28 | assert.strictEqual(err, ''); | |
| 29 | 29 | assert.strictEqual(out, 'foo'); | |
| 30 | 30 | console.log('ok'); | |
| 31 | - }); | ||
| 31 | + })); | ||
| 32 | 32 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,7 +32,7 @@ if (spawnSync('strace').error !== undefined) { | |||
| 32 | 32 | ||
| 33 | 33 | // stderr is the default for strace | |
| 34 | 34 | const rl = createInterface({ input: strace.stderr }); | |
| 35 | - rl.on('line', (line) => { | ||
| 35 | + rl.on('line', common.mustCallAtLeast((line) => { | ||
| 36 | 36 | if (!line.startsWith('open')) { | |
| 37 | 37 | return; | |
| 38 | 38 | } | |
@@ -48,7 +48,7 @@ if (spawnSync('strace').error !== undefined) { | |||
| 48 | 48 | } | |
| 49 | 49 | ||
| 50 | 50 | assert(allowedOpenCalls.delete(file), `${file} is not in the list of allowed openat calls`); | |
| 51 | - }); | ||
| 51 | + })); | ||
| 52 | 52 | const debugOutput = []; | |
| 53 | 53 | strace.stderr.setEncoding('utf8'); | |
| 54 | 54 | strace.stderr.on('data', (chunk) => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -61,7 +61,7 @@ assert.strictEqual(chunk, str); | |||
| 61 | 61 | chunk = r.read(); | |
| 62 | 62 | assert.strictEqual(chunk, null); | |
| 63 | 63 | ||
| 64 | - r.once('readable', () => { | ||
| 64 | + r.once('readable', common.mustCall(() => { | ||
| 65 | 65 | // This time, we'll get *all* the remaining data, because | |
| 66 | 66 | // it's been added synchronously, as the read WOULD take | |
| 67 | 67 | // us below the hwm, and so it triggered a _read() again, | |
@@ -71,4 +71,4 @@ r.once('readable', () => { | |||
| 71 | 71 | ||
| 72 | 72 | chunk = r.read(); | |
| 73 | 73 | assert.strictEqual(chunk, null); | |
| 74 | - }); | ||
| 74 | + })); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments