8000 test: add IIFE test for REPL by binvb · Pull Request #41047 · nodejs/node · GitHub
[go: up one dir, main page]

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,6 @@ For information about the governance of the Node.js project, see
**Mohammed Keyvanzadeh** <<mohammadkeyvanzade94@gmail.com>> (he/him)
* [watilde](https://github.com/watilde) -
**Daijiro Wachi** <<daijiro.wachi@gmail.com>> (he/him)
* [watson](https://github.com/watson) -
**Thomas Watson** <<w@tson.dk>>
* [XadillaX](https://github.com/XadillaX) -
**Khaidi Chu** <<i@2333.moe>> (he/him)
* [yashLadha](https://github.com/yashLadha) -
Expand Down Expand Up @@ -620,6 +618,8 @@ For information about the governance of the Node.js project, see
**Vladimir Kurchatkin** <<vladimir.kurchatkin@gmail.com>>
* [vsemozhetbyt](https://github.com/vsemozhetbyt) -
**Vse Mozhet Byt** <<vsemozhetbyt@gmail.com>> (he/him)
* [watson](https://github.com/watson) -
**Thomas Watson** <<w@tson.dk>>
* [whitlockjc](https://github.com/whitlockjc) -
**Jeremy Whitlock** <<jwhitlock@apache.org>>
* [yhwang](https://github.com/yhwang) -
Expand Down
50 changes: 50 additions & 0 deletions test/parallel/test-repl-IIFE.js
Original file line number Diff line number Diff line change
@@ -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 { <pending> }');
output = '';
server.close();
}

// run repl
function runRepl() {
stream.write = function(d) {
output += d;
};

return repl.start({
input: stream,
output: stream
});
}

// start
testNormalIIFE();
0