
var tape = require('tape')
var many = require('../')
var pull = require('pull-stream')

tape('add after stream creation', function (t) {

  var m = many()

  pull(
    m,
    pull.collect(function (err, ary) {
      t.notOk(err)
      t.deepEqual(ary.sort(), [1,2,3,4,5,6])
      t.end()
    })
  )

  m.add(pull.values([1,2,3]))
  m.add(pull.values([4,5,6]))
  m.add()

})

tape('add after stream creation', function (t) {

  var m = many()

  pull(
    m,
    pull.collect(function (err, ary) {
      t.notOk(err)
      t.deepEqual(ary.sort(), [])
      t.end()
    })
  )

  m.add()

})


@@ -569,24 +569,555 @@
  %7D)%0A  )%0A%0A  m.add()%0A%0A%7D)%0A%0A
+tape('do not close inputs until the last minute', function (t) %7B%0A%0A  var m = many()%0A  var seen = %5B%5D%0A%0A  pull(%0A    m,%0A    pull.through(function (data) %7B%0A      //wait until the last message to end inputs.%0A      console.log('seen', data)%0A      seen.push(data)%0A      if(data %3E= 6) m.cap()%0A    %7D),%0A    pull.collect(function (err, ary) %7B%0A      t.notOk(err)%0A      t.deepEqual(ary.sort(), %5B1,2,3,4,5,6%5D)%0A      t.deepEqual(seen.sort(), %5B1,2,3,4,5,6%5D)%0A      t.end()%0A    %7D)%0A  )%0A%0A  m.add(pull.values(%5B1,2,3%5D))%0A  m.add(pull.values(%5B4,5,6%5D))%0A%0A%7D)%0A%0A

test for capping late