diff --git a/README.md b/README.md index 83ea0ce99f4b10..9cefde8c5cef8a 100644 --- a/README.md +++ b/README.md @@ -452,8 +452,6 @@ For information about the governance of the Node.js project, see **Mohammed Keyvanzadeh** <> (he/him) * [watilde](https://github.com/watilde) - **Daijiro Wachi** <> (he/him) -* [watson](https://github.com/watson) - - **Thomas Watson** <> * [XadillaX](https://github.com/XadillaX) - **Khaidi Chu** <> (he/him) * [yashLadha](https://github.com/yashLadha) - @@ -620,6 +618,8 @@ For information about the governance of the Node.js project, see **Vladimir Kurchatkin** <> * [vsemozhetbyt](https://github.com/vsemozhetbyt) - **Vse Mozhet Byt** <> (he/him) +* [watson](https://github.com/watson) - + **Thomas Watson** <> * [whitlockjc](https://github.com/whitlockjc) - **Jeremy Whitlock** <> * [yhwang](https://github.com/yhwang) - diff --git a/test/parallel/test-repl-IIFE.js b/test/parallel/test-repl-IIFE.js new file mode 100644 index 00000000000000..acd71534b0527a --- /dev/null +++ b/test/parallel/test-repl-IIFE.js @@ -0,0 +1,50 @@ +'use strict'; + +// REPL regression test for IIFE https://github.com/nodejs/node/issues/38685 + +require('../common'); +const util = require('util'); +const assert = require('assert'); +const ArrayStream = require('../common/arraystream'); +const repl = require('repl'); + +// Create a dummy stream that does nothing +const stream = new ArrayStream(); +let output = ''; + +function testNormalIIFE() { + const server = runRepl(); + + stream.run(['(() => true)()']); + assert.strictEqual(output, '> true\n> '); + output = ''; + server.close(); + testAsyncIIEF(); +} + +function testAsyncIIEF() { + const server = runRepl(); + const asyncFn = '(async() => true)();'; + + stream.run([asyncFn]); + // promise output twice + output = util.inspect(output).split('\\n> ')[1]; + assert.strictEqual(output, 'Promise { }'); + output = ''; + server.close(); +} + +// run repl +function runRepl() { + stream.write = function(d) { + output += d; + }; + + return repl.start({ + input: stream, + output: stream + }); +} + +// start +testNormalIIFE();