2016-07-19 17:36:15 +02:00
|
|
|
'use strict';
|
|
|
|
// Refs: https://github.com/nodejs/node/issues/7788
|
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
2017-08-09 19:29:40 +02:00
|
|
|
const path = require('../common/fixtures').path;
|
2016-07-19 17:36:15 +02:00
|
|
|
const repl = require('repl');
|
|
|
|
const stream = require('stream');
|
|
|
|
const inputStream = new stream.PassThrough();
|
|
|
|
const outputStream = new stream.PassThrough();
|
2017-08-09 19:29:40 +02:00
|
|
|
const fixture = path('is-object.js');
|
2016-07-19 17:36:15 +02:00
|
|
|
const r = repl.start({
|
|
|
|
input: inputStream,
|
|
|
|
output: outputStream,
|
|
|
|
useGlobal: false
|
|
|
|
});
|
|
|
|
|
|
|
|
let output = '';
|
|
|
|
outputStream.setEncoding('utf8');
|
|
|
|
outputStream.on('data', (data) => output += data);
|
|
|
|
|
|
|
|
r.on('exit', common.mustCall(() => {
|
2017-02-02 20:21:08 +01:00
|
|
|
const results = output.replace(/^> /mg, '').split('\n');
|
2016-07-19 17:36:15 +02:00
|
|
|
|
|
|
|
assert.deepStrictEqual(results, ['undefined', 'true', 'true', '']);
|
|
|
|
}));
|
|
|
|
|
|
|
|
inputStream.write('const isObject = (obj) => obj.constructor === Object;\n');
|
|
|
|
inputStream.write('isObject({});\n');
|
|
|
|
inputStream.write(`require('${fixture}').isObject({});\n`);
|
|
|
|
r.close();
|