begin adding normal-delete tests

This commit is contained in:
2025-09-20 17:59:22 +01:00
parent 6b05c9a07a
commit a0add68e92

View File

@@ -1,2 +1,59 @@
structure NormalDelete = structure NormalDelete =
struct open Railroad open Railroad.Test open InputMsg val tests = [] end struct
open Railroad
open Railroad.Test
open InputMsg
val dhDelete = describe "delete motion 'dh'"
[ test "does not delete when cursor is at index 0" (fn _ =>
let
(* arrange *)
val originalString = "hello world\n"
val app = TestUtils.init originalString
val app = AppWith.idx (app, 0)
(* act *)
val app = TestUtils.updateMany (app, "dh")
(* assert *)
val expectedString = originalString
val actualString = LineGap.toString (#buffer app)
in
Expect.isTrue (expectedString = actualString)
end)
, test "does not delete when character before cursor is a newline" (fn _ =>
let
(* arrange *)
val originalString = "hello\nworld\n"
val app = TestUtils.init originalString
val app = AppWith.idx (app, 6)
(* act *)
val app = TestUtils.updateMany (app, "dh")
(* assert *)
val expectedString = originalString
val actualString = LineGap.toString (#buffer app)
in
Expect.isTrue (expectedString = actualString)
end)
, test "deletes one char to the left when on a non-newline" (fn _ =>
let
(* arrange *)
val originalString = "hello world\n"
val app = TestUtils.init originalString
val app = AppWith.idx (app, 5)
(* act *)
val app = TestUtils.updateMany (app, "dh")
(* assert *)
val expectedString = "hell world\n"
val actualString = LineGap.toString (#buffer app)
in
Expect.isTrue (expectedString = actualString)
end)
]
val tests = [dhDelete]
end