From 88e1ae00a9f175125acbbe850e9677cf9085d2dd Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Sun, 12 Oct 2025 08:42:05 +0100 Subject: [PATCH] progress adding additional tests for 'db' motion --- temp.txt | 2 +- test/normal-delete.sml | 97 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 1 deletion(-) diff --git a/temp.txt b/temp.txt index c90c515..9e3e294 100644 --- a/temp.txt +++ b/temp.txt @@ -1 +1 @@ -hello world again +hello!world!again diff --git a/test/normal-delete.sml b/test/normal-delete.sml index 5564684..819cf24 100644 --- a/test/normal-delete.sml +++ b/test/normal-delete.sml @@ -1905,6 +1905,103 @@ struct in Expect.isTrue (stringsAreExpected andalso cursorsAreExpected) end) + , test + "deletes newline and preceding word when cursor is \ + \on first character of word that has a newline before it" + (fn _ => + let + (* arrange *) + val originalString = "hello\nworld\nagain\n" + val app = TestUtils.init originalString + val app = AppWith.idx (app, 6) + + (* act *) + val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "db") + + (* assert *) + val expectedString = "world\nagain\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 first punctuation char when on an alpha char \ + \which is immediately preceded by a punctuation char" + (fn _ => + let + (* arrange *) + val originalString = "hello!world!again\n" + val app = TestUtils.init originalString + val app = AppWith.idx (app, 6) + + (* act *) + val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "db") + + (* assert *) + val expectedString = "helloworld!again\n" + val expectedCursor = 5 + + val actualString = LineGap.toString buffer + + val stringIsExpected = expectedString = actualString + val cursorIsExpected = expectedCursor = cursorIdx + in + Expect.isTrue (stringIsExpected andalso cursorIsExpected) + end) + , test + "deletes chars until reaching punctuation when \ + \cursor is on alpha char, preceded by more alpha chars, \ + \until preceded by punctuation" + (fn _ => + let + (* arrange *) + val originalString = "hello!world!again\n" + val app = TestUtils.init originalString + val app = AppWith.idx (app, 7) + + (* act *) + val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "db") + + (* assert *) + val expectedString = "hello!orld!again\n" + val expectedCursor = 6 + + val actualString = LineGap.toString buffer + + val stringIsExpected = expectedString = actualString + val cursorIsExpected = expectedCursor = cursorIdx + in + Expect.isTrue (stringIsExpected andalso cursorIsExpected) + end) + , test + "deletes alpha chars when on punctuation which is immediately preceded \ + \by more alpha chars, until preceded by punctuation again" + (fn _ => + let + (* arrange *) + val originalString = "hello!world!again\n" + val app = TestUtils.init originalString + val app = AppWith.idx (app, 11) + + (* act *) + val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "db") + + (* assert *) + val expectedString = "hello!!again\n" + val expectedCursor = 6 + + val actualString = LineGap.toString buffer + + val stringIsExpected = expectedString = actualString + val cursorIsExpected = expectedCursor = cursorIdx + in + Expect.isTrue (stringIsExpected andalso cursorIsExpected) + end) ] val tests =