CoffeeScriptRedux icon indicating copy to clipboard operation
CoffeeScriptRedux copied to clipboard

Something fishy with repl tests

Open ghempton opened this issue 11 years ago • 2 comments

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?

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/896924-something-fishy-with-repl-tests?utm_campaign=plugin&utm_content=tracker%2F33145&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F33145&utm_medium=issues&utm_source=github).

ghempton avatar Sep 02 '13 08:09 ghempton

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.

michaelficarra avatar Sep 02 '13 08:09 michaelficarra

I'm not sure what is going on exactly, but I think there might be some listener leaks.

ghempton avatar Sep 02 '13 17:09 ghempton