| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c0c1a4c commit b7bf43a
19 files changed
| 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 | const dns = require('dns'); | |
| 5 | 5 | const net = require('net'); | |
@@ -44,19 +44,9 @@ function checkWrap(req) { | |||
| 44 | 44 | ||
| 45 | 45 | ||
| 46 | 46 | TEST(function test_reverse_bogus(done) { | |
| 47 | - let error; | ||
| 48 | - | ||
| 49 | - try { | ||
| 50 | - dns.reverse('bogus ip', function() { | ||
| 51 | - assert.ok(false); | ||
| 52 | - }); | ||
| 53 | - } catch (e) { | ||
| 54 | - error = e; | ||
| 55 | - } | ||
| 56 | - | ||
| 57 | - assert.ok(error instanceof Error); | ||
| 58 | - assert.strictEqual(error.errno, 'EINVAL'); | ||
| 59 | - | ||
| 47 | + assert.throws(() => { | ||
| 48 | + dns.reverse('bogus ip', common.fail); | ||
| 49 | + }, /^Error: getHostByAddr EINVAL$/); | ||
| 60 | 50 | done(); | |
| 61 | 51 | }); | |
| 62 | 52 | ||
@@ -442,7 +432,7 @@ TEST(function test_lookup_all_mixed(done) { | |||
| 442 | 432 | else if (isIPv6(ip.address)) | |
| 443 | 433 | assert.strictEqual(ip.family, 6); | |
| 444 | 434 | else | |
| 445 | - assert(false); | ||
| 435 | + common.fail('unexpected IP address'); | ||
| 446 | 436 | }); | |
| 447 | 437 | ||
| 448 | 438 | done(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,7 +38,7 @@ tls.connect(opts, fail).on('error', common.mustCall((err) => { | |||
| 38 | 38 | })); | |
| 39 | 39 | ||
| 40 | 40 | function fail() { | |
| 41 | - assert(false, 'should fail to connect'); | ||
| 41 | + common.fail('should fail to connect'); | ||
| 42 | 42 | } | |
| 43 | 43 | ||
| 44 | 44 | // New secure contexts have the well-known root CAs. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,10 +37,10 @@ if (typeof process.argv[2] === 'string') { | |||
| 37 | 37 | async_wrap.setupHooks({ init, pre, post, destroy }); | |
| 38 | 38 | async_wrap.enable(); | |
| 39 | 39 | ||
| 40 | - process.on('uncaughtException', () => assert.ok(0, 'UNREACHABLE')); | ||
| 40 | + process.on('uncaughtException', common.fail); | ||
| 41 | 41 | ||
| 42 | 42 | const d = domain.create(); | |
| 43 | - d.on('error', () => assert.ok(0, 'UNREACHABLE')); | ||
| 43 | + d.on('error', common.fail); | ||
| 44 | 44 | d.run(() => { | |
| 45 | 45 | // Using randomBytes because timers are not yet supported. | |
| 46 | 46 | crypto.randomBytes(0, () => { }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,8 +21,7 @@ if (process.argv[2] === 'child') { | |||
| 21 | 21 | ||
| 22 | 22 | child.stderr.setEncoding('utf8'); | |
| 23 | 23 | child.stderr.on('data', function(data) { | |
| 24 | - console.log('parent stderr: ' + data); | ||
| 25 | - assert.ok(false); | ||
| 24 | + common.fail(`Unexpected parent stderr: ${data}`); | ||
| 26 | 25 | }); | |
| 27 | 26 | ||
| 28 | 27 | // check if we receive both 'hello' at start and 'goodbye' at end | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,7 +9,6 @@ | |||
| 9 | 9 | */ | |
| 10 | 10 | ||
| 11 | 11 | const common = require('../common'); | |
| 12 | - const assert = require('assert'); | ||
| 13 | 12 | const domain = require('domain'); | |
| 14 | 13 | const child_process = require('child_process'); | |
| 15 | 14 | ||
@@ -184,17 +183,16 @@ if (process.argv[2] === 'child') { | |||
| 184 | 183 | test.expectedMessages.forEach(function(expectedMessage) { | |
| 185 | 184 | if (test.messagesReceived === undefined || | |
| 186 | 185 | test.messagesReceived.indexOf(expectedMessage) === -1) | |
| 187 | - assert(false, 'test ' + test.fn.name + | ||
| 188 | - ' should have sent message: ' + expectedMessage + | ||
| 189 | - ' but didn\'t'); | ||
| 186 | + common.fail('test ' + test.fn.name + ' should have sent message: ' + | ||
| 187 | + expectedMessage + ' but didn\'t'); | ||
| 190 | 188 | }); | |
| 191 | 189 | ||
| 192 | 190 | if (test.messagesReceived) { | |
| 193 | 191 | test.messagesReceived.forEach(function(receivedMessage) { | |
| 194 | 192 | if (test.expectedMessages.indexOf(receivedMessage) === -1) { | |
| 195 | - assert(false, 'test ' + test.fn.name + | ||
| 196 | - ' should not have sent message: ' + receivedMessage + | ||
| 197 | - ' but did'); | ||
| 193 | + common.fail('test ' + test.fn.name + | ||
| 194 | + ' should not have sent message: ' + receivedMessage + | ||
| 195 | + ' but did'); | ||
| 198 | 196 | } | |
| 199 | 197 | }); | |
| 200 | 198 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,9 +19,7 @@ server.listen(0, options.host, common.mustCall(onListen)); | |||
| 19 | 19 | // do a GET request, expect it to fail | |
| 20 | 20 | function onListen() { | |
| 21 | 21 | options.port = this.address().port; | |
| 22 | - const req = http.request(options, function(res) { | ||
| 23 | - assert.ok(false, 'this should never run'); | ||
| 24 | - }); | ||
| 22 | + const req = http.request(options, common.fail); | ||
| 25 | 23 | req.on('error', common.mustCall(function(err) { | |
| 26 | 24 | assert.strictEqual(err.code, 'ECONNRESET'); | |
| 27 | 25 | })); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,10 +7,7 @@ const assert = require('assert'); | |||
| 7 | 7 | // The callback should never be invoked because the server | |
| 8 | 8 | // should respond with a 400 Client Error when a double | |
| 9 | 9 | // Content-Length header is received. | |
| 10 | - const server = http.createServer((req, res) => { | ||
| 11 | - assert(false, 'callback should not have been invoked'); | ||
| 12 | - res.end(); | ||
| 13 | - }); | ||
| 10 | + const server = http.createServer(common.fail); | ||
| 14 | 11 | server.on('clientError', common.mustCall((err, socket) => { | |
| 15 | 12 | assert(/^Parse Error/.test(err.message)); | |
| 16 | 13 | assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH'); | |
| 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 | const binding = process.binding('http_parser'); | |
@@ -35,9 +35,7 @@ function newParser(type) { | |||
| 35 | 35 | parser[kOnHeadersComplete] = function(info) { | |
| 36 | 36 | }; | |
| 37 | 37 | ||
| 38 | - parser[kOnBody] = function(b, start, len) { | ||
| 39 | - assert.ok(false, 'Function should not be called.'); | ||
| 40 | - }; | ||
| 38 | + parser[kOnBody] = common.fail; | ||
| 41 | 39 | ||
| 42 | 40 | parser[kOnMessageComplete] = function() { | |
| 43 | 41 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,7 +35,7 @@ server.listen(0, common.mustCall(() => { | |||
| 35 | 35 | http.get( | |
| 36 | 36 | {port: server.address().port, headers: {'x-num': n}}, | |
| 37 | 37 | (res) => { | |
| 38 | - assert(false, 'client allowed multiple content-length headers.'); | ||
| 38 | + common.fail('client allowed multiple content-length headers.'); | ||
| 39 | 39 | } | |
| 40 | 40 | ).on('error', common.mustCall((err) => { | |
| 41 | 41 | assert(/^Parse Error/.test(err.message)); | |
| 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 | const net = require('net'); | |
| 5 | 5 | ||
@@ -20,7 +20,7 @@ const srv = net.createServer(function onConnection(conn) { | |||
| 20 | 20 | conn.on('error', function(err) { | |
| 21 | 21 | errs.push(err); | |
| 22 | 22 | if (errs.length > 1 && errs[0] === errs[1]) | |
| 23 | - assert(false, 'We should not be emitting the same error twice'); | ||
| 23 | + common.fail('Should not emit the same error twice'); | ||
| 24 | 24 | }); | |
| 25 | 25 | conn.on('close', function() { | |
| 26 | 26 | srv.unref(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments