mirror of
https://github.com/nodejs/node.git
synced 2025-05-08 02:52:29 +00:00

PR-URL: https://github.com/nodejs/node/pull/7829 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yorkie Liu <yorkiefixer@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
29 lines
902 B
JavaScript
29 lines
902 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const repl = require('repl');
|
|
|
|
const expected = [
|
|
'replServer.convertToContext() is deprecated'
|
|
];
|
|
|
|
process.on('warning', common.mustCall((warning) => {
|
|
assert.strictEqual(warning.name, 'DeprecationWarning');
|
|
assert.notStrictEqual(expected.indexOf(warning.message), -1,
|
|
`unexpected error message: "${warning.message}"`);
|
|
// Remove a warning message after it is seen so that we guarantee that we get
|
|
// each message only once.
|
|
expected.splice(expected.indexOf(warning.message), 1);
|
|
}, expected.length));
|
|
|
|
// Create a dummy stream that does nothing
|
|
const stream = new common.ArrayStream();
|
|
|
|
const replServer = repl.start({
|
|
input: stream,
|
|
output: stream
|
|
});
|
|
|
|
const cmd = replServer.convertToContext('var name = "nodejs"');
|
|
assert.strictEqual(cmd, 'self.context.name = "nodejs"');
|