-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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]>
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
'use strict'; | ||
module.exports.isObject = (obj) => obj.constructor === Object; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use strict'; | ||
// Refs: https://github.com/nodejs/node/issues/7788 | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const path = require('path'); | ||
const repl = require('repl'); | ||
const stream = require('stream'); | ||
const inputStream = new stream.PassThrough(); | ||
const outputStream = new stream.PassThrough(); | ||
const fixture = path.join(common.fixturesDir, 'is-object.js'); | ||
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(() => { | ||
const results = output.split('\n').map((line) => { | ||
return line.replace(/\w*>\w*/, '').trim(); | ||
}); | ||
|
||
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(); |