mirror of
https://github.com/nodejs/node.git
synced 2025-05-05 17:10:40 +00:00

PR-URL: https://github.com/nodejs/node/pull/8622 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yorkie Liu <yorkiefixer@gmail.com> Reviewed-By: Jackson Tian <shvyo1987@gmail.com> Reviewed-By: Johan Bergström <bugs@bergstroem.nu> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
27 lines
742 B
JavaScript
27 lines
742 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const repl = require('repl');
|
|
|
|
// Create a dummy stream that does nothing
|
|
const stream = new common.ArrayStream();
|
|
|
|
// Test when useGlobal is false
|
|
testContext(repl.start({
|
|
input: stream,
|
|
output: stream,
|
|
useGlobal: false
|
|
}));
|
|
|
|
function testContext(repl) {
|
|
const context = repl.createContext();
|
|
// ensure that the repl context gets its own "console" instance
|
|
assert(context.console instanceof require('console').Console);
|
|
|
|
// ensure that the repl's global property is the context
|
|
assert.strictEqual(context.global, context);
|
|
|
|
// ensure that the repl console instance does not have a setter
|
|
assert.throws(() => context.console = 'foo');
|
|
}
|