Skip to content
Merged
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
12 changes: 0 additions & 12 deletions test/parallel/test-repl-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ if (process.env.TERM === 'dumb') {
const tests = [
testSloppyMode,
testStrictMode,
testAutoMode,
testStrictModeTerminal,
];

Expand Down Expand Up @@ -56,14 +55,3 @@ function testStrictModeTerminal() {
output.accumulator.includes('\n// ReferenceError: xyz is not defined')
);
}

function testAutoMode() {
const { input, output } = startNewREPLServer({ replMode: repl.REPL_MODE_MAGIC, terminal: false, prompt: '> ' });

input.emit('data', 'x = 3\n');
assert.strictEqual(output.accumulator, '> 3\n> ');
output.accumulator = '';

input.emit('data', 'let y = 3\n');
assert.strictEqual(output.accumulator, 'undefined\n> ');
}
Comment on lines -59 to -69
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is effectively a duplicate of

function testSloppyMode() {
const { input, output } = startNewREPLServer({ replMode: repl.REPL_MODE_SLOPPY, terminal: false, prompt: '> ' });
input.emit('data', 'x = 3\n');
assert.strictEqual(output.accumulator, '> 3\n> ');
output.accumulator = '';
input.emit('data', 'let y = 3\n');
assert.strictEqual(output.accumulator, 'undefined\n> ');
}

38 changes: 0 additions & 38 deletions test/parallel/test-repl-underscore.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const testingReplPrompt = '_REPL_TESTING_PROMPT_>';

testSloppyMode();
testStrictMode();
testMagicMode();
testResetContext();
testResetContextGlobal();
testError();
Expand Down Expand Up @@ -86,46 +85,9 @@ function testStrictMode() {
]);
}

function testMagicMode() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is effectively a duplicate of

function testSloppyMode() {
const { replServer, output } = startNewREPLServer({
prompt: testingReplPrompt,
mode: repl.REPL_MODE_SLOPPY,
});
// Cannot use `let` in sloppy mode
replServer.write(`_; // initial value undefined
var x = 10; // evaluates to undefined
_; // still undefined
y = 10; // evaluates to 10
_; // 10 from last eval
_ = 20; // explicitly set to 20
_; // 20 from user input
_ = 30; // make sure we can set it twice and no prompt
_; // 30 from user input
y = 40; // make sure eval doesn't change _
_; // remains 30 from user input
`);
assertOutput(output, [
'undefined',
'undefined',
'undefined',
'10',
'10',
'Expression assignment to _ now disabled.',
'20',
'20',
'30',
'30',
'40',
'30',
]);
}

const { replServer, output } = startNewREPLServer({
prompt: testingReplPrompt,
mode: repl.REPL_MODE_MAGIC,
});

replServer.write(`_; // initial value undefined
x = 10; //
_; // last eval - 10
let _ = 20; // undefined
_; // 20 from user input
_ = 30; // make sure we can set it twice and no prompt
_; // 30 from user input
var y = 40; // make sure eval doesn't change _
_; // remains 30 from user input
function f() { let _ = 50; return _; } // undefined
f(); // 50
_; // remains 30 from user input
`);

assertOutput(output, [
'undefined',
'10',
'10',
'undefined',
'20',
'30',
'30',
'undefined',
'30',
'undefined',
'50',
'30',
]);
}

function testResetContext() {
const { replServer, output } = startNewREPLServer({
prompt: testingReplPrompt,
mode: repl.REPL_MODE_MAGIC,
});

replServer.write(`_ = 10; // explicitly set to 10
Expand Down
Loading