| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f0c0614 commit 40d57b7
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -228,7 +228,7 @@ function REPLServer(prompt, | |||
| 228 | 228 | (self.replMode === exports.REPL_MODE_STRICT || retry)) { | |
| 229 | 229 | // "void 0" keeps the repl from returning "use strict" as the | |
| 230 | 230 | // result value for let/const statements. | |
| 231 | - code = `'use strict'; void 0; ${code}`; | ||
| 231 | + code = `'use strict'; void 0;\n${code}`; | ||
| 232 | 232 | } | |
| 233 | 233 | var script = vm.createScript(code, { | |
| 234 | 234 | filename: file, | |
@@ -287,6 +287,10 @@ function REPLServer(prompt, | |||
| 287 | 287 | debug('domain error'); | |
| 288 | 288 | const top = replMap.get(self); | |
| 289 | 289 | internalUtil.decorateErrorStack(e); | |
| 290 | + if (e.stack && self.replMode === exports.REPL_MODE_STRICT) { | ||
| 291 | + e.stack = e.stack.replace(/(\s+at\s+repl:)(\d+)/, | ||
| 292 | + (_, pre, line) => pre + (line - 1)); | ||
| 293 | + } | ||
| 290 | 294 | top.outputStream.write((e.stack || e) + '\n'); | |
| 291 | 295 | top.lineParser.reset(); | |
| 292 | 296 | top.bufferedCommand = ''; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,7 +15,7 @@ const prompt_npm = 'npm should be run outside of the ' + | |||
| 15 | 15 | 'node repl, in your normal shell.\n' + | |
| 16 | 16 | '(Press Control-D to exit.)\n'; | |
| 17 | 17 | const expect_npm = prompt_npm + prompt_unix; | |
| 18 | - var server_tcp, server_unix, client_tcp, client_unix, timer; | ||
| 18 | + var server_tcp, server_unix, client_tcp, client_unix, timer, replServer; | ||
| 19 | 19 | ||
| 20 | 20 | ||
| 21 | 21 | // absolute path to test/fixtures/a.js | |
@@ -48,9 +48,17 @@ function clean_up() { | |||
| 48 | 48 | clearTimeout(timer); | |
| 49 | 49 | } | |
| 50 | 50 | ||
| 51 | + function strict_mode_error_test() { | ||
| 52 | + send_expect([ | ||
| 53 | + { client: client_unix, send: 'ref = 1', | ||
| 54 | + expect: /^ReferenceError:\sref\sis\snot\sdefined\n\s+at\srepl:1:5/ }, | ||
| 55 | + ]); | ||
| 56 | + } | ||
| 57 | + | ||
| 51 | 58 | function error_test() { | |
| 52 | 59 | // The other stuff is done so reuse unix socket | |
| 53 | 60 | var read_buffer = ''; | |
| 61 | + var run_strict_test = true; | ||
| 54 | 62 | client_unix.removeAllListeners('data'); | |
| 55 | 63 | ||
| 56 | 64 | client_unix.on('data', function(data) { | |
@@ -72,6 +80,10 @@ function error_test() { | |||
| 72 | 80 | read_buffer = ''; | |
| 73 | 81 | if (client_unix.list && client_unix.list.length > 0) { | |
| 74 | 82 | send_expect(client_unix.list); | |
| 83 | + } else if (run_strict_test) { | ||
| 84 | + replServer.replMode = repl.REPL_MODE_STRICT; | ||
| 85 | + run_strict_test = false; | ||
| 86 | + strict_mode_error_test(); | ||
| 75 | 87 | } else { | |
| 76 | 88 | console.error('End of Error test, running TCP test.'); | |
| 77 | 89 | tcp_test(); | |
@@ -83,6 +95,10 @@ function error_test() { | |||
| 83 | 95 | read_buffer = ''; | |
| 84 | 96 | if (client_unix.list && client_unix.list.length > 0) { | |
| 85 | 97 | send_expect(client_unix.list); | |
| 98 | + } else if (run_strict_test) { | ||
| 99 | + replServer.replMode = repl.REPL_MODE_STRICT; | ||
| 100 | + run_strict_test = false; | ||
| 101 | + strict_mode_error_test(); | ||
| 86 | 102 | } else { | |
| 87 | 103 | console.error('End of Error test, running TCP test.\n'); | |
| 88 | 104 | tcp_test(); | |
@@ -381,12 +397,13 @@ function unix_test() { | |||
| 381 | 397 | socket.end(); | |
| 382 | 398 | }); | |
| 383 | 399 | ||
| 384 | - repl.start({ | ||
| 400 | + replServer = repl.start({ | ||
| 385 | 401 | prompt: prompt_unix, | |
| 386 | 402 | input: socket, | |
| 387 | 403 | output: socket, | |
| 388 | 404 | useGlobal: true | |
| 389 | - }).context.message = message; | ||
| 405 | + }); | ||
| 406 | + replServer.context.message = message; | ||
| 390 | 407 | }); | |
| 391 | 408 | ||
| 392 | 409 | server_unix.on('listening', function() { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments