Last active
March 14, 2016 16:24
-
-
Save lance/6a474ad892c34eed9026 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 'use strict'; | |
| // Flags: --expose-internals | |
| const stream = require('stream'); | |
| const REPL = require('internal/repl'); | |
| const assert = require('assert'); | |
| testDefault(); | |
| testFalse(); | |
| function testDefault() { | |
| global.lunch = 'tacos'; | |
| const inputStream = new stream.PassThrough(); | |
| const outputStream = new stream.PassThrough(); | |
| outputStream.accum = ''; | |
| outputStream.on('data', (data) => { | |
| outputStream.accum += data; | |
| }); | |
| const opts = { | |
| input: inputStream, | |
| output: outputStream, | |
| useColors: false, | |
| terminal: false, | |
| prompt: '' | |
| }; | |
| REPL.createInternalRepl(process.env, opts, function(err, repl) { | |
| if (err) throw err; | |
| repl.write('global.lunch\n;'); | |
| assert.equal(outputStream.accum.trim(), '\'tacos\''); | |
| repl.close(); | |
| }); | |
| } | |
| function testFalse() { | |
| global.lunch = 'tacos'; | |
| const inputStream = new stream.PassThrough(); | |
| const outputStream = new stream.PassThrough(); | |
| outputStream.accum = ''; | |
| outputStream.on('data', (data) => { | |
| outputStream.accum += data; | |
| }); | |
| const opts = { | |
| input: inputStream, | |
| output: outputStream, | |
| useColors: false, | |
| terminal: false, | |
| useGlobal: false, | |
| prompt: '' | |
| }; | |
| REPL.createInternalRepl(process.env, opts, function(err, repl) { | |
| if (err) throw err; | |
| repl.write('global.lunch\n;'); | |
| assert.equal(outputStream.accum.trim(), 'undefined'); | |
| repl.close(); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment