add additional test for 'dn' motion after finding bug, fixed bug (rewrote high-level delete fundtion in persistent-vector.sml to address it), and begin adding tests for 'dN' motion

This commit is contained in:
2026-03-28 00:45:08 +00:00
parent 3f6eaa730a
commit 9d46ec9f34
4 changed files with 118 additions and 67 deletions

View File

@@ -5824,7 +5824,6 @@ struct
(* assert *)
Expect.isTrue assertion
end)
, test "extends match when match should extend after deletion" (fn _ =>
let
(* arrange *)
@@ -5850,6 +5849,41 @@ struct
[{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)
, test "detects match when we delete in middle of it" (fn _ =>
let
(* arrange *)
val originalIdx = 1
val originalString = "hello 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}
, {start = 12, finish = 16}
]
val expectedNewSearchList =
[{start = 1, finish = 5}, {start = 7, finish = 11}]
val assertion =
oldSearchList = expectedOldSearchList
andalso newSearchList = expectedNewSearchList
@@ -5952,6 +5986,45 @@ struct
(actualString = expectedString
andalso cursorIdx = expectedCursorIdx)
end)
, test
"decrements subsequent matches in search list \
\when we delete prior to last match"
(fn _ =>
let
(* arrange *)
val originalIdx = 1
val originalString = "hello 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}
, {start = 12, finish = 16}
]
val expectedNewSearchList =
[{start = 5, finish = 9}, {start = 11, finish = 15}]
val assertion =
oldSearchList = expectedOldSearchList
andalso newSearchList = expectedNewSearchList
in
Expect.isTrue assertion
end)
]
val dfDelete = describe "delete motion 'df<char>'"