提交 fd5789cc 编写于 作者: I isidor

output: buffered content more tests

上级 b9f8e8ab
......@@ -50,11 +50,11 @@ export class BufferedContent {
}
private trim(): void {
if (this.length < MAX_OUTPUT_LENGTH * 1.5) {
if (this.length < MAX_OUTPUT_LENGTH * 1.2) {
return;
}
while (this.length > MAX_OUTPUT_LENGTH && this.data.length) {
while (this.length > MAX_OUTPUT_LENGTH) {
this.dataIds.shift();
const removed = this.data.shift();
this.length -= removed.length;
......@@ -68,8 +68,8 @@ export class BufferedContent {
}
const id = this.idPool;
if (idx > 0) {
const value = strings.removeAnsiEscapeCodes(this.data.slice(idx).join(''));
if (idx >= 0) {
const value = strings.removeAnsiEscapeCodes(this.data.slice(idx + 1).join(''));
return { value, id, append: true };
} else {
const value = strings.removeAnsiEscapeCodes(this.data.join(''));
......
......@@ -20,16 +20,40 @@ suite('Workbench - Output Buffered Content', () => {
assert.equal(bufferedContent.getDelta(delta).value, '');
});
test('Buffered Content - Lots of output', () => {
test('Buffered Content - Appending Output', () => {
const bufferedContent = new BufferedContent();
bufferedContent.append('first');
const firstDelta = bufferedContent.getDelta();
bufferedContent.append('second');
bufferedContent.append('third');
const secondDelta = bufferedContent.getDelta(firstDelta);
assert.equal(secondDelta.append, true);
assert.equal(secondDelta.value, 'secondthird');
bufferedContent.append('fourth');
bufferedContent.append('fifth');
assert.equal(bufferedContent.getDelta(firstDelta).value, 'secondthirdfourthfifth');
assert.equal(bufferedContent.getDelta(secondDelta).value, 'fourthfifth');
});
test('Buffered Content - Lots of Output', () => {
const bufferedContent = new BufferedContent();
bufferedContent.append('first line');
const firstDelta = bufferedContent.getDelta();
for (var i = 0; i < 100000; i++) {
let longString = '';
for (var i = 0; i < 50000; i++) {
bufferedContent.append(i.toString());
longString += i.toString();
}
const secondDelta = bufferedContent.getDelta(firstDelta);
assert.equal(!!secondDelta.append, false);
assert.equal(secondDelta.value.substr(secondDelta.value.length - 5), '99999');
assert.equal(secondDelta.append, true);
assert.equal(secondDelta.value.substr(secondDelta.value.length - 5), '49999');
longString = longString + longString + longString + longString;
bufferedContent.append(longString);
bufferedContent.append(longString);
const thirdDelta = bufferedContent.getDelta(firstDelta);
assert.equal(!!thirdDelta.append, false);
assert.equal(thirdDelta.value.substr(thirdDelta.value.length - 5), '49999');
bufferedContent.clear();
assert.equal(bufferedContent.getDelta().value, '');
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册