a bit of repository management (add Makefile to make it less verbose to run tests, and add .gitignore to avoid committing built binaries)
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
shf
|
||||
shf-tests
|
||||
5
Makefile
Normal file
5
Makefile
Normal file
@@ -0,0 +1,5 @@
|
||||
run:
|
||||
./build-unix.sh && ./shf
|
||||
|
||||
tests:
|
||||
mlton shf-tests.mlb && ./shf-tests
|
||||
@@ -28,22 +28,8 @@ fun withIdx (app: AppType.app_type, idx) =
|
||||
}
|
||||
end
|
||||
|
||||
val cursorTests = describe "cursor operations"
|
||||
[ test "'h' does not move cursor when cursorIdx = 0" (fn _ =>
|
||||
let
|
||||
(* arrange *)
|
||||
val buffer = LineGap.fromString "hello world"
|
||||
val app = AppType.init (buffer, 0, 0)
|
||||
val {cursorIdx = oldCursorIdx, ...} = app
|
||||
|
||||
(* act *)
|
||||
val ({cursorIdx, ...}, _) = AppUpdate.update (app, CHAR_EVENT #"h")
|
||||
in
|
||||
(* assert *)
|
||||
Expect.isTrue (oldCursorIdx = 0 andalso cursorIdx = 0)
|
||||
end)
|
||||
|
||||
, test "'h' moves cursor left by one in contiguous string when cursorIdx > 0"
|
||||
val movementTests = describe "movement operations"
|
||||
[ test "'h' moves cursor left by one in contiguous string when cursorIdx > 0"
|
||||
(fn _ =>
|
||||
let
|
||||
(* arrange *)
|
||||
@@ -80,6 +66,20 @@ val cursorTests = describe "cursor operations"
|
||||
Expect.isTrue (cursorIdx = 4)
|
||||
end)
|
||||
|
||||
, test "'h' does not move cursor when cursorIdx = 0" (fn _ =>
|
||||
let
|
||||
(* arrange *)
|
||||
val buffer = LineGap.fromString "hello world"
|
||||
val app = AppType.init (buffer, 0, 0)
|
||||
val {cursorIdx = oldCursorIdx, ...} = app
|
||||
|
||||
(* act *)
|
||||
val ({cursorIdx, ...}, _) = AppUpdate.update (app, CHAR_EVENT #"h")
|
||||
in
|
||||
(* assert *)
|
||||
Expect.isTrue (oldCursorIdx = 0 andalso cursorIdx = 0)
|
||||
end)
|
||||
|
||||
, test
|
||||
"'h' moves cursor left by two in contiguous string when prev chr is \\n"
|
||||
(fn _ =>
|
||||
@@ -254,6 +254,6 @@ val cursorTests = describe "cursor operations"
|
||||
end)
|
||||
]
|
||||
|
||||
val tests = concat [cursorTests]
|
||||
val tests = concat [movementTests]
|
||||
|
||||
val _ = run tests
|
||||
|
||||
Reference in New Issue
Block a user