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
|
end
|
||||||
|
|
||||||
val cursorTests = describe "cursor operations"
|
val movementTests = describe "movement operations"
|
||||||
[ test "'h' does not move cursor when cursorIdx = 0" (fn _ =>
|
[ test "'h' moves cursor left by one in contiguous string when cursorIdx > 0"
|
||||||
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"
|
|
||||||
(fn _ =>
|
(fn _ =>
|
||||||
let
|
let
|
||||||
(* arrange *)
|
(* arrange *)
|
||||||
@@ -80,6 +66,20 @@ val cursorTests = describe "cursor operations"
|
|||||||
Expect.isTrue (cursorIdx = 4)
|
Expect.isTrue (cursorIdx = 4)
|
||||||
end)
|
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
|
, test
|
||||||
"'h' 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 _ =>
|
||||||
@@ -254,6 +254,6 @@ val cursorTests = describe "cursor operations"
|
|||||||
end)
|
end)
|
||||||
]
|
]
|
||||||
|
|
||||||
val tests = concat [cursorTests]
|
val tests = concat [movementTests]
|
||||||
|
|
||||||
val _ = run tests
|
val _ = run tests
|
||||||
|
|||||||
Reference in New Issue
Block a user