add additional tests for 'l' motion

This commit is contained in:
2025-09-20 06:31:14 +01:00
parent 60cbb33cb6
commit ec091b56a3

View File

@@ -87,21 +87,19 @@ struct
] ]
val lMove = describe "move motion 'l'" val lMove = describe "move motion 'l'"
[ test [ test "moves cursor right by one when cursorIdx < length" (fn _ =>
"moves cursor right by one in contiguous string when cursorIdx < length" let
(fn _ => (* arrange *)
let val app = TestUtils.init "hello world"
(* arrange *) val {cursorIdx = oldCursorIdx, ...} = app
val app = TestUtils.init "hello world"
val {cursorIdx = oldCursorIdx, ...} = app
(* act *) (* act *)
val {cursorIdx, ...} = TestUtils.update (app, CHAR_EVENT #"l") val {cursorIdx, ...} = TestUtils.update (app, CHAR_EVENT #"l")
in in
(* assert *) (* assert *)
Expect.isTrue (oldCursorIdx = 0 andalso cursorIdx = 1) Expect.isTrue (oldCursorIdx = 0 andalso cursorIdx = 1)
end) end)
, test "does not move cursor when cursorIdx = length" (fn _ => , test "does not move cursor when cursorIdx is at end of line" (fn _ =>
let let
(* arrange *) (* arrange *)
val app = TestUtils.init "hello world" val app = TestUtils.init "hello world"
@@ -114,7 +112,8 @@ struct
Expect.isTrue (cursorIdx = 10) Expect.isTrue (cursorIdx = 10)
end) end)
, test , test
"moves right by two in contiguous string when char is followed by \\n" "moves cursor to the first character after a newline\
\ when there is a newlineo on the right followed by a non-newline"
(fn _ => (fn _ =>
let let
(* arrange *) (* arrange *)
@@ -127,6 +126,21 @@ struct
(* assert *) (* assert *)
Expect.isTrue (cursorIdx = 6) Expect.isTrue (cursorIdx = 6)
end) end)
, test
"moves cursor to the first newline\
\ when there are multiple continuous newlines ahead"
(fn _ =>
let
(* arrange *)
val app = TestUtils.init "hello\n\nworld"
val app = AppWith.idx (app, 4)
(* act *)
val {cursorIdx, ...} = TestUtils.update (app, CHAR_EVENT #"l")
in
(* assert *)
Expect.isTrue (cursorIdx = 5)
end)
] ]
val jMove = describe "move motion 'j'" val jMove = describe "move motion 'j'"