diff options
author | cjihrig <cjihrig@gmail.com> | 2015-11-25 16:38:01 -0500 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2015-11-26 21:16:08 -0500 |
commit | f2e319b7578326b0f5adb5c986533d3136404cbd (patch) | |
tree | 65711638400d72e0468ef2df38b7b376c0c79051 /test/parallel/test-repl-tab-complete-crash.js | |
parent | 1c8584997346d549dd5ff4bb787f48f52440a9cb (diff) | |
download | android-node-v8-f2e319b7578326b0f5adb5c986533d3136404cbd.tar.gz android-node-v8-f2e319b7578326b0f5adb5c986533d3136404cbd.tar.bz2 android-node-v8-f2e319b7578326b0f5adb5c986533d3136404cbd.zip |
test: move ArrayStream to common
A number of REPL tests define the same ArrayStream object. This
commit moves the repeated code into common.js.
PR-URL: https://github.com/nodejs/node/pull/4027
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'test/parallel/test-repl-tab-complete-crash.js')
-rw-r--r-- | test/parallel/test-repl-tab-complete-crash.js | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/test/parallel/test-repl-tab-complete-crash.js b/test/parallel/test-repl-tab-complete-crash.js index 85ab0577eb..484580f1e7 100644 --- a/test/parallel/test-repl-tab-complete-crash.js +++ b/test/parallel/test-repl-tab-complete-crash.js @@ -1,32 +1,19 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const util = require('util'); const repl = require('repl'); var referenceErrorCount = 0; -// A stream to push an array into a REPL -function ArrayStream() { - this.run = function(data) { - const self = this; - data.forEach(function(line) { - self.emit('data', line + '\n'); - }); - }; -} -util.inherits(ArrayStream, require('stream').Stream); -ArrayStream.prototype.readable = true; -ArrayStream.prototype.writable = true; -ArrayStream.prototype.resume = function() {}; -ArrayStream.prototype.write = function(msg) { +common.ArrayStream.prototype.write = function(msg) { if (msg.startsWith('ReferenceError: ')) { referenceErrorCount++; } }; -const putIn = new ArrayStream(); +const putIn = new common.ArrayStream(); const testMe = repl.start('', putIn); // https://github.com/nodejs/node/issues/3346 |