add a few more tests for 'dk' motion
This commit is contained in:
@@ -634,27 +634,78 @@ struct
|
|||||||
Expect.isTrue
|
Expect.isTrue
|
||||||
(expectedString = actualString andalso expectedIdx = cursorIdx)
|
(expectedString = actualString andalso expectedIdx = cursorIdx)
|
||||||
end)
|
end)
|
||||||
, test "deletes first two lines when cursor is on second line" (fn _ =>
|
, test
|
||||||
let
|
"deletes first two lines, leaving a newline in the buffer \
|
||||||
(* arrange *)
|
\ when there are two lines \and cursor is on second line"
|
||||||
val originalString = "hello\nworld\n"
|
(fn _ =>
|
||||||
val originalIdx = 6
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalString = "hello\nworld\n"
|
||||||
|
val originalIdx = 6
|
||||||
|
|
||||||
val app = TestUtils.init originalString
|
val app = TestUtils.init originalString
|
||||||
val app = AppWith.idx (app, originalIdx)
|
val app = AppWith.idx (app, originalIdx)
|
||||||
|
|
||||||
(* act *)
|
(* act *)
|
||||||
val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "dk")
|
val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "dk")
|
||||||
|
|
||||||
(* assert *)
|
(* assert *)
|
||||||
val expectedString = "\n"
|
val expectedString = "\n"
|
||||||
val actualString = LineGap.toString buffer
|
val actualString = LineGap.toString buffer
|
||||||
|
|
||||||
val expectedIdx = 0
|
val expectedIdx = 0
|
||||||
in
|
in
|
||||||
Expect.isTrue
|
Expect.isTrue
|
||||||
(expectedString = actualString andalso expectedIdx = cursorIdx)
|
(expectedString = actualString andalso expectedIdx = cursorIdx)
|
||||||
end)
|
end)
|
||||||
|
, test
|
||||||
|
"deletes last two lines when there are three lines in the buffer \
|
||||||
|
\ and cursor is on third line"
|
||||||
|
(fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalString = "hello\nworld\nagain\n"
|
||||||
|
val originalIdx = 15
|
||||||
|
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
val app = AppWith.idx (app, originalIdx)
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "dk")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val expectedString = "hello\n"
|
||||||
|
val actualString = LineGap.toString buffer
|
||||||
|
|
||||||
|
val expectedIdx = 0
|
||||||
|
in
|
||||||
|
Expect.isTrue
|
||||||
|
(expectedString = actualString andalso expectedIdx = cursorIdx)
|
||||||
|
end)
|
||||||
|
, test
|
||||||
|
"leaves a buffer containing just a newline when\
|
||||||
|
\deleting from last line with a counter greater than total lines"
|
||||||
|
(fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalString = "hello\nworld\nagain\n"
|
||||||
|
val originalIdx = 15
|
||||||
|
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
val app = AppWith.idx (app, originalIdx)
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "33dk")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val expectedString = "\n"
|
||||||
|
val actualString = LineGap.toString buffer
|
||||||
|
|
||||||
|
val expectedIdx = 0
|
||||||
|
in
|
||||||
|
Expect.isTrue
|
||||||
|
(expectedString = actualString andalso expectedIdx = cursorIdx)
|
||||||
|
end)
|
||||||
]
|
]
|
||||||
|
|
||||||
val tests = [dhDelete, dlDelete, djDelete, ddDelete, dkDelete]
|
val tests = [dhDelete, dlDelete, djDelete, ddDelete, dkDelete]
|
||||||
|
|||||||
Reference in New Issue
Block a user