test: refactor test-repl-mode.js
* var -> const/let * assert.equal() -> assert.strictEqual() PR-URL: https://github.com/nodejs/node/pull/10061 Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
This commit is contained in:
parent
f7f2102514
commit
4f3c761ac0
@ -1,12 +1,12 @@
|
||||
'use strict';
|
||||
var common = require('../common');
|
||||
var assert = require('assert');
|
||||
var Stream = require('stream');
|
||||
var repl = require('repl');
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const Stream = require('stream');
|
||||
const repl = require('repl');
|
||||
|
||||
common.globalCheck = false;
|
||||
|
||||
var tests = [
|
||||
const tests = [
|
||||
testSloppyMode,
|
||||
testStrictMode,
|
||||
testAutoMode
|
||||
@ -17,22 +17,22 @@ tests.forEach(function(test) {
|
||||
});
|
||||
|
||||
function testSloppyMode() {
|
||||
var cli = initRepl(repl.REPL_MODE_SLOPPY);
|
||||
const cli = initRepl(repl.REPL_MODE_SLOPPY);
|
||||
|
||||
cli.input.emit('data', `
|
||||
x = 3
|
||||
`.trim() + '\n');
|
||||
assert.equal(cli.output.accumulator.join(''), '> 3\n> ');
|
||||
assert.strictEqual(cli.output.accumulator.join(''), '> 3\n> ');
|
||||
cli.output.accumulator.length = 0;
|
||||
|
||||
cli.input.emit('data', `
|
||||
let y = 3
|
||||
`.trim() + '\n');
|
||||
assert.equal(cli.output.accumulator.join(''), 'undefined\n> ');
|
||||
assert.strictEqual(cli.output.accumulator.join(''), 'undefined\n> ');
|
||||
}
|
||||
|
||||
function testStrictMode() {
|
||||
var cli = initRepl(repl.REPL_MODE_STRICT);
|
||||
const cli = initRepl(repl.REPL_MODE_STRICT);
|
||||
|
||||
cli.input.emit('data', `
|
||||
x = 3
|
||||
@ -44,30 +44,30 @@ function testStrictMode() {
|
||||
cli.input.emit('data', `
|
||||
let y = 3
|
||||
`.trim() + '\n');
|
||||
assert.equal(cli.output.accumulator.join(''), 'undefined\n> ');
|
||||
assert.strictEqual(cli.output.accumulator.join(''), 'undefined\n> ');
|
||||
}
|
||||
|
||||
function testAutoMode() {
|
||||
var cli = initRepl(repl.REPL_MODE_MAGIC);
|
||||
const cli = initRepl(repl.REPL_MODE_MAGIC);
|
||||
|
||||
cli.input.emit('data', `
|
||||
x = 3
|
||||
`.trim() + '\n');
|
||||
assert.equal(cli.output.accumulator.join(''), '> 3\n> ');
|
||||
assert.strictEqual(cli.output.accumulator.join(''), '> 3\n> ');
|
||||
cli.output.accumulator.length = 0;
|
||||
|
||||
cli.input.emit('data', `
|
||||
let y = 3
|
||||
`.trim() + '\n');
|
||||
assert.equal(cli.output.accumulator.join(''), 'undefined\n> ');
|
||||
assert.strictEqual(cli.output.accumulator.join(''), 'undefined\n> ');
|
||||
}
|
||||
|
||||
function initRepl(mode) {
|
||||
var input = new Stream();
|
||||
const input = new Stream();
|
||||
input.write = input.pause = input.resume = function() {};
|
||||
input.readable = true;
|
||||
|
||||
var output = new Stream();
|
||||
const output = new Stream();
|
||||
output.write = output.pause = output.resume = function(buf) {
|
||||
output.accumulator.push(buf);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user