done adding search-list related tests for 'dN' motion
This commit is contained in:
@@ -5986,7 +5986,6 @@ struct
|
|||||||
(actualString = expectedString
|
(actualString = expectedString
|
||||||
andalso cursorIdx = expectedCursorIdx)
|
andalso cursorIdx = expectedCursorIdx)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
, test
|
, test
|
||||||
"decrements subsequent matches in search list \
|
"decrements subsequent matches in search list \
|
||||||
\when we delete prior to last match"
|
\when we delete prior to last match"
|
||||||
@@ -6019,6 +6018,103 @@ struct
|
|||||||
val expectedNewSearchList =
|
val expectedNewSearchList =
|
||||||
[{start = 5, finish = 9}, {start = 11, finish = 15}]
|
[{start = 5, finish = 9}, {start = 11, finish = 15}]
|
||||||
|
|
||||||
|
val assertion =
|
||||||
|
oldSearchList = expectedOldSearchList
|
||||||
|
andalso newSearchList = expectedNewSearchList
|
||||||
|
in
|
||||||
|
Expect.isTrue assertion
|
||||||
|
end)
|
||||||
|
, test "recognises new match when there is a match after deletion" (fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalIdx = 8
|
||||||
|
val originalString = "hhello, ello\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 = 1, finish = 5}]
|
||||||
|
val expectedNewSearchList = [{start = 0, finish = 4}]
|
||||||
|
|
||||||
|
val assertion =
|
||||||
|
oldSearchList = expectedOldSearchList
|
||||||
|
andalso newSearchList = expectedNewSearchList
|
||||||
|
in
|
||||||
|
Expect.isTrue assertion
|
||||||
|
end)
|
||||||
|
, test
|
||||||
|
"shortens existing match when existing match should shorten after deletion"
|
||||||
|
(fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalIdx = 7
|
||||||
|
val originalString = "test ooooooo hi there\n"
|
||||||
|
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
val app = AppWith.idx (app, originalIdx)
|
||||||
|
|
||||||
|
val app = TestUtils.updateMany (app, "/o+")
|
||||||
|
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 = 5, finish = 11}]
|
||||||
|
val expectedNewSearchList = [{start = 5, finish = 9}]
|
||||||
|
|
||||||
|
val assertion =
|
||||||
|
oldSearchList = expectedOldSearchList
|
||||||
|
andalso newSearchList = expectedNewSearchList
|
||||||
|
in
|
||||||
|
Expect.isTrue assertion
|
||||||
|
end)
|
||||||
|
, test
|
||||||
|
"deletes match in search list \
|
||||||
|
\when match no longer exists in buffer after deletion"
|
||||||
|
(fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalIdx = 9
|
||||||
|
val originalString = "hello world test again\n"
|
||||||
|
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
val app = AppWith.idx (app, originalIdx)
|
||||||
|
|
||||||
|
val app = TestUtils.updateMany (app, "/o")
|
||||||
|
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 = 4, finish = 4}, {start = 7, finish = 7}]
|
||||||
|
val expectedNewSearchList = [{start = 4, finish = 4}]
|
||||||
|
|
||||||
val assertion =
|
val assertion =
|
||||||
oldSearchList = expectedOldSearchList
|
oldSearchList = expectedOldSearchList
|
||||||
andalso newSearchList = expectedNewSearchList
|
andalso newSearchList = expectedNewSearchList
|
||||||
|
|||||||
Reference in New Issue
Block a user