add search-list tests for 'dn' motion

This commit is contained in:
2026-02-14 20:56:11 +00:00
parent 1b07323e54
commit 3f6eaa730a
2 changed files with 64 additions and 2 deletions

View File

@@ -1,2 +1 @@
alpha world hellohello
test again

View File

@@ -5793,6 +5793,69 @@ struct
(actualString = expectedString (actualString = expectedString
andalso cursorIdx = expectedCursorIdx) andalso cursorIdx = expectedCursorIdx)
end) end)
, test "decrements matches after cursor position" (fn _ =>
let
(* arrange *)
val originalIdx = 6
val originalString = "hello world hello\n"
val app = TestUtils.init originalString
val app = AppWith.idx (app, originalIdx)
val app = TestUtils.updateMany (app, "/hello")
val app = AppUpdate.update (app, InputMsg.KEY_ENTER, Time.now ())
(* act *)
val newApp = TestUtils.updateMany (app, "dn")
(* assert *)
val oldSearchList = PersistentVector.toList (#searchList app)
val newSearchList = PersistentVector.toList (#searchList newApp)
val expectedOldSearchList =
[{start = 0, finish = 4}, {start = 12, finish = 16}]
val expectedNewSearchList =
[{start = 0, finish = 4}, {start = 6, finish = 10}]
val assertion =
oldSearchList = expectedOldSearchList
andalso newSearchList = expectedNewSearchList
in
(* assert *)
Expect.isTrue assertion
end)
, test "extends match when match should extend after deletion" (fn _ =>
let
(* arrange *)
val originalIdx = 5
val originalString = "hello hello\n"
val app = TestUtils.init originalString
val app = AppWith.idx (app, originalIdx)
val app = TestUtils.updateMany (app, "/(hello)+")
val app = AppUpdate.update (app, InputMsg.KEY_ENTER, Time.now ())
(* act *)
val newApp = TestUtils.updateMany (app, "dn")
(* assert *)
val oldSearchList = #searchList app
val oldSearchList = PersistentVector.toList oldSearchList
val newSearchList = #searchList newApp
val newSearchList = PersistentVector.toList newSearchList
val expectedOldSearchList =
[{start = 0, finish = 4}, {start = 6, finish = 10}]
val expectedNewSearchList = [{start = 0, finish = 9}]
val assertion =
oldSearchList = expectedOldSearchList
andalso newSearchList = expectedNewSearchList
in
Expect.isTrue assertion
end)
] ]
val dNDelete = describe "delete motion 'dN'" val dNDelete = describe "delete motion 'dN'"