test: remove unreachable code
authorMichaël Zasso <mic.besace@gmail.com>
Sun, 2 Aug 2015 10:09:38 +0000 (12:09 +0200)
committerMichaël Zasso <mic.besace@gmail.com>
Thu, 20 Aug 2015 18:16:47 +0000 (20:16 +0200)
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>
test/message/throw_custom_error.js
test/message/throw_custom_error.out
test/message/throw_non_error.js
test/message/throw_non_error.out
test/parallel/test-domain.js
test/parallel/test-file-write-stream.js
test/parallel/test-http-content-length.js
test/parallel/test-listen-fd-detached-inherit.js

index 270b37d14ddead21411d69168f724b252b7ca562..bb5dae05a9b03a2a1094eefc5b86f3225bd6a91f 100644 (file)
@@ -2,9 +2,5 @@
 var common = require('../common');
 var assert = require('assert');
 
-console.error('before');
-
 // custom error throwing
 throw ({ name: 'MyCustomError', message: 'This is a custom message' });
-
-console.error('after');
index bfb928d48dd08e67f4be665a563f0b351bb78570..ef73c52c889dffd066dbbf66ff029d77721ef032 100644 (file)
@@ -1,5 +1,4 @@
-before
-*test*message*throw_custom_error.js:8
+*test*message*throw_custom_error.js:6
 throw ({ name: 'MyCustomError', message: 'This is a custom message' });
 ^
 MyCustomError: This is a custom message
index 33e0a051d65a1db959f6791a6fd8c51369db8047..a1046b725e93a4cc3e385163bc94c87af6168320 100644 (file)
@@ -2,9 +2,5 @@
 var common = require('../common');
 var assert = require('assert');
 
-console.error('before');
-
 // custom error throwing
 throw ({ foo: 'bar' });
-
-console.error('after');
index c859d5f16a511e188fcd0ce60ddb9698f291ddcc..15f95fcc11699a46e13c069e3296b4fad9fdbcb2 100644 (file)
@@ -1,5 +1,4 @@
-before
-*test*message*throw_non_error.js:8
+*test*message*throw_non_error.js:6
 throw ({ foo: 'bar' });
 ^
 [object Object]
index cca01572123a45dad5aa15a021381732b17bd582..918e3288e8dc91b6954342a86b122936545f69cf 100644 (file)
@@ -163,7 +163,6 @@ expectCaught++;
 // as a callback instead.
 function fn(er) {
   throw new Error('This function should never be called!');
-  process.exit(1);
 }
 
 var bound = d.intercept(fn);
index 7309a6bf9db4d36f238af7d1455a89d0202bb69a..36ef283528b7c1b0a43f6750a33c50ade5cf20f0 100644 (file)
@@ -26,7 +26,6 @@ file
     })
   .on('error', function(err) {
       throw err;
-      console.error('error!', err.stack);
     })
   .on('drain', function() {
       console.error('drain!', callbacks.drain);
index 6c9576cdabf5631caf19e016c8a2b9563dc138b4..ec60396a24545dfc2d3ef227fc692256f03ab27c 100644 (file)
@@ -40,7 +40,6 @@ var server = http.createServer(function(req, res) {
       break;
     default:
       throw new Error('Unreachable');
-      break;
   }
 
   receivedRequests++;
index 7d4df0c1aec106539161f98306cefadeae13a384..472b1e8ff939f0ceade04d0161c1ee505097463d 100644 (file)
@@ -64,8 +64,8 @@ function test() {
 // Then output the child's pid, and immediately exit.
 function parent() {
   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');
+    throw new Error('Should not see connections on parent');
   }).listen(PORT, function() {
     console.error('server listening on %d', PORT);