add another test for 'daw' motion
This commit is contained in:
@@ -4443,25 +4443,81 @@ struct
|
|||||||
]
|
]
|
||||||
|
|
||||||
val dawDelete = describe "delete motion 'daw' (delete around word)"
|
val dawDelete = describe "delete motion 'daw' (delete around word)"
|
||||||
[test "deletes a single newline when cursor is on a newline" (fn _ =>
|
[ test "deletes a single newline when cursor is on a newline" (fn _ =>
|
||||||
let
|
let
|
||||||
(* arrange *)
|
(* arrange *)
|
||||||
val originalString = "hello\n\nworld\n"
|
val originalString = "hello\n\nworld\n"
|
||||||
val app = TestUtils.init originalString
|
val app = TestUtils.init originalString
|
||||||
val app = AppWith.idx (app, 6)
|
val app = AppWith.idx (app, 6)
|
||||||
|
|
||||||
(* act *)
|
(* act *)
|
||||||
val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "daw")
|
val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "daw")
|
||||||
|
|
||||||
(* assert *)
|
(* assert *)
|
||||||
val expectedString = "hello\nworld\n"
|
val expectedString = "hello\nworld\n"
|
||||||
val actualString = LineGap.toString buffer
|
val actualString = LineGap.toString buffer
|
||||||
|
|
||||||
val expectedCursorIdx = 6
|
val expectedCursorIdx = 6
|
||||||
in
|
in
|
||||||
Expect.isTrue
|
Expect.isTrue
|
||||||
(actualString = expectedString andalso cursorIdx = expectedCursorIdx)
|
(actualString = expectedString andalso cursorIdx = expectedCursorIdx)
|
||||||
end)]
|
end)
|
||||||
|
, test
|
||||||
|
"deletes middle word and spaces after middle word \
|
||||||
|
\when there are three words on line and cursor is on middle word"
|
||||||
|
(fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalString = "hello world again\n"
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
|
||||||
|
val app1 = AppWith.idx (app, 6)
|
||||||
|
val app2 = AppWith.idx (app, 7)
|
||||||
|
val app3 = AppWith.idx (app, 8)
|
||||||
|
val app4 = AppWith.idx (app, 9)
|
||||||
|
val app5 = AppWith.idx (app, 10)
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val app1 = TestUtils.updateMany (app1, "daw")
|
||||||
|
val app2 = TestUtils.updateMany (app2, "daw")
|
||||||
|
val app3 = TestUtils.updateMany (app3, "daw")
|
||||||
|
val app4 = TestUtils.updateMany (app4, "daw")
|
||||||
|
val app5 = TestUtils.updateMany (app5, "daw")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val expectedString = "hello again\n"
|
||||||
|
|
||||||
|
val actualString1 = LineGap.toString (#buffer app1)
|
||||||
|
val actualString2 = LineGap.toString (#buffer app2)
|
||||||
|
val actualString3 = LineGap.toString (#buffer app3)
|
||||||
|
val actualString4 = LineGap.toString (#buffer app4)
|
||||||
|
val actualString5 = LineGap.toString (#buffer app5)
|
||||||
|
|
||||||
|
val stringsAreExpected =
|
||||||
|
expectedString = actualString1
|
||||||
|
andalso expectedString = actualString2
|
||||||
|
andalso expectedString = actualString3
|
||||||
|
andalso expectedString = actualString4
|
||||||
|
andalso expectedString = actualString5
|
||||||
|
|
||||||
|
val expectedCursorIdx = 6
|
||||||
|
|
||||||
|
val actualCursor1 = #cursorIdx app1
|
||||||
|
val actualCursor2 = #cursorIdx app2
|
||||||
|
val actualCursor3 = #cursorIdx app3
|
||||||
|
val actualCursor4 = #cursorIdx app4
|
||||||
|
val actualCursor5 = #cursorIdx app5
|
||||||
|
|
||||||
|
val cursorsAreExpected =
|
||||||
|
expectedCursorIdx = actualCursor1
|
||||||
|
andalso expectedCursorIdx = actualCursor2
|
||||||
|
andalso expectedCursorIdx = actualCursor3
|
||||||
|
andalso expectedCursorIdx = actualCursor4
|
||||||
|
andalso expectedCursorIdx = actualCursor5
|
||||||
|
in
|
||||||
|
Expect.isTrue (stringsAreExpected andalso cursorsAreExpected)
|
||||||
|
end)
|
||||||
|
]
|
||||||
|
|
||||||
val tests =
|
val tests =
|
||||||
[ dhDelete
|
[ dhDelete
|
||||||
|
|||||||
Reference in New Issue
Block a user