Skip to content

Revert "test: add tests for REPL custom evals" #57793

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2025
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
1 change: 1 addition & 0 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ function REPLServer(prompt,
options.useColors = shouldColorize(options.output);
}

// TODO(devsnek): Add a test case for custom eval functions.
const preview = options.terminal &&
(options.preview !== undefined ? !!options.preview : !eval_);

Expand Down
135 changes: 0 additions & 135 deletions test/parallel/test-repl-custom-eval.js

This file was deleted.

33 changes: 33 additions & 0 deletions test/parallel/test-repl-eval.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const repl = require('repl');

{
let evalCalledWithExpectedArgs = false;

const options = {
eval: common.mustCall((cmd, context) => {
// Assertions here will not cause the test to exit with an error code
// so set a boolean that is checked later instead.
evalCalledWithExpectedArgs = (cmd === 'function f() {}\n' &&
context.foo === 'bar');
})
};

const r = repl.start(options);
r.context = { foo: 'bar' };

try {
// Default preprocessor transforms
// function f() {} to
// var f = function f() {}
// Test to ensure that original input is preserved.
// Reference: https://github.com/nodejs/node/issues/9743
r.write('function f() {}\n');
} finally {
r.write('.exit\n');
}

assert(evalCalledWithExpectedArgs);
}
Loading