CoffeeScriptRedux
CoffeeScriptRedux copied to clipboard
Something fishy with repl tests
Looking over test/repl.coffee
I am noticing some strange things. The first test:
testRepl 'starts with coffee prompt', (input, output) ->
eq 'coffee> ', output.lastWrite 1
Shouldn't that be eq 'coffee> ', output.lastWrite 0
instead (with a 0 instead of a 1)? Indeed, if I place a debugger and manually inspect output.written
I see: ["coffee> ", ""]
. That explains the index, but where is the comma coming from?
If I replace that first test with:
input = null
output = null
repl = null
beforeEach ->
input = new MockInputStream
output = new MockOutputStream
repl = Repl.start {input, output, historyFile}
afterEach ->
repl.emit 'exit'
test 'starts with coffee prompt', ->
eq 'coffee> ', output.lastWrite 0 # the index here is now correct
Then the index is correct and there is no comma. Thoughts on what is going on here?
That's a good question. These tests were pretty much ripped straight from jashkenas/coffee-script, so any errors in these probably also apply there. I will look into it soon. Feel free to send a PR if you think you fully understand it.
I'm not sure what is going on exactly, but I think there might be some listener leaks.