From 074ba2bcde1101d8b25cd683366ab1d431c1c79b Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Fri, 26 Sep 2025 08:21:54 +0100 Subject: [PATCH] done adding tests for 'dw' motion --- test/normal-delete.sml | 116 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/test/normal-delete.sml b/test/normal-delete.sml index 1288af9..300927e 100644 --- a/test/normal-delete.sml +++ b/test/normal-delete.sml @@ -963,6 +963,122 @@ struct val actualString = LineGap.toString buffer + val stringIsExpected = expectedString = actualString + val cursorIsExpected = expectedCursor = cursorIdx + in + Expect.isTrue (stringIsExpected andalso cursorIsExpected) + end) + , test + "deletes until first punctuation char when on an alpha char \ + \and there is no space between alpha and punctuation" + (fn _ => + let + (* arrange *) + val originalString = "hello!world!again\n" + val app = TestUtils.init originalString + + (* act *) + val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "dw") + + (* assert *) + val expectedString = "!world!again\n" + val expectedCursor = 0 + + val actualString = LineGap.toString buffer + + val stringIsExpected = expectedString = actualString + val cursorIsExpected = expectedCursor = cursorIdx + in + Expect.isTrue (stringIsExpected andalso cursorIsExpected) + end) + , test + "deletes until first alpha char when on punctuation \ + \and there is no space between punctuation and alpha" + (fn _ => + let + (* arrange *) + val originalString = "!#%&QWERTY#!\n" + val app = TestUtils.init originalString + + (* act *) + val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "dw") + + (* assert *) + val expectedString = "QWERTY#!\n" + val expectedCursor = 0 + + val actualString = LineGap.toString buffer + + val stringIsExpected = expectedString = actualString + val cursorIsExpected = expectedCursor = cursorIdx + in + Expect.isTrue (stringIsExpected andalso cursorIsExpected) + end) + , test + "deletes until first alpha char \ + \when cursor is on space and next char is alpha" + (fn _ => + let + (* arrange *) + val originalString = "h ello\n" + val app = TestUtils.init originalString + val app = AppWith.idx (app, 1) + + (* act *) + val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "dw") + + (* assert *) + val expectedString = "hello\n" + val actualString = LineGap.toString buffer + val expectedCursor = 1 + + val stringIsExpected = expectedString = actualString + val cursorIsExpected = expectedCursor = cursorIdx + in + Expect.isTrue (stringIsExpected andalso cursorIsExpected) + end) + , test + "deletes until first alpha char \ + \when cursor is on space, many spaces are ahead, \ + \and first char after spaces is alpha" + (fn _ => + let + (* arrange *) + val originalString = "h ello\n" + val app = TestUtils.init originalString + val app = AppWith.idx (app, 3) + + (* act *) + val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "dw") + + (* assert *) + val expectedString = "h ello\n" + val actualString = LineGap.toString buffer + val expectedCursor = 3 + + val stringIsExpected = expectedString = actualString + val cursorIsExpected = expectedCursor = cursorIdx + in + Expect.isTrue (stringIsExpected andalso cursorIsExpected) + end) + , test + "deletes until first punctuation char \ + \when cursor is on space and next non-space char is punctuation" + (fn _ => + let + (* arrange *) + val originalString = "! @#$%\n" + val app = TestUtils.init originalString + val app = AppWith.idx (app, 2) + + (* act *) + val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "dw") + + (* assert *) + val expectedString = "! @#$%\n" + val actualString = LineGap.toString buffer + val expectedCursor = 2 + val stringIsExpected = expectedString = actualString val cursorIsExpected = expectedCursor = cursorIdx in