give different strings for some tests

This commit is contained in:
2024-11-24 13:43:22 +00:00
parent d76b753fa7
commit 73482a7cc2

View File

@@ -647,9 +647,7 @@ val wMove = describe "move motion 'w'"
Expect.isTrue (cursorChr = #"w") Expect.isTrue (cursorChr = #"w")
end) end)
, test , test "does not break on undescore when cursor is on alphanumeric char"
"moves cursor past underscore \
\when underscore is between alphanumeric chars"
(fn _ => (fn _ =>
(* This behaviour makes behaviour different from vi, (* This behaviour makes behaviour different from vi,
* where "w" when a newline is in between causes cursor * where "w" when a newline is in between causes cursor
@@ -672,65 +670,55 @@ val wMove = describe "move motion 'w'"
Expect.isTrue (cursorChr = #"g") Expect.isTrue (cursorChr = #"g")
end) end)
, test , test "breaks on punctuation when cursor is on alphanumeric char" (fn _ =>
"moves cursor to punctuation when next char\ (* vi's definition of 'word' instead of 'WORD' *)
\after continuous alphanumeric chars is punctuation" let
(fn _ => (* arrange *)
(* vi's definition of 'word' instead of 'WORD' *) val buffer = LineGap.fromString "hello, world"
let val app = AppType.init (buffer, 0, 0)
(* arrange *)
val buffer = LineGap.fromString "hello, world"
val app = AppType.init (buffer, 0, 0)
(* act *) (* act *)
val (app, _) = AppUpdate.update (app, CHAR_EVENT #"w") val (app, _) = AppUpdate.update (app, CHAR_EVENT #"w")
(* assert *) (* assert *)
val cursorChr = getChr app val cursorChr = getChr app
in in
Expect.isTrue (cursorChr = #",") Expect.isTrue (cursorChr = #",")
end) end)
, test , test "breaks on alphanumeric char when cursor is on punctuation" (fn _ =>
"moves cursor to alphanumeric char when next char\ (* vi's definition of 'word' instead of 'WORD' *)
\after continuous punctuation chars is alphanumeric" let
(fn _ => (* arrange *)
(* vi's definition of 'word' instead of 'WORD' *) val buffer = LineGap.fromString "!#%^()hello\n"
let val app = AppType.init (buffer, 0, 0)
(* arrange *)
val buffer = LineGap.fromString "!#%^()hello\n"
val app = AppType.init (buffer, 0, 0)
(* act *) (* act *)
val (app, _) = AppUpdate.update (app, CHAR_EVENT #"w") val (app, _) = AppUpdate.update (app, CHAR_EVENT #"w")
(* assert *) (* assert *)
val cursorChr = getChr app val cursorChr = getChr app
in in
Expect.isTrue (cursorChr = #"h") Expect.isTrue (cursorChr = #"h")
end) end)
, test , test "breaks on non-blank char when on blank char" (fn _ =>
"moves cursor to first {alphanumeric|punctuation} \ let
\when cursor is in {space|tab|'\\n'}" (* arrange *)
(fn _ => val buffer = LineGap.fromString "0123 \t \n \t 789\n"
(* vi's definition of 'word' instead of 'WORD' *) val app = AppType.init (buffer, 0, 0)
let val app = withIdx (app, 4)
(* arrange *)
val buffer = LineGap.fromString "0123 \t \n \t 789\n"
val app = AppType.init (buffer, 0, 0)
val app = withIdx (app, 4)
(* act *) (* act *)
val (app, _) = AppUpdate.update (app, CHAR_EVENT #"w") val (app, _) = AppUpdate.update (app, CHAR_EVENT #"w")
(* assert *) (* assert *)
val cursorChr = getChr app val cursorChr = getChr app
in in
Expect.isTrue (cursorChr = #"7") Expect.isTrue (cursorChr = #"7")
end) end)
, test "moves cursor to first alphanumeric char when in punctuation" (fn _ => , test "moves cursor to first alphanumeric char when on punctuation" (fn _ =>
let let
(* arrange *) (* arrange *)
val buffer = LineGap.fromString "!!! hello\n" val buffer = LineGap.fromString "!!! hello\n"
@@ -746,7 +734,7 @@ val wMove = describe "move motion 'w'"
Expect.isTrue (startsAtExc andalso movedToH) Expect.isTrue (startsAtExc andalso movedToH)
end) end)
, test "moves cursor to last char in buffer when in last word" (fn _ => , test "moves cursor to last char when cursor is on last word" (fn _ =>
let let
(* arrange *) (* arrange *)
val buffer = LineGap.fromString "hello world\n" val buffer = LineGap.fromString "hello world\n"
@@ -764,7 +752,7 @@ val wMove = describe "move motion 'w'"
] ]
val WMove = describe "move motion 'W'" val WMove = describe "move motion 'W'"
[ test "moves cursor to start of next word in contiguous string" (fn _ => [ test "moves cursor to start of next WORD in contiguous string" (fn _ =>
let let
(* arrange *) (* arrange *)
val buffer = LineGap.fromString "hello world" val buffer = LineGap.fromString "hello world"
@@ -779,7 +767,7 @@ val WMove = describe "move motion 'W'"
Expect.isTrue (chr = #"w") Expect.isTrue (chr = #"w")
end) end)
, test "moves cursor to start of next word in split string" (fn _ => , test "moves cursor to start of next WORD in split string" (fn _ =>
let let
(* arrange *) (* arrange *)
val buffer = fromList ["hello ", "world"] val buffer = fromList ["hello ", "world"]
@@ -794,7 +782,7 @@ val WMove = describe "move motion 'W'"
Expect.isTrue (chr = #"w") Expect.isTrue (chr = #"w")
end) end)
, test "moves cursor past newline when next word is after newline" (fn _ => , test "moves cursor past newline when next WORD is after newline" (fn _ =>
let let
(* arrange *) (* arrange *)
val buffer = LineGap.fromString "hello \n\n\n world" val buffer = LineGap.fromString "hello \n\n\n world"
@@ -809,58 +797,57 @@ val WMove = describe "move motion 'W'"
Expect.isTrue (cursorChr = #"w") Expect.isTrue (cursorChr = #"w")
end) end)
, test "moves cursor past punctuation when in alphanumeric char" (fn _ => , test "does not break on punctuation when cursor is on alphanumeric char"
(* vi's definition of 'WORD' instead of 'word' *)
let
(* arrange *)
val buffer = LineGap.fromString "hello, world"
val app = AppType.init (buffer, 0, 0)
(* act *)
val (app, _) = AppUpdate.update (app, CHAR_EVENT #"W")
(* assert *)
val cursorChr = getChr app
in
Expect.isTrue (cursorChr = #"w")
end)
, test "moves cursor past alphanumeric char when in punctuation" (fn _ =>
(* vi's definition of 'WORD' instead of 'word' *)
let
(* arrange *)
val buffer = LineGap.fromString "!hello!!! world!!!\n"
val app = AppType.init (buffer, 0, 0)
(* act *)
val (app, _) = AppUpdate.update (app, CHAR_EVENT #"W")
(* assert *)
val cursorChr = getChr app
in
Expect.isTrue (cursorChr = #"w")
end)
, test
"moves cursor to first {alphanumeric|punctuation} \
\when cursor is in {space|tab|'\\n'}"
(fn _ => (fn _ =>
(* vi's definition of 'WORD' instead of 'word' *)
let let
(* arrange *) (* arrange *)
val buffer = LineGap.fromString "0123 \t \n \t 789\n" val buffer = LineGap.fromString "hello, world"
val app = AppType.init (buffer, 0, 0) val app = AppType.init (buffer, 0, 0)
val app = withIdx (app, 4)
(* act *) (* act *)
val (app, _) = AppUpdate.update (app, CHAR_EVENT #"w") val (app, _) = AppUpdate.update (app, CHAR_EVENT #"W")
(* assert *) (* assert *)
val cursorChr = getChr app val cursorChr = getChr app
in in
Expect.isTrue (cursorChr = #"7") Expect.isTrue (cursorChr = #"w")
end) end)
, test "moves cursor to last char in buffer when in last word" (fn _ => , test "does not break on alphanumeric char when cursor is on punctuation"
(fn _ =>
(* vi's definition of 'WORD' instead of 'word' *)
let
(* arrange *)
val buffer = LineGap.fromString "#!hello!!! world!!!\n"
val app = AppType.init (buffer, 0, 0)
(* act *)
val (app, _) = AppUpdate.update (app, CHAR_EVENT #"W")
(* assert *)
val cursorChr = getChr app
in
Expect.isTrue (cursorChr = #"w")
end)
, test "moves cursor to first non-blank when cursor is on blank" (fn _ =>
let
(* arrange *)
val buffer = LineGap.fromString "0123 \t \n \t 789\n"
val app = AppType.init (buffer, 0, 0)
val app = withIdx (app, 4)
(* act *)
val (app, _) = AppUpdate.update (app, CHAR_EVENT #"w")
(* assert *)
val cursorChr = getChr app
in
Expect.isTrue (cursorChr = #"7")
end)
, test "moves cursor to last char when cursor is on last word" (fn _ =>
let let
(* arrange *) (* arrange *)
val buffer = LineGap.fromString "hello world\n" val buffer = LineGap.fromString "hello world\n"