60 lines
1.7 KiB
Standard ML
60 lines
1.7 KiB
Standard ML
structure NormalDelete =
|
|
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
|