|
@ -26,9 +26,9 @@ var repl = require('repl'); |
|
|
|
|
|
|
|
|
// A stream to push an array into a REPL
|
|
|
// A stream to push an array into a REPL
|
|
|
function ArrayStream() { |
|
|
function ArrayStream() { |
|
|
this.run = function (data) { |
|
|
this.run = function(data) { |
|
|
var self = this; |
|
|
var self = this; |
|
|
data.forEach(function (line) { |
|
|
data.forEach(function(line) { |
|
|
self.emit('data', line); |
|
|
self.emit('data', line); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
@ -36,11 +36,11 @@ function ArrayStream() { |
|
|
util.inherits(ArrayStream, require('stream').Stream); |
|
|
util.inherits(ArrayStream, require('stream').Stream); |
|
|
ArrayStream.prototype.readable = true; |
|
|
ArrayStream.prototype.readable = true; |
|
|
ArrayStream.prototype.writable = true; |
|
|
ArrayStream.prototype.writable = true; |
|
|
ArrayStream.prototype.resume = function () {}; |
|
|
ArrayStream.prototype.resume = function() {}; |
|
|
ArrayStream.prototype.write = function () {}; |
|
|
ArrayStream.prototype.write = function() {}; |
|
|
|
|
|
|
|
|
var works = [ [ 'inner.one' ], 'inner.o' ]; |
|
|
var works = [['inner.one'], 'inner.o']; |
|
|
var doesNotBreak = [ [], 'inner.o' ]; |
|
|
var doesNotBreak = [[], 'inner.o']; |
|
|
|
|
|
|
|
|
var putIn = new ArrayStream(); |
|
|
var putIn = new ArrayStream(); |
|
|
var testMe = repl.start('', putIn); |
|
|
var testMe = repl.start('', putIn); |
|
@ -49,14 +49,15 @@ var testMe = repl.start('', putIn); |
|
|
putIn.run(['.clear']); |
|
|
putIn.run(['.clear']); |
|
|
putIn.run([ |
|
|
putIn.run([ |
|
|
'var inner = {', |
|
|
'var inner = {', |
|
|
'one:1']); |
|
|
'one:1' |
|
|
testMe.complete('inner.o', function (error, data) { |
|
|
]); |
|
|
|
|
|
testMe.complete('inner.o', function(error, data) { |
|
|
assert.deepEqual(data, doesNotBreak); |
|
|
assert.deepEqual(data, doesNotBreak); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// Tab Complete will return globaly scoped variables
|
|
|
// Tab Complete will return globaly scoped variables
|
|
|
putIn.run(['};']); |
|
|
putIn.run(['};']); |
|
|
testMe.complete('inner.o', function (error, data) { |
|
|
testMe.complete('inner.o', function(error, data) { |
|
|
assert.deepEqual(data, works); |
|
|
assert.deepEqual(data, works); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -66,8 +67,9 @@ putIn.run(['.clear']); |
|
|
putIn.run([ |
|
|
putIn.run([ |
|
|
'var inner = ( true ' , |
|
|
'var inner = ( true ' , |
|
|
'?', |
|
|
'?', |
|
|
'{one: 1} : ']); |
|
|
'{one: 1} : ' |
|
|
testMe.complete('inner.o', function (error, data) { |
|
|
]); |
|
|
|
|
|
testMe.complete('inner.o', function(error, data) { |
|
|
assert.deepEqual(data, doesNotBreak); |
|
|
assert.deepEqual(data, doesNotBreak); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -76,15 +78,16 @@ putIn.run(['.clear']); |
|
|
// Tab Complete will return a simple local variable
|
|
|
// Tab Complete will return a simple local variable
|
|
|
putIn.run([ |
|
|
putIn.run([ |
|
|
'var top = function () {', |
|
|
'var top = function () {', |
|
|
'var inner = {one:1};']); |
|
|
'var inner = {one:1};' |
|
|
testMe.complete('inner.o', function (error, data) { |
|
|
]); |
|
|
|
|
|
testMe.complete('inner.o', function(error, data) { |
|
|
assert.deepEqual(data, works); |
|
|
assert.deepEqual(data, works); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// When you close the function scope tab complete will not return the
|
|
|
// When you close the function scope tab complete will not return the
|
|
|
// locally scoped variable
|
|
|
// locally scoped variable
|
|
|
putIn.run(['};']); |
|
|
putIn.run(['};']); |
|
|
testMe.complete('inner.o', function (error, data) { |
|
|
testMe.complete('inner.o', function(error, data) { |
|
|
assert.deepEqual(data, doesNotBreak); |
|
|
assert.deepEqual(data, doesNotBreak); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -95,8 +98,9 @@ putIn.run([ |
|
|
'var top = function () {', |
|
|
'var top = function () {', |
|
|
'var inner = {', |
|
|
'var inner = {', |
|
|
' one:1', |
|
|
' one:1', |
|
|
'};']); |
|
|
'};' |
|
|
testMe.complete('inner.o', function (error, data) { |
|
|
]); |
|
|
|
|
|
testMe.complete('inner.o', function(error, data) { |
|
|
assert.deepEqual(data, works); |
|
|
assert.deepEqual(data, works); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -108,8 +112,9 @@ putIn.run([ |
|
|
'var top = function (one, two) {', |
|
|
'var top = function (one, two) {', |
|
|
'var inner = {', |
|
|
'var inner = {', |
|
|
' one:1', |
|
|
' one:1', |
|
|
'};']); |
|
|
'};' |
|
|
testMe.complete('inner.o', function (error, data) { |
|
|
]); |
|
|
|
|
|
testMe.complete('inner.o', function(error, data) { |
|
|
assert.deepEqual(data, works); |
|
|
assert.deepEqual(data, works); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -122,8 +127,9 @@ putIn.run([ |
|
|
'(function test () {', |
|
|
'(function test () {', |
|
|
'var inner = {', |
|
|
'var inner = {', |
|
|
' one:1', |
|
|
' one:1', |
|
|
'};']); |
|
|
'};' |
|
|
testMe.complete('inner.o', function (error, data) { |
|
|
]); |
|
|
|
|
|
testMe.complete('inner.o', function(error, data) { |
|
|
assert.deepEqual(data, works); |
|
|
assert.deepEqual(data, works); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -137,8 +143,9 @@ putIn.run([ |
|
|
' one, two) {', |
|
|
' one, two) {', |
|
|
'var inner = {', |
|
|
'var inner = {', |
|
|
' one:1', |
|
|
' one:1', |
|
|
'};']); |
|
|
'};' |
|
|
testMe.complete('inner.o', function (error, data) { |
|
|
]); |
|
|
|
|
|
testMe.complete('inner.o', function(error, data) { |
|
|
assert.deepEqual(data, doesNotBreak); |
|
|
assert.deepEqual(data, doesNotBreak); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -151,8 +158,9 @@ putIn.run([ |
|
|
'{', |
|
|
'{', |
|
|
'var inner = {', |
|
|
'var inner = {', |
|
|
' one:1', |
|
|
' one:1', |
|
|
'};']); |
|
|
'};' |
|
|
testMe.complete('inner.o', function (error, data) { |
|
|
]); |
|
|
|
|
|
testMe.complete('inner.o', function(error, data) { |
|
|
assert.deepEqual(data, doesNotBreak); |
|
|
assert.deepEqual(data, doesNotBreak); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -166,8 +174,9 @@ putIn.run([ |
|
|
'{', |
|
|
'{', |
|
|
'var inner = {', |
|
|
'var inner = {', |
|
|
' one:1', |
|
|
' one:1', |
|
|
'};']); |
|
|
'};' |
|
|
testMe.complete('inner.o', function (error, data) { |
|
|
]); |
|
|
|
|
|
testMe.complete('inner.o', function(error, data) { |
|
|
assert.deepEqual(data, doesNotBreak); |
|
|
assert.deepEqual(data, doesNotBreak); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|