add test for 'yW' yank motion
This commit is contained in:
@@ -832,5 +832,187 @@ struct
|
|||||||
end)
|
end)
|
||||||
]
|
]
|
||||||
|
|
||||||
val tests = [yhYank, ylYank, ykYank, yjYank, yyYank, ywYank]
|
fun yankSeconWORD (pos, expectedString) =
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalString = "hello wor!d again\n"
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
val app = AppWith.idx (app, pos)
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val app = TestUtils.updateMany (app, "yW")
|
||||||
|
in
|
||||||
|
(* assert *)
|
||||||
|
TestUtils.expectYank (app, expectedString)
|
||||||
|
end
|
||||||
|
|
||||||
|
val yWYank = describe "yank motion 'yW'"
|
||||||
|
[ test "yanks last character when cursor is on last character of line"
|
||||||
|
(fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalString = "hello world\n"
|
||||||
|
val originalIdx = String.size originalString - 2
|
||||||
|
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
val app = AppWith.idx (app, originalIdx)
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val app = TestUtils.updateMany (app, "yW")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val expectedString = "d"
|
||||||
|
in
|
||||||
|
TestUtils.expectYank (app, expectedString)
|
||||||
|
end)
|
||||||
|
, test
|
||||||
|
"yanks from second word up to (and excluding) third word \
|
||||||
|
\when cursor is on first character of second word"
|
||||||
|
(fn _ => yankSeconWORD (6, "wor!d "))
|
||||||
|
, test
|
||||||
|
"yanks from second character of second word \
|
||||||
|
\up to (and excluding) third word \
|
||||||
|
\when cursor is on second character of second word"
|
||||||
|
(fn _ => yankSeconWORD (7, "or!d "))
|
||||||
|
, test
|
||||||
|
"yanks from third character of second word \
|
||||||
|
\up to (and excluding) third word \
|
||||||
|
\when cursor is on third character of second word"
|
||||||
|
(fn _ => yankSeconWORD (8, "r!d "))
|
||||||
|
, test
|
||||||
|
"yanks from fourth character of second word \
|
||||||
|
\up to (and excluding) third word \
|
||||||
|
\when cursor is on fourth character of second word"
|
||||||
|
(fn _ => yankSeconWORD (9, "!d "))
|
||||||
|
, test
|
||||||
|
"yanks from fifth character of second word \
|
||||||
|
\up to (and excluding) third word \
|
||||||
|
\when cursor is on fifth character of second word"
|
||||||
|
(fn _ => yankSeconWORD (10, "d "))
|
||||||
|
, test "yanks space when cursor is on space preceding an alpha char"
|
||||||
|
(fn _ => yankSeconWORD (11, " "))
|
||||||
|
, test "does not yank newline when cursor is on last word of line" (fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalString = "he!!o\nworld\nagain\n"
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
val app = AppWith.idx (app, 0)
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val app = TestUtils.updateMany (app, "yW")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val expectedString = "he!!o"
|
||||||
|
in
|
||||||
|
TestUtils.expectYank (app, expectedString)
|
||||||
|
end)
|
||||||
|
, test
|
||||||
|
"yanks past a WORD containing both alpha and punctuation chars \
|
||||||
|
\when cursor is on alpha char"
|
||||||
|
(fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalString = "hello!world! again\n"
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val app = TestUtils.updateMany (app, "yW")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val expectedString = "hello!world! "
|
||||||
|
in
|
||||||
|
TestUtils.expectYank (app, expectedString)
|
||||||
|
end)
|
||||||
|
, test
|
||||||
|
"yanks past a WORD containing both alpha and punctuation chars \
|
||||||
|
\when cursor is on punctuation char"
|
||||||
|
(fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalString = "!#%&QWE RTY#!\n"
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val app = TestUtils.updateMany (app, "yW")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val expectedString = "!#%&QWE "
|
||||||
|
in
|
||||||
|
TestUtils.expectYank (app, expectedString)
|
||||||
|
end)
|
||||||
|
, test
|
||||||
|
"yanks until first alpha char (exluding) \
|
||||||
|
\when cursor is on space and next char is alpha"
|
||||||
|
(fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalString = "h e!!o\n"
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
val app = AppWith.idx (app, 1)
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val app = TestUtils.updateMany (app, "yW")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val expectedString = " "
|
||||||
|
in
|
||||||
|
TestUtils.expectYank (app, expectedString)
|
||||||
|
end)
|
||||||
|
, test
|
||||||
|
"yanks until first alpha char \
|
||||||
|
\when cursor is on space, many spaces are ahead, \
|
||||||
|
\and first char after spaces is alpha"
|
||||||
|
(fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalString = "h e!!o\n"
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
val app = AppWith.idx (app, 3)
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val app = TestUtils.updateMany (app, "yW")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val expectedString = " "
|
||||||
|
in
|
||||||
|
TestUtils.expectYank (app, expectedString)
|
||||||
|
end)
|
||||||
|
, test
|
||||||
|
"yanks until first punctuation char \
|
||||||
|
\when cursor is on space and next non-space char is punctuation"
|
||||||
|
(fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val originalString = "! @azq\n"
|
||||||
|
val app = TestUtils.init originalString
|
||||||
|
val app = AppWith.idx (app, 2)
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val app = TestUtils.updateMany (app, "yW")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val expectedString = " "
|
||||||
|
in
|
||||||
|
TestUtils.expectYank (app, expectedString)
|
||||||
|
end)
|
||||||
|
, test
|
||||||
|
"yanks last char when on last word \
|
||||||
|
\and there is no newline after current word"
|
||||||
|
(fn _ =>
|
||||||
|
let
|
||||||
|
(* arrange *)
|
||||||
|
val app = TestUtils.init "hello wor!d"
|
||||||
|
val app = AppWith.idx (app, 6)
|
||||||
|
|
||||||
|
(* act *)
|
||||||
|
val app = TestUtils.updateMany (app, "yW")
|
||||||
|
|
||||||
|
(* assert *)
|
||||||
|
val expectedString = "wor!d"
|
||||||
|
in
|
||||||
|
TestUtils.expectYank (app, expectedString)
|
||||||
|
end)
|
||||||
|
]
|
||||||
|
|
||||||
|
val tests = [yhYank, ylYank, ykYank, yjYank, yyYank, ywYank, yWYank]
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user