Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

[WIP] Buffer stress tests #45

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions test/StressTest.re
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
open TestFramework;
open Vim;

let resetBuffer = () => Helpers.resetBuffer("test/testfile.txt");

describe("Stress", ({describe, _}) => {
describe("Stress with undo lots of lines", ({test, _}) => {
test("Add and remove 1 million lines", ({expect}) => {
let initialBuffer = resetBuffer();
expect.int(Buffer.getLineCount(initialBuffer)).toBe(3);
let buffer = Buffer.openFile("test/lines_100.txt");
expect.int(Buffer.getLineCount(buffer)).toBe(100);

// Now lets duplicate the buffer a bunch.
input("yG");
input("9999p");

expect.int(Buffer.getLineCount(buffer)).toBe(1000000);

input("u");

expect.int(Buffer.getLineCount(buffer)).toBe(100);
});

test("Add and remove 3 million lines", ({expect}) => {
let initialBuffer = resetBuffer();
expect.int(Buffer.getLineCount(initialBuffer)).toBe(3);
let buffer = Buffer.openFile("test/lines_100.txt");
expect.int(Buffer.getLineCount(buffer)).toBe(100);

// Now lets duplicate the buffer a bunch.
input("yG");
input("29999p");

expect.int(Buffer.getLineCount(buffer)).toBe(3000000);

input("u");

expect.int(Buffer.getLineCount(buffer)).toBe(100);
});

test("Add and remove 6 million lines", ({expect}) => {
let initialBuffer = resetBuffer();
expect.int(Buffer.getLineCount(initialBuffer)).toBe(3);
let buffer = Buffer.openFile("test/lines_100.txt");
expect.int(Buffer.getLineCount(buffer)).toBe(100);

// Now lets duplicate the buffer a bunch.
input("yG");
input("59999p");

expect.int(Buffer.getLineCount(buffer)).toBe(6000000);

input("u");

expect.int(Buffer.getLineCount(buffer)).toBe(100);
});
// test("Add and remove 10 million lines", ({expect}) => {
// let initialBuffer = resetBuffer();
// expect.int(Buffer.getLineCount(initialBuffer)).toBe(3);
// let buffer = Buffer.openFile("test/lines_100.txt");
// expect.int(Buffer.getLineCount(buffer)).toBe(100);
// // Now lets duplicate the buffer a bunch.
// input("yG");
// input("99999p");
// expect.int(Buffer.getLineCount(buffer)).toBe(10000000);
// input("u");
// expect.int(Buffer.getLineCount(buffer)).toBe(100);
// });
});

describe("Stress with large macros", ({test, _}) =>
test("Macro over 100 thousand lines", ({expect}) => {
let initialBuffer = resetBuffer();
expect.int(Buffer.getLineCount(initialBuffer)).toBe(3);
let buffer = Buffer.openFile("test/lines_100.txt");
expect.int(Buffer.getLineCount(buffer)).toBe(100);

// Now lets duplicate the buffer a bunch.
input("yG");
input("999p");

expect.int(Buffer.getLineCount(buffer)).toBe(100000);

// Reset the cursor and then record a macro
input("gg");
input("0");
input("qacwMyNewLine");
input("<esc>");
input("j0q");
input("99999@a");

let line = Buffer.getLine(buffer, 100000);
expect.string(line).toEqual("MyNewLine 100");
})
);
});