From 9e6d41c94c742f615352e19f7239c46ac8d22577 Mon Sep 17 00:00:00 2001 From: CrossR Date: Tue, 9 Jul 2019 22:21:58 +0100 Subject: [PATCH 1/4] Start work on stress tests. --- test/StressTest.re | 78 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 test/StressTest.re diff --git a/test/StressTest.re b/test/StressTest.re new file mode 100644 index 0000000..05a72cb --- /dev/null +++ b/test/StressTest.re @@ -0,0 +1,78 @@ +open TestFramework; +open Vim; + +let resetBuffer = () => Helpers.resetBuffer("test/testfile.txt"); + +describe("Stress", ({describe, _}) => { + describe("Adding lots of lines", ({test, _}) => { + test("Adding 1 million lines", ({expect}) => { + + let _ = resetBuffer(); + let buffer = Buffer.openFile("test/lines_100.txt"); + + // Now lets duplicate the buffer a bunch. + input("yG"); + input("9999p"); + + expect.int(Buffer.getLineCount(buffer)).toBe(1000000); + }); + + test("Repeat adding 1 million lines", ({expect}) => { + + let _ = resetBuffer(); + let buffer = Buffer.openFile("test/lines_100.txt"); + + // Now lets duplicate the buffer a bunch. + input("yG"); + input("9999p"); + + expect.int(Buffer.getLineCount(buffer)).toBe(1000000); + }); + + // test("Undoing 1 million lines", ({expect}) => { + + // let _ = resetBuffer(); + // let buffer = Buffer.openFile("test/lines_100.txt") + + // // Now lets duplicate the buffer a bunch. + // input("yG"); + // input("9999p"); + + // expect.int(Buffer.getLineCount(buffer)).toBe(1000000); + + // // Okay, now lets issue an undo and make sure we don't crash. + // input("u"); + + // expect.int(Buffer.getLineCount(buffer)).toBe(100); + // }); + + // test("Adding 10 million lines", ({expect}) => { + + // let _ = resetBuffer(); + // let buffer = Buffer.openFile("test/lines_100.txt"); + + // // Now lets duplicate the buffer a bunch. + // input("yG"); + // input("99999p"); + + // expect.int(Buffer.getLineCount(buffer)).toBe(10000000); + // }); + + // test("Undoing 10 million lines", ({expect}) => { + + // let _ = resetBuffer(); + // let buffer = Buffer.openFile("test/lines_100.txt") + + // // Now lets duplicate the buffer a bunch. + // input("yG"); + // input("99999p"); + + // expect.int(Buffer.getLineCount(buffer)).toBe(10000000); + + // // Okay, now lets issue an undo and make sure we don't crash. + // input("u"); + + // expect.int(Buffer.getLineCount(buffer)).toBe(100); + // }); + }); +}); From a6c1cec01738a657dbdb2909586e8a5b964b5b5f Mon Sep 17 00:00:00 2001 From: CrossR Date: Tue, 9 Jul 2019 22:48:48 +0100 Subject: [PATCH 2/4] Add further checks to initial state. --- test/StressTest.re | 54 ++++++---------------------------------------- 1 file changed, 6 insertions(+), 48 deletions(-) diff --git a/test/StressTest.re b/test/StressTest.re index 05a72cb..0f70c19 100644 --- a/test/StressTest.re +++ b/test/StressTest.re @@ -7,8 +7,10 @@ describe("Stress", ({describe, _}) => { describe("Adding lots of lines", ({test, _}) => { test("Adding 1 million lines", ({expect}) => { - let _ = resetBuffer(); + 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"); @@ -19,8 +21,10 @@ describe("Stress", ({describe, _}) => { test("Repeat adding 1 million lines", ({expect}) => { - let _ = resetBuffer(); + 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"); @@ -28,51 +32,5 @@ describe("Stress", ({describe, _}) => { expect.int(Buffer.getLineCount(buffer)).toBe(1000000); }); - - // test("Undoing 1 million lines", ({expect}) => { - - // let _ = resetBuffer(); - // let buffer = Buffer.openFile("test/lines_100.txt") - - // // Now lets duplicate the buffer a bunch. - // input("yG"); - // input("9999p"); - - // expect.int(Buffer.getLineCount(buffer)).toBe(1000000); - - // // Okay, now lets issue an undo and make sure we don't crash. - // input("u"); - - // expect.int(Buffer.getLineCount(buffer)).toBe(100); - // }); - - // test("Adding 10 million lines", ({expect}) => { - - // let _ = resetBuffer(); - // let buffer = Buffer.openFile("test/lines_100.txt"); - - // // Now lets duplicate the buffer a bunch. - // input("yG"); - // input("99999p"); - - // expect.int(Buffer.getLineCount(buffer)).toBe(10000000); - // }); - - // test("Undoing 10 million lines", ({expect}) => { - - // let _ = resetBuffer(); - // let buffer = Buffer.openFile("test/lines_100.txt") - - // // Now lets duplicate the buffer a bunch. - // input("yG"); - // input("99999p"); - - // expect.int(Buffer.getLineCount(buffer)).toBe(10000000); - - // // Okay, now lets issue an undo and make sure we don't crash. - // input("u"); - - // expect.int(Buffer.getLineCount(buffer)).toBe(100); - // }); }); }); From 7a1a0485e4ea5ca12bea145991bec873db77b881 Mon Sep 17 00:00:00 2001 From: CrossR Date: Wed, 10 Jul 2019 00:39:58 +0100 Subject: [PATCH 3/4] Add different levels of undo tests. --- test/StressTest.re | 58 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/test/StressTest.re b/test/StressTest.re index 0f70c19..e37af50 100644 --- a/test/StressTest.re +++ b/test/StressTest.re @@ -3,10 +3,9 @@ open Vim; let resetBuffer = () => Helpers.resetBuffer("test/testfile.txt"); -describe("Stress", ({describe, _}) => { - describe("Adding lots of lines", ({test, _}) => { - test("Adding 1 million lines", ({expect}) => { - +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"); @@ -17,10 +16,30 @@ describe("Stress", ({describe, _}) => { input("9999p"); expect.int(Buffer.getLineCount(buffer)).toBe(1000000); + + input("u"); + + expect.int(Buffer.getLineCount(buffer)).toBe(100); }); - test("Repeat adding 1 million lines", ({expect}) => { + 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"); @@ -28,9 +47,30 @@ describe("Stress", ({describe, _}) => { // Now lets duplicate the buffer a bunch. input("yG"); - input("9999p"); + input("59999p"); - expect.int(Buffer.getLineCount(buffer)).toBe(1000000); + 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); + // }); + }) +); \ No newline at end of file From fe6273db5ca2c2c80e84ce902a1e1b28b5a49f49 Mon Sep 17 00:00:00 2001 From: CrossR Date: Wed, 10 Jul 2019 00:55:40 +0100 Subject: [PATCH 4/4] Add a macro test. --- test/StressTest.re | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/test/StressTest.re b/test/StressTest.re index e37af50..c8192e8 100644 --- a/test/StressTest.re +++ b/test/StressTest.re @@ -3,7 +3,7 @@ open Vim; let resetBuffer = () => Helpers.resetBuffer("test/testfile.txt"); -describe("Stress", ({describe, _}) => +describe("Stress", ({describe, _}) => { describe("Stress with undo lots of lines", ({test, _}) => { test("Add and remove 1 million lines", ({expect}) => { let initialBuffer = resetBuffer(); @@ -55,22 +55,43 @@ describe("Stress", ({describe, _}) => 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); // }); - }) -); \ No newline at end of file + }); + + 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(""); + input("j0q"); + input("99999@a"); + + let line = Buffer.getLine(buffer, 100000); + expect.string(line).toEqual("MyNewLine 100"); + }) + ); +}); \ No newline at end of file