From 3b27e437bce285eaf80d34f8d4485e5f24483f6b Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Sat, 20 Sep 2025 23:59:14 +0100 Subject: [PATCH] add a failing test for 'dl' motion --- test/normal-delete.sml | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/test/normal-delete.sml b/test/normal-delete.sml index 3aa32a2..e18bf1c 100644 --- a/test/normal-delete.sml +++ b/test/normal-delete.sml @@ -115,5 +115,32 @@ struct end) ] - val tests = [dhDelete] + val dlDelete = describe "delete motion 'dl'" + [test + "deletes last char and moves cursor back by 1 \ + \when next char is a newline" + (fn _ => + let + (* arrange *) + val originalString = "hello\nworld\n" + val originalIdx = 4 + + val app = TestUtils.init originalString + val app = AppWith.idx (app, originalIdx) + + (* act *) + val {cursorIdx, buffer, ...} = TestUtils.updateMany (app, "dl") + + (* assert *) + val expectedString = "hell\nworld\n" + val actualString = LineGap.toString buffer + val stringIsExpected = expectedString = actualString + + val expectedCursorIdx = originalIdx - 1 + val cursorIdxIsExpected = expectedCursorIdx = cursorIdx + in + Expect.isTrue (stringIsExpected andalso cursorIdxIsExpected) + end)] + + val tests = [dhDelete, dlDelete] end