diff --git a/test/parallel/test-repl-eval.js b/test/parallel/test-repl-eval.js new file mode 100644 index 00000000000000..ac32e858415cd1 --- /dev/null +++ b/test/parallel/test-repl-eval.js @@ -0,0 +1,22 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const repl = require('repl'); + +{ + const options = { + eval: common.mustCall((cmd, context) => { + assert.strictEqual(cmd, 'foo\n'); + assert.deepStrictEqual(context, {animal: 'Sterrance'}); + }) + }; + + const r = repl.start(options); + r.context = {animal: 'Sterrance'}; + + try { + r.write('foo\n'); + } finally { + r.write('.exit\n'); + } +}