node/test/parallel/test-repl-syntax-error-stack.js
cjihrig f2e319b757 test: move ArrayStream to common
A number of REPL tests define the same ArrayStream object. This
commit moves the repeated code into common.js.

PR-URL: https://github.com/nodejs/node/pull/4027
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-11-26 21:16:08 -05:00

28 lines
644 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const path = require('path');
const repl = require('repl');
const util = require('util');
let found = false;
process.on('exit', () => {
assert.strictEqual(found, true);
});
common.ArrayStream.prototype.write = function(output) {
if (/var foo bar;/.test(output))
found = true;
};
const putIn = new common.ArrayStream();
const testMe = repl.start('', putIn);
let file = path.resolve(__dirname, '../fixtures/syntax/bad_syntax');
if (common.isWindows)
file = file.replace(/\\/g, '\\\\');
putIn.run(['.clear']);
putIn.run([`require('${file}');`]);