add search-list tests for 'dge' and 'dgE' motions
This commit is contained in:
@@ -4089,6 +4089,151 @@ struct
|
|||||||
in
|
in
|
||||||
Expect.isTrue (stringIsExpected andalso cursorIsExpected)
|
Expect.isTrue (stringIsExpected andalso cursorIsExpected)
|
||||||
end)
|
end)
|
||||||
|
, test "has same searchList when deleting after all matches" (fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalIdx = 15
|
||||||
|
val originalString = "hello world again\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, "dge")
|
||||||
|
in
|
||||||
|
(* assert *)
|
||||||
|
Expect.isTrue (#searchList app = #searchList newApp)
|
||||||
|
end)
|
||||||
|
, test "decrements search list when we delete word preceding match" (fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalIdx = 5
|
||||||
|
val originalString = "hello world again\n"
|
||||||
|
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
val app = AppWith.idx (app, originalIdx)
|
||||||
|
|
||||||
|
val app = TestUtils.updateMany (app, "/world")
|
||||||
|
val app = AppUpdate.update (app, InputMsg.KEY_ENTER, Time.now ())
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val newApp = TestUtils.updateMany (app, "dge")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val oldSearchList = #searchList app
|
||||||
|
val oldSearchList = PersistentVector.toList oldSearchList
|
||||||
|
|
||||||
|
val newSearchList = #searchList newApp
|
||||||
|
val newSearchList = PersistentVector.toList newSearchList
|
||||||
|
|
||||||
|
val expectedOldSearchList = [{start = 6, finish = 10}]
|
||||||
|
val expectedNewSearchList = [{start = 4, finish = 8}]
|
||||||
|
|
||||||
|
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 = 6
|
||||||
|
val originalString = "hello world again\n"
|
||||||
|
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
val app = AppWith.idx (app, originalIdx)
|
||||||
|
|
||||||
|
val app = TestUtils.updateMany (app, "/hellorld")
|
||||||
|
val app = AppUpdate.update (app, InputMsg.KEY_ENTER, Time.now ())
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val newApp = TestUtils.updateMany (app, "dge")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val oldSearchList = #searchList app
|
||||||
|
val oldSearchList = PersistentVector.toList oldSearchList
|
||||||
|
val newSearchList = #searchList newApp
|
||||||
|
val newSearchList = PersistentVector.toList newSearchList
|
||||||
|
|
||||||
|
val expectedOldSearchList = []
|
||||||
|
val expectedNewSearchList = [{start = 0, finish = 7}]
|
||||||
|
|
||||||
|
val assertion =
|
||||||
|
oldSearchList = expectedOldSearchList
|
||||||
|
andalso newSearchList = expectedNewSearchList
|
||||||
|
in
|
||||||
|
Expect.isTrue assertion
|
||||||
|
end)
|
||||||
|
, test
|
||||||
|
"extends existing match when existing match should extend after deletion"
|
||||||
|
(fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalIdx = 7
|
||||||
|
val originalString = "hello orange oops\n"
|
||||||
|
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
val app = AppWith.idx (app, originalIdx)
|
||||||
|
|
||||||
|
val app = TestUtils.updateMany (app, "/hella*")
|
||||||
|
val app = AppUpdate.update (app, InputMsg.KEY_ENTER, Time.now ())
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val newApp = TestUtils.updateMany (app, "dge")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val oldSearchList = #searchList app
|
||||||
|
val oldSearchList = PersistentVector.toList oldSearchList
|
||||||
|
|
||||||
|
val newSearchList = #searchList newApp
|
||||||
|
val newSearchList = PersistentVector.toList newSearchList
|
||||||
|
|
||||||
|
val expectedOldSearchList = [{start = 0, finish = 3}]
|
||||||
|
val expectedNewSearchList = [{start = 0, finish = 4}]
|
||||||
|
|
||||||
|
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 = 7
|
||||||
|
val originalString = "hello world test again\n"
|
||||||
|
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
val app = AppWith.idx (app, originalIdx)
|
||||||
|
|
||||||
|
val app = TestUtils.updateMany (app, "/world")
|
||||||
|
val app = AppUpdate.update (app, InputMsg.KEY_ENTER, Time.now ())
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val newApp = TestUtils.updateMany (app, "dge")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val oldSearchList = #searchList app
|
||||||
|
val oldSearchList = PersistentVector.toList oldSearchList
|
||||||
|
val newSearchList = #searchList newApp
|
||||||
|
val newSearchList = PersistentVector.toList newSearchList
|
||||||
|
|
||||||
|
val expectedOldSearchList = [{start = 6, finish = 10}]
|
||||||
|
val expectedNewSearchList = []
|
||||||
|
|
||||||
|
val assertion =
|
||||||
|
oldSearchList = expectedOldSearchList
|
||||||
|
andalso newSearchList = expectedNewSearchList
|
||||||
|
in
|
||||||
|
Expect.isTrue assertion
|
||||||
|
end)
|
||||||
]
|
]
|
||||||
|
|
||||||
val dgEDelete = describe "delete motion 'dgE'"
|
val dgEDelete = describe "delete motion 'dgE'"
|
||||||
@@ -4289,6 +4434,151 @@ struct
|
|||||||
in
|
in
|
||||||
Expect.isTrue (stringIsExpected andalso cursorIsExpected)
|
Expect.isTrue (stringIsExpected andalso cursorIsExpected)
|
||||||
end)
|
end)
|
||||||
|
, test "has same searchList when deleting after all matches" (fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalIdx = 15
|
||||||
|
val originalString = "hello world again\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, "dge")
|
||||||
|
in
|
||||||
|
(* assert *)
|
||||||
|
Expect.isTrue (#searchList app = #searchList newApp)
|
||||||
|
end)
|
||||||
|
, test "decrements search list when we delete word preceding match" (fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalIdx = 5
|
||||||
|
val originalString = "hello world again\n"
|
||||||
|
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
val app = AppWith.idx (app, originalIdx)
|
||||||
|
|
||||||
|
val app = TestUtils.updateMany (app, "/world")
|
||||||
|
val app = AppUpdate.update (app, InputMsg.KEY_ENTER, Time.now ())
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val newApp = TestUtils.updateMany (app, "dge")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val oldSearchList = #searchList app
|
||||||
|
val oldSearchList = PersistentVector.toList oldSearchList
|
||||||
|
|
||||||
|
val newSearchList = #searchList newApp
|
||||||
|
val newSearchList = PersistentVector.toList newSearchList
|
||||||
|
|
||||||
|
val expectedOldSearchList = [{start = 6, finish = 10}]
|
||||||
|
val expectedNewSearchList = [{start = 4, finish = 8}]
|
||||||
|
|
||||||
|
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 = 6
|
||||||
|
val originalString = "hello world again\n"
|
||||||
|
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
val app = AppWith.idx (app, originalIdx)
|
||||||
|
|
||||||
|
val app = TestUtils.updateMany (app, "/hellorld")
|
||||||
|
val app = AppUpdate.update (app, InputMsg.KEY_ENTER, Time.now ())
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val newApp = TestUtils.updateMany (app, "dge")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val oldSearchList = #searchList app
|
||||||
|
val oldSearchList = PersistentVector.toList oldSearchList
|
||||||
|
val newSearchList = #searchList newApp
|
||||||
|
val newSearchList = PersistentVector.toList newSearchList
|
||||||
|
|
||||||
|
val expectedOldSearchList = []
|
||||||
|
val expectedNewSearchList = [{start = 0, finish = 7}]
|
||||||
|
|
||||||
|
val assertion =
|
||||||
|
oldSearchList = expectedOldSearchList
|
||||||
|
andalso newSearchList = expectedNewSearchList
|
||||||
|
in
|
||||||
|
Expect.isTrue assertion
|
||||||
|
end)
|
||||||
|
, test
|
||||||
|
"extends existing match when existing match should extend after deletion"
|
||||||
|
(fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalIdx = 7
|
||||||
|
val originalString = "hello orange oops\n"
|
||||||
|
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
val app = AppWith.idx (app, originalIdx)
|
||||||
|
|
||||||
|
val app = TestUtils.updateMany (app, "/hella*")
|
||||||
|
val app = AppUpdate.update (app, InputMsg.KEY_ENTER, Time.now ())
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val newApp = TestUtils.updateMany (app, "dge")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val oldSearchList = #searchList app
|
||||||
|
val oldSearchList = PersistentVector.toList oldSearchList
|
||||||
|
|
||||||
|
val newSearchList = #searchList newApp
|
||||||
|
val newSearchList = PersistentVector.toList newSearchList
|
||||||
|
|
||||||
|
val expectedOldSearchList = [{start = 0, finish = 3}]
|
||||||
|
val expectedNewSearchList = [{start = 0, finish = 4}]
|
||||||
|
|
||||||
|
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 = 7
|
||||||
|
val originalString = "hello world test again\n"
|
||||||
|
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
val app = AppWith.idx (app, originalIdx)
|
||||||
|
|
||||||
|
val app = TestUtils.updateMany (app, "/world")
|
||||||
|
val app = AppUpdate.update (app, InputMsg.KEY_ENTER, Time.now ())
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val newApp = TestUtils.updateMany (app, "dge")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val oldSearchList = #searchList app
|
||||||
|
val oldSearchList = PersistentVector.toList oldSearchList
|
||||||
|
val newSearchList = #searchList newApp
|
||||||
|
val newSearchList = PersistentVector.toList newSearchList
|
||||||
|
|
||||||
|
val expectedOldSearchList = [{start = 6, finish = 10}]
|
||||||
|
val expectedNewSearchList = []
|
||||||
|
|
||||||
|
val assertion =
|
||||||
|
oldSearchList = expectedOldSearchList
|
||||||
|
andalso newSearchList = expectedNewSearchList
|
||||||
|
in
|
||||||
|
Expect.isTrue assertion
|
||||||
|
end)
|
||||||
]
|
]
|
||||||
|
|
||||||
val dGDelete = describe "delete motion 'dG'"
|
val dGDelete = describe "delete motion 'dG'"
|
||||||
|
|||||||
Reference in New Issue
Block a user