add tests for 'f' motion
This commit is contained in:
@@ -1951,6 +1951,78 @@ struct
|
|||||||
end)
|
end)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
val fMove = describe "move motion 'f'"
|
||||||
|
[ test "motion 'fw' moves cursor to first 'w' in string \"hello world\""
|
||||||
|
(fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val buffer = LineGap.fromString "hello world"
|
||||||
|
val app = AppType.init (buffer, 0, 0)
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val app = updateMany (app, "fw")
|
||||||
|
in
|
||||||
|
(* assert *)
|
||||||
|
Expect.isTrue (getChr app = #"w")
|
||||||
|
end)
|
||||||
|
, test "count followed by f<char> moves to count'th match" (fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val buffer = LineGap.fromString "hello world"
|
||||||
|
val app = AppType.init (buffer, 0, 0)
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val app = updateMany (app, "3fl")
|
||||||
|
in
|
||||||
|
(* assert *)
|
||||||
|
Expect.isTrue (#cursorIdx app = 9 andalso getChr app = #"l")
|
||||||
|
end)
|
||||||
|
, test
|
||||||
|
"'count f<char>' goes to last match when count is greater than number of chars"
|
||||||
|
(fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val buffer = LineGap.fromString "hello world"
|
||||||
|
val app = AppType.init (buffer, 0, 0)
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val app = updateMany (app, "9fl")
|
||||||
|
in
|
||||||
|
(* assert *)
|
||||||
|
Expect.isTrue (#cursorIdx app = 9 andalso getChr app = #"l")
|
||||||
|
end)
|
||||||
|
, test
|
||||||
|
"does not move cursor at all when char following 'f' is not in string"
|
||||||
|
(fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val buffer = LineGap.fromString "hello world"
|
||||||
|
val app = AppType.init (buffer, 0, 0)
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val app1 = updateMany (app, "f;")
|
||||||
|
in
|
||||||
|
(* assert *)
|
||||||
|
Expect.isTrue (#cursorIdx app1 = #cursorIdx app)
|
||||||
|
end)
|
||||||
|
, test "is cancellable by pressing escape" (fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val buffer = LineGap.fromString "hello world"
|
||||||
|
val app = AppType.init (buffer, 0, 0)
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val app1 = AppUpdate.update (app, CHAR_EVENT #"f")
|
||||||
|
val app2 = AppUpdate.update (app1, KEY_ESC)
|
||||||
|
val app3 = AppUpdate.update (app2, CHAR_EVENT #"d")
|
||||||
|
in
|
||||||
|
(* assert *)
|
||||||
|
Expect.isTrue
|
||||||
|
(#cursorIdx app1 = #cursorIdx app2
|
||||||
|
andalso #cursorIdx app2 = #cursorIdx app3)
|
||||||
|
end)
|
||||||
|
]
|
||||||
|
|
||||||
val tests = concat
|
val tests = concat
|
||||||
[ hMove
|
[ hMove
|
||||||
, jMove
|
, jMove
|
||||||
@@ -1970,5 +2042,6 @@ struct
|
|||||||
(* multi-char motions *)
|
(* multi-char motions *)
|
||||||
, tMove
|
, tMove
|
||||||
, TMove
|
, TMove
|
||||||
|
, fMove
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user