anchor.diff:            chunkStack.finalize();
   
             var lastChunk;
  -          if (chunkStack.totalByteLength > 0) {
  -            assert(chunkStack.length == 1);
  +          if (chunkStack.length == 1) {
               lastChunk = chunkStack.removeSublist(0, chunkStack.length).first;
             } else {
  -            lastChunk = new ResumableChunk([], 0, 0);
  +            completer.completeError(new StateError(
  +                'Resumable uploads need to result in at least one non-empty '
  +                'chunk at the end.'));
  +            return;
             }
             var end = lastChunk.endOfChunk;
   
  
positive.code:   // Currently accumulated data.
    List<List<int>> _byteArrays = [];
    int _length = 0;
    int _totalLength = 0;
    int _offset = 0;
  
    bool _finalized = false;
  
    ChunkStack(this._chunkSize);
  
    int get length => _chunkStack.length;
  
    int get totalByteLength => _offset;
  
    /**
     * Returns the chunks [from] ... [to] and deletes it from the stack.
  
negative.code: 
          // Upload all but the last chunk.
          // The final send will be done in the [onDone] handler.
          bool hasPartialChunk = chunkStack.hasPartialChunk;
          if (chunkStack.length > 1 ||
              (chunkStack.length == 1 && hasPartialChunk)) {
            // Pause the input stream.
            subscription.pause();
  
            // Upload all chunks except the last one.
            var fullChunks;
            if (hasPartialChunk) {
              fullChunks = chunkStack.removeSublist(0, chunkStack.length);
            } else {
              fullChunks = chunkStack.removeSublist(0, chunkStack.length - 1);
            }
            Future.forEach(fullChunks,
                           (c) => _uploadChunkDrained(uploadUri, c)).then((_) {
              // All chunks uploaded, we can continue consuming data.
  