| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,8 @@ var fs = require('fs'); | |||
| 5 | 5 | var assert = require('assert'); | |
| 6 | 6 | var os = require('os'); | |
| 7 | 7 | var child_process = require('child_process'); | |
| 8 | + const stream = require('stream'); | ||
| 9 | + const util = require('util'); | ||
| 8 | 10 | ||
| 9 | 11 | ||
| 10 | 12 | exports.testDir = path.dirname(__filename); | |
@@ -449,3 +451,21 @@ exports.fileExists = function(pathname) { | |||
| 449 | 451 | exports.fail = function(msg) { | |
| 450 | 452 | assert.fail(null, null, msg); | |
| 451 | 453 | }; | |
| 454 | + | ||
| 455 | + | ||
| 456 | + // A stream to push an array into a REPL | ||
| 457 | + function ArrayStream() { | ||
| 458 | + this.run = function(data) { | ||
| 459 | + data.forEach(line => { | ||
| 460 | + this.emit('data', line + '\n'); | ||
| 461 | + }); | ||
| 462 | + }; | ||
| 463 | + } | ||
| 464 | + | ||
| 465 | + util.inherits(ArrayStream, stream.Stream); | ||
| 466 | + exports.ArrayStream = ArrayStream; | ||
| 467 | + ArrayStream.prototype.readable = true; | ||
| 468 | + ArrayStream.prototype.writable = true; | ||
| 469 | + ArrayStream.prototype.pause = function() {}; | ||
| 470 | + ArrayStream.prototype.resume = function() {}; | ||
| 471 | + ArrayStream.prototype.write = function() {}; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,24 +9,9 @@ common.refreshTmpDir(); | |||
| 9 | 9 | ||
| 10 | 10 | var repl = require('repl'); | |
| 11 | 11 | ||
| 12 | - // A stream to push an array into a REPL | ||
| 13 | - function ArrayStream() { | ||
| 14 | - this.run = function(data) { | ||
| 15 | - var self = this; | ||
| 16 | - data.forEach(function(line) { | ||
| 17 | - self.emit('data', line + '\n'); | ||
| 18 | - }); | ||
| 19 | - }; | ||
| 20 | - } | ||
| 21 | - util.inherits(ArrayStream, require('stream').Stream); | ||
| 22 | - ArrayStream.prototype.readable = true; | ||
| 23 | - ArrayStream.prototype.writable = true; | ||
| 24 | - ArrayStream.prototype.resume = function() {}; | ||
| 25 | - ArrayStream.prototype.write = function() {}; | ||
| 26 | - | ||
| 27 | 12 | var works = [['inner.one'], 'inner.o']; | |
| 28 | 13 | ||
| 29 | - var putIn = new ArrayStream(); | ||
| 14 | + const putIn = new common.ArrayStream(); | ||
| 30 | 15 | var testMe = repl.start('', putIn); | |
| 31 | 16 | ||
| 32 | 17 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,25 +1,13 @@ | |||
| 1 | - /* eslint-disable required-modules */ | ||
| 2 | 1 | 'use strict'; | |
| 2 | + const common = require('../common'); | ||
| 3 | 3 | var assert = require('assert'); | |
| 4 | 4 | var util = require('util'); | |
| 5 | 5 | var repl = require('repl'); | |
| 6 | 6 | ||
| 7 | - // A stream to push an array into a REPL | ||
| 8 | - function ArrayStream() { | ||
| 9 | - this.run = function(data) { | ||
| 10 | - var self = this; | ||
| 11 | - data.forEach(function(line) { | ||
| 12 | - self.emit('data', line + '\n'); | ||
| 13 | - }); | ||
| 14 | - }; | ||
| 15 | - } | ||
| 16 | - util.inherits(ArrayStream, require('stream').Stream); | ||
| 17 | - ArrayStream.prototype.readable = true; | ||
| 18 | - ArrayStream.prototype.writable = true; | ||
| 19 | - ArrayStream.prototype.resume = function() {}; | ||
| 20 | - ArrayStream.prototype.write = function() {}; | ||
| 7 | + // This test adds global variables | ||
| 8 | + common.globalCheck = false; | ||
| 21 | 9 | ||
| 22 | - var putIn = new ArrayStream(); | ||
| 10 | + const putIn = new common.ArrayStream(); | ||
| 23 | 11 | var testMe = repl.start('', putIn, null, true); | |
| 24 | 12 | ||
| 25 | 13 | test1(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,13 +1,10 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | var common = require('../common'), | |
| 3 | 3 | assert = require('assert'), | |
| 4 | - Stream = require('stream'), | ||
| 5 | 4 | repl = require('repl'); | |
| 6 | 5 | ||
| 7 | - // create a dummy stream that does nothing | ||
| 8 | - var stream = new Stream(); | ||
| 9 | - stream.write = stream.pause = stream.resume = function() {}; | ||
| 10 | - stream.readable = stream.writable = true; | ||
| 6 | + // Create a dummy stream that does nothing | ||
| 7 | + const stream = new common.ArrayStream(); | ||
| 11 | 8 | ||
| 12 | 9 | var r = repl.start({ | |
| 13 | 10 | input: stream, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,22 +5,7 @@ var common = require('../common'); | |||
| 5 | 5 | var util = require('util'); | |
| 6 | 6 | var repl = require('repl'); | |
| 7 | 7 | ||
| 8 | - // A stream to push an array into a REPL | ||
| 9 | - function ArrayStream() { | ||
| 10 | - this.run = function(data) { | ||
| 11 | - var self = this; | ||
| 12 | - data.forEach(function(line) { | ||
| 13 | - self.emit('data', line + '\n'); | ||
| 14 | - }); | ||
| 15 | - }; | ||
| 16 | - } | ||
| 17 | - util.inherits(ArrayStream, require('stream').Stream); | ||
| 18 | - ArrayStream.prototype.readable = true; | ||
| 19 | - ArrayStream.prototype.writable = true; | ||
| 20 | - ArrayStream.prototype.resume = function() {}; | ||
| 21 | - ArrayStream.prototype.write = function() {}; | ||
| 22 | - | ||
| 23 | - var putIn = new ArrayStream(); | ||
| 8 | + const putIn = new common.ArrayStream(); | ||
| 24 | 9 | var testMe = repl.start('', putIn); | |
| 25 | 10 | ||
| 26 | 11 | putIn.write = function(data) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,15 +1,12 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | var common = require('../common'), | |
| 3 | 3 | assert = require('assert'), | |
| 4 | - Stream = require('stream'), | ||
| 5 | 4 | repl = require('repl'), | |
| 6 | 5 | terminalExit = 0, | |
| 7 | 6 | regularExit = 0; | |
| 8 | 7 | ||
| 9 | - // create a dummy stream that does nothing | ||
| 10 | - var stream = new Stream(); | ||
| 11 | - stream.write = stream.pause = stream.resume = function() {}; | ||
| 12 | - stream.readable = stream.writable = true; | ||
| 8 | + // Create a dummy stream that does nothing | ||
| 9 | + const stream = new common.ArrayStream(); | ||
| 13 | 10 | ||
| 14 | 11 | function testTerminalMode() { | |
| 15 | 12 | var r1 = repl.start({ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,15 +1,12 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | var common = require('../common'), | |
| 3 | 3 | assert = require('assert'), | |
| 4 | - Stream = require('stream'), | ||
| 5 | 4 | repl = require('repl'); | |
| 6 | 5 | ||
| 7 | 6 | common.globalCheck = false; | |
| 8 | 7 | ||
| 9 | - // create a dummy stream that does nothing | ||
| 10 | - var stream = new Stream(); | ||
| 11 | - stream.write = stream.pause = stream.resume = function() {}; | ||
| 12 | - stream.readable = stream.writable = true; | ||
| 8 | + // Create a dummy stream that does nothing | ||
| 9 | + const stream = new common.ArrayStream(); | ||
| 13 | 10 | ||
| 14 | 11 | // 1, mostly defaults | |
| 15 | 12 | var r1 = repl.start({ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,12 +4,9 @@ common.globalCheck = false; | |||
| 4 | 4 | ||
| 5 | 5 | var assert = require('assert'); | |
| 6 | 6 | var repl = require('repl'); | |
| 7 | - var Stream = require('stream'); | ||
| 8 | 7 | ||
| 9 | - // create a dummy stream that does nothing | ||
| 10 | - var dummy = new Stream(); | ||
| 11 | - dummy.write = dummy.pause = dummy.resume = function() {}; | ||
| 12 | - dummy.readable = dummy.writable = true; | ||
| 8 | + // Create a dummy stream that does nothing | ||
| 9 | + const dummy = new common.ArrayStream(); | ||
| 13 | 10 | ||
| 14 | 11 | function testReset(cb) { | |
| 15 | 12 | var r = repl.start({ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,24 +11,12 @@ process.on('exit', () => { | |||
| 11 | 11 | assert.strictEqual(found, true); | |
| 12 | 12 | }); | |
| 13 | 13 | ||
| 14 | - // A stream to push an array into a REPL | ||
| 15 | - function ArrayStream() { | ||
| 16 | - this.run = function(data) { | ||
| 17 | - data.forEach(line => { | ||
| 18 | - this.emit('data', line + '\n'); | ||
| 19 | - }); | ||
| 20 | - }; | ||
| 21 | - } | ||
| 22 | - util.inherits(ArrayStream, require('stream').Stream); | ||
| 23 | - ArrayStream.prototype.readable = true; | ||
| 24 | - ArrayStream.prototype.writable = true; | ||
| 25 | - ArrayStream.prototype.resume = function() {}; | ||
| 26 | - ArrayStream.prototype.write = function(output) { | ||
| 14 | + common.ArrayStream.prototype.write = function(output) { | ||
| 27 | 15 | if (/var foo bar;/.test(output)) | |
| 28 | 16 | found = true; | |
| 29 | 17 | }; | |
| 30 | 18 | ||
| 31 | - const putIn = new ArrayStream(); | ||
| 19 | + const putIn = new common.ArrayStream(); | ||
| 32 | 20 | const testMe = repl.start('', putIn); | |
| 33 | 21 | let file = path.resolve(__dirname, '../fixtures/syntax/bad_syntax'); | |
| 34 | 22 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,32 +1,19 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | - require('../common'); | ||
| 3 | + const common = require('../common'); | ||
| 4 | 4 | const assert = require('assert'); | |
| 5 | 5 | const util = require('util'); | |
| 6 | 6 | const repl = require('repl'); | |
| 7 | 7 | ||
| 8 | 8 | var referenceErrorCount = 0; | |
| 9 | 9 | ||
| 10 | - // A stream to push an array into a REPL | ||
| 11 | - function ArrayStream() { | ||
| 12 | - this.run = function(data) { | ||
| 13 | - const self = this; | ||
| 14 | - data.forEach(function(line) { | ||
| 15 | - self.emit('data', line + '\n'); | ||
| 16 | - }); | ||
| 17 | - }; | ||
| 18 | - } | ||
| 19 | - util.inherits(ArrayStream, require('stream').Stream); | ||
| 20 | - ArrayStream.prototype.readable = true; | ||
| 21 | - ArrayStream.prototype.writable = true; | ||
| 22 | - ArrayStream.prototype.resume = function() {}; | ||
| 23 | - ArrayStream.prototype.write = function(msg) { | ||
| 10 | + common.ArrayStream.prototype.write = function(msg) { | ||
| 24 | 11 | if (msg.startsWith('ReferenceError: ')) { | |
| 25 | 12 | referenceErrorCount++; | |
| 26 | 13 | } | |
| 27 | 14 | }; | |
| 28 | 15 | ||
| 29 | - const putIn = new ArrayStream(); | ||
| 16 | + const putIn = new common.ArrayStream(); | ||
| 30 | 17 | const testMe = repl.start('', putIn); | |
| 31 | 18 | ||
| 32 | 19 | // https://github.com/nodejs/node/issues/3346 | |
| Back | FazBrowse Home | New Git URL |
0 commit comments