done with tests for 'yw' motion

This commit is contained in:
2026-02-04 10:19:40 +00:00
parent 1f2af6aacd
commit 5c34a4c6ac

View File

@@ -707,8 +707,7 @@ struct
\up to (and excluding) third word \ \up to (and excluding) third word \
\when cursor is on fifth character of second word" \when cursor is on fifth character of second word"
(fn _ => yankSeconWordAlpha (10, "d ")) (fn _ => yankSeconWordAlpha (10, "d "))
, test , test "yanks space when cursor is on space preceding an alpha char"
"yanks space when cursor is on space preceding an alpha char"
(fn _ => yankSeconWordAlpha (11, " ")) (fn _ => yankSeconWordAlpha (11, " "))
, test "does not yank newline when cursor is on last word of line" (fn _ => , test "does not yank newline when cursor is on last word of line" (fn _ =>
let let
@@ -718,21 +717,15 @@ struct
val app = AppWith.idx (app, 0) val app = AppWith.idx (app, 0)
(* act *) (* act *)
val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "yw") val app = TestUtils.updateMany (app, "yw")
(* assert *) (* assert *)
val expectedString = "\nworld\nagain\n" val expectedString = "hello"
val expectedCursor = 0
val actualString = LineGap.toString buffer
val stringIsExpected = expectedString = actualString
val cursorIsExpected = expectedCursor = cursorIdx
in in
Expect.isTrue (stringIsExpected andalso cursorIsExpected) TestUtils.expectYank (app, expectedString)
end) end)
, test , test
"deletes until first punctuation char when on an alpha char \ "yanks until first punctuation char when on an alpha char \
\and there is no space between alpha and punctuation" \and there is no space between alpha and punctuation"
(fn _ => (fn _ =>
let let
@@ -741,21 +734,15 @@ struct
val app = TestUtils.init originalString val app = TestUtils.init originalString
(* act *) (* act *)
val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "yw") val app = TestUtils.updateMany (app, "yw")
(* assert *) (* assert *)
val expectedString = "!world!again\n" val expectedString = "hello"
val expectedCursor = 0
val actualString = LineGap.toString buffer
val stringIsExpected = expectedString = actualString
val cursorIsExpected = expectedCursor = cursorIdx
in in
Expect.isTrue (stringIsExpected andalso cursorIsExpected) TestUtils.expectYank (app, expectedString)
end) end)
, test , test
"deletes until first alpha char when on punctuation \ "yanks until first alpha char when on punctuation \
\and there is no space between punctuation and alpha" \and there is no space between punctuation and alpha"
(fn _ => (fn _ =>
let let
@@ -764,21 +751,15 @@ struct
val app = TestUtils.init originalString val app = TestUtils.init originalString
(* act *) (* act *)
val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "yw") val app = TestUtils.updateMany (app, "yw")
(* assert *) (* assert *)
val expectedString = "QWERTY#!\n" val expectedString = "!#%&"
val expectedCursor = 0
val actualString = LineGap.toString buffer
val stringIsExpected = expectedString = actualString
val cursorIsExpected = expectedCursor = cursorIdx
in in
Expect.isTrue (stringIsExpected andalso cursorIsExpected) TestUtils.expectYank (app, expectedString)
end) end)
, test , test
"deletes until first alpha char \ "yanks until first alpha char (exluding) \
\when cursor is on space and next char is alpha" \when cursor is on space and next char is alpha"
(fn _ => (fn _ =>
let let
@@ -788,20 +769,15 @@ struct
val app = AppWith.idx (app, 1) val app = AppWith.idx (app, 1)
(* act *) (* act *)
val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "yw") val app = TestUtils.updateMany (app, "yw")
(* assert *) (* assert *)
val expectedString = "hello\n" val expectedString = " "
val actualString = LineGap.toString buffer
val expectedCursor = 1
val stringIsExpected = expectedString = actualString
val cursorIsExpected = expectedCursor = cursorIdx
in in
Expect.isTrue (stringIsExpected andalso cursorIsExpected) TestUtils.expectYank (app, expectedString)
end) end)
, test , test
"deletes until first alpha char \ "yanks until first alpha char \
\when cursor is on space, many spaces are ahead, \ \when cursor is on space, many spaces are ahead, \
\and first char after spaces is alpha" \and first char after spaces is alpha"
(fn _ => (fn _ =>
@@ -812,20 +788,15 @@ struct
val app = AppWith.idx (app, 3) val app = AppWith.idx (app, 3)
(* act *) (* act *)
val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "yw") val app = TestUtils.updateMany (app, "yw")
(* assert *) (* assert *)
val expectedString = "h ello\n" val expectedString = " "
val actualString = LineGap.toString buffer
val expectedCursor = 3
val stringIsExpected = expectedString = actualString
val cursorIsExpected = expectedCursor = cursorIdx
in in
Expect.isTrue (stringIsExpected andalso cursorIsExpected) TestUtils.expectYank (app, expectedString)
end) end)
, test , test
"deletes until first punctuation char \ "yanks until first punctuation char \
\when cursor is on space and next non-space char is punctuation" \when cursor is on space and next non-space char is punctuation"
(fn _ => (fn _ =>
let let
@@ -835,20 +806,15 @@ struct
val app = AppWith.idx (app, 2) val app = AppWith.idx (app, 2)
(* act *) (* act *)
val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "yw") val app = TestUtils.updateMany (app, "yw")
(* assert *) (* assert *)
val expectedString = "! @#$%\n" val expectedString = " "
val actualString = LineGap.toString buffer
val expectedCursor = 2
val stringIsExpected = expectedString = actualString
val cursorIsExpected = expectedCursor = cursorIdx
in in
Expect.isTrue (stringIsExpected andalso cursorIsExpected) TestUtils.expectYank (app, expectedString)
end) end)
, test , test
"deletes last char when on last word \ "yanks last char when on last word \
\and there is no newline after current word" \and there is no newline after current word"
(fn _ => (fn _ =>
let let
@@ -857,18 +823,12 @@ struct
val app = AppWith.idx (app, 6) val app = AppWith.idx (app, 6)
(* act *) (* act *)
val {buffer, cursorIdx, ...} = TestUtils.updateMany (app, "yw") val app = TestUtils.updateMany (app, "yw")
(* assert *) (* assert *)
val expectedString = "hello " val expectedString = "world"
val actualString = LineGap.toString buffer
val expectedIdx = 5
val stringIsExpected = expectedString = actualString
val cursorIsExpected = cursorIdx = expectedIdx
in in
Expect.isTrue (stringIsExpected andalso cursorIsExpected) TestUtils.expectYank (app, expectedString)
end) end)
] ]