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:
2024-11-19 04:32:37 +00:00
parent afcd3ee70b
commit 96080d0964
5 changed files with 24 additions and 17 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
shf
shf-tests

5
Makefile Normal file
View File

@@ -0,0 +1,5 @@
run:
./build-unix.sh && ./shf
tests:
mlton shf-tests.mlb && ./shf-tests

BIN
shf

Binary file not shown.

BIN
shf-tests

Binary file not shown.

View File

@@ -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