| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent bfe8c62 commit b890362
12 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,7 +42,7 @@ function runBenchmark(name, env) { | |||
| 42 | 42 | ||
| 43 | 43 | for (let testIdx = 1; testIdx < splitTests.length - 1; testIdx++) { | |
| 44 | 44 | const lines = splitTests[testIdx].split('\n'); | |
| 45 | - assert.ok(/.+/.test(lines[0])); | ||
| 45 | + assert.match(lines[0], /.+/); | ||
| 46 | 46 | ||
| 47 | 47 | if (!lines[1].includes('group="')) { | |
| 48 | 48 | assert.strictEqual(lines.length, 2, `benchmark file not running exactly one configuration in test: ${stdout}`); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -109,6 +109,14 @@ export default [ | |||
| 109 | 109 | selector: 'CallExpression[callee.property.name="catch"]>:first-child:matches(CallExpression[callee.object.name="common"][callee.property.name="mustNotCall"], CallExpression[callee.name="mustNotCall"])', | |
| 110 | 110 | message: 'Calling `.catch(common.mustNotCall())` will not detect never-settling promises. Use `.then(common.mustCall())` instead.', | |
| 111 | 111 | }, | |
| 112 | + { | ||
| 113 | + selector: 'CallExpression[callee.type="MemberExpression"][callee.object.type="Identifier"][callee.object.name="assert"][callee.property.type="Identifier"][callee.property.name="ok"][arguments.0.type="CallExpression"][arguments.0.callee.type="MemberExpression"][arguments.0.callee.object.regex][arguments.0.callee.property.type="Identifier"][arguments.0.callee.property.name="test"]', | ||
| 114 | + message: 'Use assert.match instead', | ||
| 115 | + }, | ||
| 116 | + { | ||
| 117 | + selector: 'CallExpression[callee.type="MemberExpression"][callee.object.type="Identifier"][callee.object.name="assert"][callee.property.type="Identifier"][callee.property.name="ok"][arguments.0.type="UnaryExpression"][arguments.0.operator="!"][arguments.0.argument.type="CallExpression"][arguments.0.argument.callee.type="MemberExpression"][arguments.0.argument.callee.object.regex][arguments.0.argument.callee.property.name="test"]', | ||
| 118 | + message: 'Use assert.doesNotMatch instead', | ||
| 119 | + }, | ||
| 112 | 120 | ], | |
| 113 | 121 | ||
| 114 | 122 | // Stylistic rules. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -304,7 +304,7 @@ function InstanceTest(x, func) { | |||
| 304 | 304 | const answer = addon.doInstanceOf(x, func); | |
| 305 | 305 | assert.strictEqual(correct_answers[correct_answer_index], answer); | |
| 306 | 306 | } catch (e) { | |
| 307 | - assert.ok(/prototype/.test(e)); | ||
| 307 | + assert.match(`${e}`, /prototype/); | ||
| 308 | 308 | assert.strictEqual(correct_answers[correct_answer_index], except); | |
| 309 | 309 | } | |
| 310 | 310 | correct_answer_index++; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,7 +9,6 @@ const dgram = require('dgram'); | |||
| 9 | 9 | -1, | |
| 10 | 10 | 1.1, | |
| 11 | 11 | NaN, | |
| 12 | - undefined, | ||
| 13 | 12 | {}, | |
| 14 | 13 | [], | |
| 15 | 14 | null, | |
@@ -18,11 +17,9 @@ const dgram = require('dgram'); | |||
| 18 | 17 | true, | |
| 19 | 18 | Infinity, | |
| 20 | 19 | ].forEach((maxTimeout) => { | |
| 21 | - try { | ||
| 20 | + assert.throws(() => { | ||
| 22 | 21 | new dns.Resolver({ maxTimeout }); | |
| 23 | - } catch (e) { | ||
| 24 | - assert.ok(/ERR_OUT_OF_RANGE|ERR_INVALID_ARG_TYPE/i.test(e.code)); | ||
| 25 | - } | ||
| 22 | + }, /ERR_OUT_OF_RANGE|ERR_INVALID_ARG_TYPE/i); | ||
| 26 | 23 | }); | |
| 27 | 24 | ||
| 28 | 25 | const server = dgram.createSocket('udp4'); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -43,10 +43,10 @@ function testHttp10(port, callback) { | |||
| 43 | 43 | ||
| 44 | 44 | c.on('end', common.mustCall(() => { | |
| 45 | 45 | c.end(); | |
| 46 | + // Ensure no trailer being in HTTP/1.0 response | ||
| 46 | 47 | assert.doesNotMatch( | |
| 47 | 48 | res_buffer, | |
| 48 | 49 | /x-foo/, | |
| 49 | - `No trailer in HTTP/1.0 response. Response buffer: ${res_buffer}` | ||
| 50 | 50 | ); | |
| 51 | 51 | callback(); | |
| 52 | 52 | })); | |
@@ -69,10 +69,10 @@ function testHttp11(port, callback) { | |||
| 69 | 69 | res_buffer += chunk; | |
| 70 | 70 | if (/0\r\n/.test(res_buffer)) { // got the end. | |
| 71 | 71 | clearTimeout(tid); | |
| 72 | + // Ensure trailer being in HTTP/1.1 response | ||
| 72 | 73 | assert.match( | |
| 73 | 74 | res_buffer, | |
| 74 | 75 | /0\r\nx-foo: bar\r\n\r\n$/, | |
| 75 | - `No trailer in HTTP/1.1 response. Response buffer: ${res_buffer}` | ||
| 76 | 76 | ); | |
| 77 | 77 | callback(); | |
| 78 | 78 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -165,7 +165,7 @@ function onSession(session, next) { | |||
| 165 | 165 | .setEncoding('utf8') | |
| 166 | 166 | .on('data', (chunk) => text += chunk) | |
| 167 | 167 | .on('end', common.mustCall(() => { | |
| 168 | - assert.ok(/Missing ALPN Protocol, expected `h2` to be available/.test(text)); | ||
| 168 | + assert.match(text, /Missing ALPN Protocol, expected `h2` to be available/); | ||
| 169 | 169 | cleanup(); | |
| 170 | 170 | })); | |
| 171 | 171 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,10 +14,10 @@ function checkListResponse(response) { | |||
| 14 | 14 | `Expected response length ${response.length} to be ${expectedLength}.` | |
| 15 | 15 | ); | |
| 16 | 16 | assert.ok(response[0].devtoolsFrontendUrl); | |
| 17 | - assert.ok( | ||
| 18 | - /ws:\/\/localhost:\d+\/[0-9A-Fa-f]{8}-/ | ||
| 19 | - .test(response[0].webSocketDebuggerUrl), | ||
| 20 | - response[0].webSocketDebuggerUrl); | ||
| 17 | + assert.match( | ||
| 18 | + response[0].webSocketDebuggerUrl, | ||
| 19 | + /ws:\/\/localhost:\d+\/[0-9A-Fa-f]{8}-/, | ||
| 20 | + ); | ||
| 21 | 21 | } | |
| 22 | 22 | ||
| 23 | 23 | function checkVersion(response) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -62,7 +62,10 @@ describe('Mock Timers Date Test Suite', () => { | |||
| 62 | 62 | const returned = Date(); | |
| 63 | 63 | // Matches the format: 'Mon Jan 01 1970 00:00:00' | |
| 64 | 64 | // We don't care about the date, just the format | |
| 65 | - assert.ok(/\w{3}\s\w{3}\s\d{1,2}\s\d{2,4}\s\d{1,2}:\d{2}:\d{2}/.test(returned)); | ||
| 65 | + assert.match( | ||
| 66 | + returned, | ||
| 67 | + /\w{3}\s\w{3}\s\d{1,2}\s\d{2,4}\s\d{1,2}:\d{2}:\d{2}/, | ||
| 68 | + ); | ||
| 66 | 69 | }); | |
| 67 | 70 | ||
| 68 | 71 | it('should return the date with different argument calls', (t) => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,10 +20,10 @@ const server = tls.createServer({}) | |||
| 20 | 20 | }).on('tlsClientError', common.mustCall(function(e) { | |
| 21 | 21 | assert.ok(e instanceof Error, | |
| 22 | 22 | 'Instance of Error should be passed to error handler'); | |
| 23 | - assert.ok( | ||
| 24 | - /SSL routines:[^:]*:wrong version number/.test( | ||
| 25 | - e.message), | ||
| 26 | - 'Expecting SSL unknown protocol'); | ||
| 23 | + assert.match( | ||
| 24 | + e.message, | ||
| 25 | + /SSL routines:[^:]*:wrong version number/, | ||
| 26 | + ); | ||
| 27 | 27 | ||
| 28 | 28 | server.close(); | |
| 29 | 29 | })); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,10 +20,10 @@ const server = net.createServer(function(c) { | |||
| 20 | 20 | s.on('error', common.mustCall(function(e) { | |
| 21 | 21 | assert.ok(e instanceof Error, | |
| 22 | 22 | 'Instance of Error should be passed to error handler'); | |
| 23 | - assert.ok( | ||
| 24 | - /SSL routines:[^:]*:wrong version number/.test( | ||
| 25 | - e.message), | ||
| 26 | - 'Expecting SSL unknown protocol'); | ||
| 23 | + assert.match( | ||
| 24 | + e.message, | ||
| 25 | + /SSL routines:[^:]*:wrong version number/, | ||
| 26 | + ); | ||
| 27 | 27 | })); | |
| 28 | 28 | ||
| 29 | 29 | s.on('close', function() { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments