Browse Source

test: remove unreachable code

There is no way a line can be called after throwing an exception.

PR-URL: https://github.com/nodejs/node/pull/2289
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
v4.0.0-rc
Michaël Zasso 10 years ago
parent
commit
2235fad11b
  1. 4
      test/message/throw_custom_error.js
  2. 3
      test/message/throw_custom_error.out
  3. 4
      test/message/throw_non_error.js
  4. 3
      test/message/throw_non_error.out
  5. 1
      test/parallel/test-domain.js
  6. 1
      test/parallel/test-file-write-stream.js
  7. 1
      test/parallel/test-http-content-length.js
  8. 2
      test/parallel/test-listen-fd-detached-inherit.js

4
test/message/throw_custom_error.js

@ -2,9 +2,5 @@
var common = require('../common'); var common = require('../common');
var assert = require('assert'); var assert = require('assert');
console.error('before');
// custom error throwing // custom error throwing
throw ({ name: 'MyCustomError', message: 'This is a custom message' }); throw ({ name: 'MyCustomError', message: 'This is a custom message' });
console.error('after');

3
test/message/throw_custom_error.out

@ -1,5 +1,4 @@
before *test*message*throw_custom_error.js:6
*test*message*throw_custom_error.js:8
throw ({ name: 'MyCustomError', message: 'This is a custom message' }); throw ({ name: 'MyCustomError', message: 'This is a custom message' });
^ ^
MyCustomError: This is a custom message MyCustomError: This is a custom message

4
test/message/throw_non_error.js

@ -2,9 +2,5 @@
var common = require('../common'); var common = require('../common');
var assert = require('assert'); var assert = require('assert');
console.error('before');
// custom error throwing // custom error throwing
throw ({ foo: 'bar' }); throw ({ foo: 'bar' });
console.error('after');

3
test/message/throw_non_error.out

@ -1,5 +1,4 @@
before *test*message*throw_non_error.js:6
*test*message*throw_non_error.js:8
throw ({ foo: 'bar' }); throw ({ foo: 'bar' });
^ ^
[object Object] [object Object]

1
test/parallel/test-domain.js

@ -163,7 +163,6 @@ expectCaught++;
// as a callback instead. // as a callback instead.
function fn(er) { function fn(er) {
throw new Error('This function should never be called!'); throw new Error('This function should never be called!');
process.exit(1);
} }
var bound = d.intercept(fn); var bound = d.intercept(fn);

1
test/parallel/test-file-write-stream.js

@ -26,7 +26,6 @@ file
}) })
.on('error', function(err) { .on('error', function(err) {
throw err; throw err;
console.error('error!', err.stack);
}) })
.on('drain', function() { .on('drain', function() {
console.error('drain!', callbacks.drain); console.error('drain!', callbacks.drain);

1
test/parallel/test-http-content-length.js

@ -40,7 +40,6 @@ var server = http.createServer(function(req, res) {
break; break;
default: default:
throw new Error('Unreachable'); throw new Error('Unreachable');
break;
} }
receivedRequests++; receivedRequests++;

2
test/parallel/test-listen-fd-detached-inherit.js

@ -64,8 +64,8 @@ function test() {
// Then output the child's pid, and immediately exit. // Then output the child's pid, and immediately exit.
function parent() { function parent() {
var server = net.createServer(function(conn) { var server = net.createServer(function(conn) {
throw new Error('Should not see connections on parent');
conn.end('HTTP/1.1 403 Forbidden\r\n\r\nI got problems.\r\n'); conn.end('HTTP/1.1 403 Forbidden\r\n\r\nI got problems.\r\n');
throw new Error('Should not see connections on parent');
}).listen(PORT, function() { }).listen(PORT, function() {
console.error('server listening on %d', PORT); console.error('server listening on %d', PORT);

Loading…
Cancel
Save