GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Revert "test: add tests for REPL custom evals" · nodejs/node@a6cc240

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • repl.js
  • test/parallel
    • test-repl-custom-eval.js
    • test-repl-eval.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/repl.js‎

Copy file name to clipboardExpand all lines: lib/repl.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ function REPLServer(prompt,
302302
options.useColors = shouldColorize(options.output);
303303
}
304304

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

Collapse file

‎test/parallel/test-repl-custom-eval.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-repl-custom-eval.js
-135Lines changed: 0 additions & 135 deletions
This file was deleted.
Collapse file

‎test/parallel/test-repl-eval.js‎

Copy file name to clipboard
+33Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const repl = require('repl');
5+
6+
{
7+
let evalCalledWithExpectedArgs = false;
8+
9+
const options = {
10+
eval: common.mustCall((cmd, context) => {
11+
// Assertions here will not cause the test to exit with an error code
12+
// so set a boolean that is checked later instead.
13+
evalCalledWithExpectedArgs = (cmd === 'function f() {}\n' &&
14+
context.foo === 'bar');
15+
})
16+
};
17+
18+
const r = repl.start(options);
19+
r.context = { foo: 'bar' };
20+
21+
try {
22+
// Default preprocessor transforms
23+
// function f() {} to
24+
// var f = function f() {}
25+
// Test to ensure that original input is preserved.
26+
// Reference: https://github.com/nodejs/node/issues/9743
27+
r.write('function f() {}\n');
28+
} finally {
29+
r.write('.exit\n');
30+
}
31+
32+
assert(evalCalledWithExpectedArgs);
33+
}

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.