2015-11-24 19:55:51 -05:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
2018-08-21 14:47:47 -07:00
|
|
|
const ArrayStream = require('../common/arraystream');
|
2017-10-06 12:25:05 -07:00
|
|
|
const fixtures = require('../common/fixtures');
|
2015-11-24 19:55:51 -05:00
|
|
|
const assert = require('assert');
|
|
|
|
const repl = require('repl');
|
|
|
|
let found = false;
|
|
|
|
|
|
|
|
process.on('exit', () => {
|
|
|
|
assert.strictEqual(found, true);
|
|
|
|
});
|
|
|
|
|
2018-08-21 14:47:47 -07:00
|
|
|
ArrayStream.prototype.write = function(output) {
|
2017-10-17 16:39:07 -07:00
|
|
|
// Matching only on a minimal piece of the stack because the string will vary
|
|
|
|
// greatly depending on the JavaScript engine. V8 includes `;` because it
|
|
|
|
// displays the line of code (`var foo bar;`) that is causing a problem.
|
|
|
|
// ChakraCore does not display the line of code but includes `;` in the phrase
|
|
|
|
// `Expected ';' `.
|
|
|
|
if (/;/.test(output))
|
2015-11-24 19:55:51 -05:00
|
|
|
found = true;
|
|
|
|
};
|
|
|
|
|
2018-08-21 14:47:47 -07:00
|
|
|
const putIn = new ArrayStream();
|
2016-01-01 17:37:10 -08:00
|
|
|
repl.start('', putIn);
|
2017-10-06 12:25:05 -07:00
|
|
|
let file = fixtures.path('syntax', 'bad_syntax');
|
2015-11-24 19:55:51 -05:00
|
|
|
|
|
|
|
if (common.isWindows)
|
|
|
|
file = file.replace(/\\/g, '\\\\');
|
|
|
|
|
|
|
|
putIn.run(['.clear']);
|
|
|
|
putIn.run([`require('${file}');`]);
|