break test suite in test.sml into more managable chunks (one test per motion)
This commit is contained in:
@@ -75,8 +75,8 @@ fun getChr (app: AppType.app_type) =
|
|||||||
String.sub (c, 0)
|
String.sub (c, 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
val movementTests = describe "movement operations"
|
val hMove = describe "move motion 'h'"
|
||||||
[ test "'h' moves cursor left by one in contiguous string when cursorIdx > 0"
|
[ test "moves cursor left by one in contiguous string when cursorIdx > 0"
|
||||||
(fn _ =>
|
(fn _ =>
|
||||||
let
|
let
|
||||||
(* arrange *)
|
(* arrange *)
|
||||||
@@ -91,8 +91,7 @@ val movementTests = describe "movement operations"
|
|||||||
Expect.isTrue (cursorIdx = 0)
|
Expect.isTrue (cursorIdx = 0)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
, test "'h' moves cursor left by one in split string when cursorIdx > 0"
|
, test "moves cursor left by one in split string when cursorIdx > 0" (fn _ =>
|
||||||
(fn _ =>
|
|
||||||
let
|
let
|
||||||
(* arrange *)
|
(* arrange *)
|
||||||
val buffer = fromList ["hello", " world"]
|
val buffer = fromList ["hello", " world"]
|
||||||
@@ -106,7 +105,7 @@ val movementTests = describe "movement operations"
|
|||||||
Expect.isTrue (cursorIdx = 4)
|
Expect.isTrue (cursorIdx = 4)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
, test "'h' does not move cursor when cursorIdx = 0" (fn _ =>
|
, test "does not move cursor when cursorIdx = 0" (fn _ =>
|
||||||
let
|
let
|
||||||
(* arrange *)
|
(* arrange *)
|
||||||
val buffer = LineGap.fromString "hello world"
|
val buffer = LineGap.fromString "hello world"
|
||||||
@@ -120,8 +119,7 @@ val movementTests = describe "movement operations"
|
|||||||
Expect.isTrue (oldCursorIdx = 0 andalso cursorIdx = 0)
|
Expect.isTrue (oldCursorIdx = 0 andalso cursorIdx = 0)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
, test
|
, test "moves cursor left by two in contiguous string when prev chr is \\n"
|
||||||
"'h' moves cursor left by two in contiguous string when prev chr is \\n"
|
|
||||||
(fn _ =>
|
(fn _ =>
|
||||||
let
|
let
|
||||||
(* arrange *)
|
(* arrange *)
|
||||||
@@ -136,7 +134,7 @@ val movementTests = describe "movement operations"
|
|||||||
Expect.isTrue (cursorIdx = 4)
|
Expect.isTrue (cursorIdx = 4)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
, test "'h' moves cursor left by two in split string when prev chr is \\n"
|
, test "moves cursor left by two in split string when prev chr is \\n"
|
||||||
(fn _ =>
|
(fn _ =>
|
||||||
let
|
let
|
||||||
(* arrange *)
|
(* arrange *)
|
||||||
@@ -150,9 +148,11 @@ val movementTests = describe "movement operations"
|
|||||||
(* assert *)
|
(* assert *)
|
||||||
Expect.isTrue (cursorIdx = 4)
|
Expect.isTrue (cursorIdx = 4)
|
||||||
end)
|
end)
|
||||||
|
]
|
||||||
|
|
||||||
, test
|
val lMove = describe "move motion 'l'"
|
||||||
"'l' moves cursor right by one in contiguous string when cursorIdx < length"
|
[ test
|
||||||
|
"moves cursor right by one in contiguous string when cursorIdx < length"
|
||||||
(fn _ =>
|
(fn _ =>
|
||||||
let
|
let
|
||||||
(* arrange *)
|
(* arrange *)
|
||||||
@@ -167,7 +167,7 @@ val movementTests = describe "movement operations"
|
|||||||
Expect.isTrue (oldCursorIdx = 0 andalso cursorIdx = 1)
|
Expect.isTrue (oldCursorIdx = 0 andalso cursorIdx = 1)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
, test "'l' moves cursor right by one in split string when cursorIdx < length"
|
, test "moves cursor right by one in split string when cursorIdx < length"
|
||||||
(fn _ =>
|
(fn _ =>
|
||||||
let
|
let
|
||||||
(* arrange *)
|
(* arrange *)
|
||||||
@@ -182,8 +182,7 @@ val movementTests = describe "movement operations"
|
|||||||
Expect.isTrue (oldCursorIdx = 0 andalso cursorIdx = 1)
|
Expect.isTrue (oldCursorIdx = 0 andalso cursorIdx = 1)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
, test "'l' does not move cursor right by one when cursorIdx = length"
|
, test "does not move cursor right by one when cursorIdx = length" (fn _ =>
|
||||||
(fn _ =>
|
|
||||||
let
|
let
|
||||||
(* arrange *)
|
(* arrange *)
|
||||||
val buffer = LineGap.fromString "hello world\n"
|
val buffer = LineGap.fromString "hello world\n"
|
||||||
@@ -197,8 +196,7 @@ val movementTests = describe "movement operations"
|
|||||||
Expect.isTrue (cursorIdx = 10)
|
Expect.isTrue (cursorIdx = 10)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
, test
|
, test "moves right by two in contiguous string when char is followed by \\n"
|
||||||
"'l' moves right by two in contiguous string when char is followed by \\n"
|
|
||||||
(fn _ =>
|
(fn _ =>
|
||||||
let
|
let
|
||||||
(* arrange *)
|
(* arrange *)
|
||||||
@@ -213,7 +211,7 @@ val movementTests = describe "movement operations"
|
|||||||
Expect.isTrue (cursorIdx = 6)
|
Expect.isTrue (cursorIdx = 6)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
, test "'l' moves right by two in split string when char is followed by \\n"
|
, test "moves right by two in split string when char is followed by \\n"
|
||||||
(fn _ =>
|
(fn _ =>
|
||||||
let
|
let
|
||||||
(* arrange *)
|
(* arrange *)
|
||||||
@@ -227,8 +225,10 @@ val movementTests = describe "movement operations"
|
|||||||
(* assert *)
|
(* assert *)
|
||||||
Expect.isTrue (cursorIdx = 6)
|
Expect.isTrue (cursorIdx = 6)
|
||||||
end)
|
end)
|
||||||
|
]
|
||||||
|
|
||||||
, test "'j' moves cursur down one column in contiguous string when column = 0"
|
val jMove = describe "move motion 'j'"
|
||||||
|
[ test "moves cursur down one column in contiguous string when column = 0"
|
||||||
(fn _ =>
|
(fn _ =>
|
||||||
let
|
let
|
||||||
(* arrange *)
|
(* arrange *)
|
||||||
@@ -251,8 +251,7 @@ val movementTests = describe "movement operations"
|
|||||||
Expect.isTrue (c1 andalso c2 andalso c3)
|
Expect.isTrue (c1 andalso c2 andalso c3)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
, test "'j' moves cursur down one column in split string when column = 0"
|
, test "moves cursur down one column in split string when column = 0" (fn _ =>
|
||||||
(fn _ =>
|
|
||||||
let
|
let
|
||||||
(* arrange *)
|
(* arrange *)
|
||||||
val buffer = fromList ["hello \n", "world \n", "goodbye \n", "qorld"]
|
val buffer = fromList ["hello \n", "world \n", "goodbye \n", "qorld"]
|
||||||
@@ -271,7 +270,7 @@ val movementTests = describe "movement operations"
|
|||||||
Expect.isTrue (c1 andalso c2 andalso c3)
|
Expect.isTrue (c1 andalso c2 andalso c3)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
, test "'j' moves cursur down one column in contiguous string when column = 1"
|
, test "moves cursur down one column in contiguous string when column = 1"
|
||||||
(fn _ =>
|
(fn _ =>
|
||||||
let
|
let
|
||||||
(* arrange *)
|
(* arrange *)
|
||||||
@@ -292,12 +291,10 @@ val movementTests = describe "movement operations"
|
|||||||
Expect.isTrue (c1 andalso c2 andalso c3)
|
Expect.isTrue (c1 andalso c2 andalso c3)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
, test "'j' moves cursur down one column in split string when column = 1"
|
, test "moves cursur down one column in split string when column = 1" (fn _ =>
|
||||||
(fn _ =>
|
|
||||||
let
|
let
|
||||||
(* arrange *)
|
(* arrange *)
|
||||||
val buffer =
|
val buffer = fromList ["hello \n", "world ", "\nb", "ye \nfriends \n"]
|
||||||
fromList ["hello \n", "world ", "\nb", "ye \nfriends \n"]
|
|
||||||
val app = AppType.init (buffer, 0, 0)
|
val app = AppType.init (buffer, 0, 0)
|
||||||
val app = withIdx (app, 1)
|
val app = withIdx (app, 1)
|
||||||
|
|
||||||
@@ -314,7 +311,7 @@ val movementTests = describe "movement operations"
|
|||||||
Expect.isTrue (c1 andalso c2 andalso c3)
|
Expect.isTrue (c1 andalso c2 andalso c3)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
, test "'j' moves cursur down one column in contiguous string when column = 2"
|
, test "moves cursur down one column in contiguous string when column = 2"
|
||||||
(fn _ =>
|
(fn _ =>
|
||||||
let
|
let
|
||||||
(* arrange *)
|
(* arrange *)
|
||||||
@@ -335,12 +332,10 @@ val movementTests = describe "movement operations"
|
|||||||
Expect.isTrue (c1 andalso c2 andalso c3)
|
Expect.isTrue (c1 andalso c2 andalso c3)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
, test "'j' moves cursur down one column in split string when column = 2"
|
, test "moves cursur down one column in split string when column = 2" (fn _ =>
|
||||||
(fn _ =>
|
|
||||||
let
|
let
|
||||||
(* arrange *)
|
(* arrange *)
|
||||||
val buffer =
|
val buffer = fromList ["hello \n", "world ", "\nb", "ye \nfriends \n"]
|
||||||
fromList ["hello \n", "world ", "\nb", "ye \nfriends \n"]
|
|
||||||
val app = AppType.init (buffer, 0, 0)
|
val app = AppType.init (buffer, 0, 0)
|
||||||
val app = withIdx (app, 2)
|
val app = withIdx (app, 2)
|
||||||
|
|
||||||
@@ -357,8 +352,7 @@ val movementTests = describe "movement operations"
|
|||||||
Expect.isTrue (c1 andalso c2 andalso c3)
|
Expect.isTrue (c1 andalso c2 andalso c3)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
, test
|
, test "skips '\\n' when cursor is on non-\\n and is followed by two '\\n's"
|
||||||
"'j' skips '\\n' when cursor is on non-\\n and is followed by two '\\n's"
|
|
||||||
(fn _ =>
|
(fn _ =>
|
||||||
let
|
let
|
||||||
(* arrange *)
|
(* arrange *)
|
||||||
@@ -374,7 +368,7 @@ val movementTests = describe "movement operations"
|
|||||||
Expect.isTrue isSkipped
|
Expect.isTrue isSkipped
|
||||||
end)
|
end)
|
||||||
|
|
||||||
, test "'j' moves to end of buffer when on last line" (fn _ =>
|
, test "moves to end of buffer when on last line" (fn _ =>
|
||||||
let
|
let
|
||||||
(* arrange *)
|
(* arrange *)
|
||||||
val str = "hello \nworld \ntime to go\n"
|
val str = "hello \nworld \ntime to go\n"
|
||||||
@@ -394,8 +388,10 @@ val movementTests = describe "movement operations"
|
|||||||
in
|
in
|
||||||
Expect.isTrue isAtEnd
|
Expect.isTrue isAtEnd
|
||||||
end)
|
end)
|
||||||
|
]
|
||||||
|
|
||||||
, test "'w' moves cursor to start of next word in contiguous string" (fn _ =>
|
val wMove = describe "move motion 'w'"
|
||||||
|
[ 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"
|
||||||
@@ -410,7 +406,7 @@ val movementTests = describe "movement operations"
|
|||||||
Expect.isTrue (chr = #"w")
|
Expect.isTrue (chr = #"w")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
, test "'w' 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"]
|
||||||
@@ -426,6 +422,6 @@ val movementTests = describe "movement operations"
|
|||||||
end)
|
end)
|
||||||
]
|
]
|
||||||
|
|
||||||
val tests = concat [movementTests]
|
val tests = concat [hMove, lMove, jMove, wMove]
|
||||||
|
|
||||||
val _ = run tests
|
val _ = run tests
|
||||||
|
|||||||
Reference in New Issue
Block a user