Skip to content

Commit 2e05e65

Browse files
cjihrigevanlucas
authored andcommitted
test: add known issue test for #7788
15157c3 changed the CLI REPL to default to useGlobal: false by default. This caused the regression seen in #7788. This commit adds a known issue test while a proper resolution is determined. Refs: #5703 Refs: #7788 PR-URL: #7793 Reviewed-By: Rich Trott <[email protected]>
1 parent 7fb4794 commit 2e05e65

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

test/fixtures/is-object.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
'use strict';
2+
module.exports.isObject = (obj) => obj.constructor === Object;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'use strict';
2+
// Refs: https://github.com/nodejs/node/issues/7788
3+
const common = require('../common');
4+
const assert = require('assert');
5+
const path = require('path');
6+
const repl = require('repl');
7+
const stream = require('stream');
8+
const inputStream = new stream.PassThrough();
9+
const outputStream = new stream.PassThrough();
10+
const fixture = path.join(common.fixturesDir, 'is-object.js');
11+
const r = repl.start({
12+
input: inputStream,
13+
output: outputStream,
14+
useGlobal: false
15+
});
16+
17+
let output = '';
18+
outputStream.setEncoding('utf8');
19+
outputStream.on('data', (data) => output += data);
20+
21+
r.on('exit', common.mustCall(() => {
22+
const results = output.split('\n').map((line) => {
23+
return line.replace(/\w*>\w*/, '').trim();
24+
});
25+
26+
assert.deepStrictEqual(results, ['undefined', 'true', 'true', '']);
27+
}));
28+
29+
inputStream.write('const isObject = (obj) => obj.constructor === Object;\n');
30+
inputStream.write('isObject({});\n');
31+
inputStream.write(`require('${fixture}').isObject({});\n`);
32+
r.close();

0 commit comments

Comments
 (0)