| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d0b4835 commit c6a45a9
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -306,6 +306,7 @@ function REPLServer(prompt, | |||
| 306 | 306 | options.useColors = shouldColorize(options.output); | |
| 307 | 307 | } | |
| 308 | 308 | ||
| 309 | + // TODO(devsnek): Add a test case for custom eval functions. | ||
| 309 | 310 | const preview = options.terminal && | |
| 310 | 311 | (options.preview !== undefined ? !!options.preview : !eval_); | |
| 311 | 312 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,33 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const repl = require('repl'); | ||
| 5 | + | ||
| 6 | + { | ||
| 7 | + let evalCalledWithExpectedArgs = false; | ||
| 8 | + | ||
| 9 | + const options = { | ||
| 10 | + eval: common.mustCall((cmd, context) => { | ||
| 11 | + // Assertions here will not cause the test to exit with an error code | ||
| 12 | + // so set a boolean that is checked later instead. | ||
| 13 | + evalCalledWithExpectedArgs = (cmd === 'function f() {}\n' && | ||
| 14 | + context.foo === 'bar'); | ||
| 15 | + }) | ||
| 16 | + }; | ||
| 17 | + | ||
| 18 | + const r = repl.start(options); | ||
| 19 | + r.context = { foo: 'bar' }; | ||
| 20 | + | ||
| 21 | + try { | ||
| 22 | + // Default preprocessor transforms | ||
| 23 | + // function f() {} to | ||
| 24 | + // var f = function f() {} | ||
| 25 | + // Test to ensure that original input is preserved. | ||
| 26 | + // Reference: https://github.com/nodejs/node/issues/9743 | ||
| 27 | + r.write('function f() {}\n'); | ||
| 28 | + } finally { | ||
| 29 | + r.write('.exit\n'); | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + assert(evalCalledWithExpectedArgs); | ||
| 33 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments