From a0add68e927dee91091719c909369f36f4aa7a79 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Sat, 20 Sep 2025 17:59:22 +0100 Subject: [PATCH] begin adding normal-delete tests --- test/normal-delete.sml | 59 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/test/normal-delete.sml b/test/normal-delete.sml index 725fd33..ffc1fc3 100644 --- a/test/normal-delete.sml +++ b/test/normal-delete.sml @@ -1,2 +1,59 @@ structure NormalDelete = -struct open Railroad open Railroad.Test open InputMsg val tests = [] end +struct + open Railroad + open Railroad.Test + open InputMsg + + val dhDelete = describe "delete motion 'dh'" + [ test "does not delete when cursor is at index 0" (fn _ => + let + (* arrange *) + val originalString = "hello world\n" + val app = TestUtils.init originalString + val app = AppWith.idx (app, 0) + + (* act *) + val app = TestUtils.updateMany (app, "dh") + + (* assert *) + val expectedString = originalString + val actualString = LineGap.toString (#buffer app) + in + Expect.isTrue (expectedString = actualString) + end) + , test "does not delete when character before cursor is a newline" (fn _ => + let + (* arrange *) + val originalString = "hello\nworld\n" + val app = TestUtils.init originalString + val app = AppWith.idx (app, 6) + + (* act *) + val app = TestUtils.updateMany (app, "dh") + + (* assert *) + val expectedString = originalString + val actualString = LineGap.toString (#buffer app) + in + Expect.isTrue (expectedString = actualString) + end) + , test "deletes one char to the left when on a non-newline" (fn _ => + let + (* arrange *) + val originalString = "hello world\n" + val app = TestUtils.init originalString + val app = AppWith.idx (app, 5) + + (* act *) + val app = TestUtils.updateMany (app, "dh") + + (* assert *) + val expectedString = "hell world\n" + val actualString = LineGap.toString (#buffer app) + in + Expect.isTrue (expectedString = actualString) + end) + ] + + val tests = [dhDelete] +end