add tests to verify that cursorIdx is as expected after 'dh' delete motion
This commit is contained in:
@@ -53,6 +53,66 @@ struct
|
|||||||
in
|
in
|
||||||
Expect.isTrue (expectedString = actualString)
|
Expect.isTrue (expectedString = actualString)
|
||||||
end)
|
end)
|
||||||
|
, test "moves cursor left by one after deleting left char" (fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalIdx = 5
|
||||||
|
val originalString = "hello world\n"
|
||||||
|
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
val app = AppWith.idx (app, originalIdx)
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val {cursorIdx, ...} = TestUtils.updateMany (app, "dh")
|
||||||
|
in
|
||||||
|
(* assert *)
|
||||||
|
Expect.isTrue (cursorIdx = originalIdx - 1)
|
||||||
|
end)
|
||||||
|
, test "deletes 3 chars and moves cursor left by 3 when count is 3" (fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalIdx = 5
|
||||||
|
val originalString = "hello world\n"
|
||||||
|
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
val app = AppWith.idx (app, originalIdx)
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val {cursorIdx, buffer, ...} = TestUtils.updateMany (app, "3dh")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val expectedString = "he world\n"
|
||||||
|
val deleted3CharsInString = expectedString = LineGap.toString buffer
|
||||||
|
val cursorIdxIsDecrementedBy3 = cursorIdx = originalIdx - 3
|
||||||
|
in
|
||||||
|
Expect.isTrue
|
||||||
|
(cursorIdxIsDecrementedBy3 andalso deleted3CharsInString)
|
||||||
|
end)
|
||||||
|
, test
|
||||||
|
"deletes until start column when \
|
||||||
|
\count is greater than current column"
|
||||||
|
(fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalIdx = 5
|
||||||
|
val originalString = "hello world\n"
|
||||||
|
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
val app = AppWith.idx (app, originalIdx)
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val {cursorIdx, buffer, ...} = TestUtils.updateMany (app, "9dh")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val actualString = LineGap.toString buffer
|
||||||
|
val expectedString = " world\n"
|
||||||
|
val stringIsExpected = actualString = expectedString
|
||||||
|
|
||||||
|
val expectedCursorIdx = 0
|
||||||
|
val cursorIdxIsExpected = cursorIdx = expectedCursorIdx
|
||||||
|
in
|
||||||
|
Expect.isTrue (stringIsExpected andalso cursorIdxIsExpected)
|
||||||
|
end)
|
||||||
]
|
]
|
||||||
|
|
||||||
val tests = [dhDelete]
|
val tests = [dhDelete]
|
||||||
|
|||||||
Reference in New Issue
Block a user