       sendInputs 'itemsIn', [4, 5], [7], [], [8, 9]
 
       changesFor("doubled").should.eql([0, 10, 14, 0, 18])
+
+    it 'collects all items from unpacked lists', ->
+
+      providedStreamReturnFunctions
+        unpackLists: (s) -> s.flatMap( (x) -> [].concat x)
+      providedAggregateFunctions
+        total: (s) -> s.scan (acc, x) -> acc + x
+
+      parseUserFunctions 'itemsIn = input'
+      parseUserFunctions 'items = unpackLists(itemsIn)'
+      parseUserFunctions 'tot = total(all_items)'
+      sendInputs 'itemsIn', [4, 5], [7], [], [8, 9]
+
+      changesFor("tot").should.eql([null, 9, 16, 33])
 
 
   describe 'updates dependent expressions and notifies changes', ->


  describe 'buffers value changes', ->

    it.skip 'for each input', ->
      providedStreamReturnFunctions
        unpackLists: (s) -> s.flatMap( (x) -> [].concat x)

      parseUserFunctions 'itemsIn = input'
      parseUserFunctions 'items = unpackLists(all_itemsIn)'
      parseUserFunctions 'doubled = items * 2'
      sendInputs 'itemsIn', [4, 5, 6], 7, [], [8, 9]

      bufferedChanges.should.eql [{itemsIn: [4, 5, 6]}, {items: 6}, {doubled: 12},
        {itemsIn: 7}, {items: 7}, {doubled: 14},
        {itemsIn: []},
        {itemsIn: [8, 9]}, {items: 9}, {doubled: 18}]



      inputs [2, 3, 4], [5, 6], [7]
      changesFor("sq").should.eql [[], [4, 9, 16], [25, 36], [49]]       # TODO should first be null or []?

    it 'uses items from unpacked lists', ->

      providedStreamReturnFunctions
        unpackLists: (s) -> s.flatMap( (x) -> [].concat x)
