From d2f32c15124f92a35d2c41c82e755d7bcce43159 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Sat, 3 Jan 2026 08:39:41 +0000 Subject: [PATCH] add tests for 'da' motion, finishing all delete-tests --- test/normal-delete.sml | 77 ++++++++++++++++++++++++++++++++++++++++++ todo.md | 7 +--- 2 files changed, 78 insertions(+), 6 deletions(-) diff --git a/test/normal-delete.sml b/test/normal-delete.sml index 334c762..a85689c 100644 --- a/test/normal-delete.sml +++ b/test/normal-delete.sml @@ -5151,6 +5151,82 @@ struct end) ] + val daParenDelete = describe "delete motion 'da('" + [ test "does not delete when there is no ( after the cursor" (fn _ => + let + (* arrange *) + val originalString = " ( ) hello\n" + val app = TestUtils.init originalString + val app = AppWith.idx (app, 7) + + (* act *) + val {buffer, ...} = TestUtils.updateMany (app, "da(") + + (* assert *) + val expectedString = originalString + val actualString = LineGap.toString buffer + in + Expect.isTrue (expectedString = actualString) + end) + , test + "deletes pair after cursor when there is a pair \ + \before the cursor and after the cursor" + (fn _ => + let + (* arrange *) + val originalString = " ( abc ) xyz ( def )\n" + val app = TestUtils.init originalString + val app = AppWith.idx (app, 9) + + (* act *) + val {buffer, ...} = TestUtils.updateMany (app, "da(") + + (* assert *) + val expectedString = " ( abc ) xyz \n" + val actualString = LineGap.toString buffer + in + Expect.isTrue (expectedString = actualString) + end) + , test + "deletes outer parens when cursor is in \ + \outer paren, and there is an inner paren after cursor" + (fn _ => + let + (* arrange *) + val originalString = "( ( hello ) )\n" + val app = TestUtils.init originalString + val app = AppWith.idx (app, 1) + + (* act *) + val {buffer, ...} = TestUtils.updateMany (app, "da(") + + (* assert *) + val expectedString = "\n" + val actualString = LineGap.toString buffer + in + Expect.isTrue (expectedString = actualString) + end) + , test + "deletes inner parren when cursor is in inner paren-pair, \ + \and there is an outer paren above this inner paren" + (fn _ => + let + (* arrange *) + val originalString = "( ( hello ) )\n" + val app = TestUtils.init originalString + val app = AppWith.idx (app, 5) + + (* act *) + val {buffer, ...} = TestUtils.updateMany (app, "da(") + + (* assert *) + val expectedString = "( )\n" + val actualString = LineGap.toString buffer + in + Expect.isTrue (expectedString = actualString) + end) + ] + val tests = [ dhDelete , dlDelete @@ -5182,5 +5258,6 @@ struct , daWDelete , pairDelete , diParenDelete + , daParenDelete ] end diff --git a/todo.md b/todo.md index bd33b5d..f3e7568 100644 --- a/todo.md +++ b/todo.md @@ -1,8 +1,3 @@ # To-do list -- Add tests for: - - `da` - - Afterwards, add tests for yanking. - - Add yank commands like yh/yj/yk/yl as well and test them too. +- Add yank commands like yh/yj/yk/yl as well and then add tests for yanking.