diff --git a/temp.txt b/temp.txt index 3b18e51..0dac0f6 100644 --- a/temp.txt +++ b/temp.txt @@ -1 +1 @@ -hello world +hey hello diff --git a/test/normal-delete.sml b/test/normal-delete.sml index f4bfe2b..cd68cd8 100644 --- a/test/normal-delete.sml +++ b/test/normal-delete.sml @@ -3690,6 +3690,141 @@ struct end) ] + val dFDelete = describe "delete motion 'dF'" + [ test + "does not delete when there is no occurrence of \ + \before cursor position" + (fn _ => + let + (* arrange *) + val originalString = "hello world\n" + val app = TestUtils.init originalString + val app = AppWith.idx (app, 0) + + (* act *) + val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "dFq") + + (* assert *) + val actualString = LineGap.toString buffer + val expectedString = originalString + val expectedCursorIdx = 0 + in + Expect.isTrue + (actualString = expectedString + andalso cursorIdx = expectedCursorIdx) + end) + , test + "does not delete when cursor is at first occurrence of in buffer" + (fn _ => + let + (* arrange *) + val originalString = "hello world\n" + val app = TestUtils.init originalString + val app = AppWith.idx (app, 6) + + (* act *) + val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "dFw") + + (* assert *) + val actualString = LineGap.toString buffer + val expectedString = originalString + val expectedCursorIdx = 6 + in + Expect.isTrue + (actualString = expectedString + andalso cursorIdx = expectedCursorIdx) + end) + , test + "deletes from cursor position to previous when \ + \there is an ocurrence of before cursor's position on same line" + (fn _ => + let + (* arrange *) + val originalString = "hey hello\n" + val app = TestUtils.init originalString + val app = AppWith.idx (app, 5) + + (* act *) + val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "dFy") + + (* assert *) + val actualString = LineGap.toString buffer + val expectedString = "heello\n" + val expectedCursorIdx = 2 + in + Expect.isTrue + (actualString = expectedString + andalso cursorIdx = expectedCursorIdx) + end) + , test + "deletes up to when the previous occurrence of \ + \is before a newline" + (fn _ => + let + (* arrange *) + val originalString = "hello\nworld\n" + val app = TestUtils.init originalString + val app = AppWith.idx (app, 7) + + (* act *) + val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "dFl") + + (* assert *) + val actualString = LineGap.toString buffer + val expectedString = "helorld\n" + val expectedCursorIdx = 3 + in + Expect.isTrue + (actualString = expectedString + andalso cursorIdx = expectedCursorIdx) + end) + , test + "deletes from cursor's position to second occurrence of \ + \if motion has a count of 2" + (fn _ => + let + (* arrange *) + val originalString = "hello\nworld\n" + val app = TestUtils.init originalString + val app = AppWith.idx (app, 9) + + (* act *) + val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "2dFo") + + (* assert *) + val actualString = LineGap.toString buffer + val expectedString = "hellld\n" + val expectedCursorIdx = 4 + in + Expect.isTrue + (actualString = expectedString + andalso cursorIdx = expectedCursorIdx) + end) + , test + "deletes from cursor's position to first occurrence of \ + \if motion has a count greater than \ + \the number of occurences of , before the cursor" + (fn _ => + let + (* arrange *) + val originalString = "hello\nworld\n" + val app = TestUtils.init originalString + val app = AppWith.idx (app, 7) + + (* act *) + val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "99dFl") + + (* assert *) + val actualString = LineGap.toString buffer + val expectedString = "heorld\n" + val expectedCursorIdx = 2 + in + Expect.isTrue + (actualString = expectedString + andalso cursorIdx = expectedCursorIdx) + end) + ] + val tests = [ dhDelete , dlDelete @@ -3713,5 +3848,6 @@ struct , dNDelete , dfDelete , dtDelete + , dFDelete ] end