diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..41d11bd --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +shf +shf-tests diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ab111fd --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +run: + ./build-unix.sh && ./shf + +tests: + mlton shf-tests.mlb && ./shf-tests diff --git a/shf b/shf deleted file mode 100755 index b03ac00..0000000 Binary files a/shf and /dev/null differ diff --git a/shf-tests b/shf-tests deleted file mode 100755 index af7a104..0000000 Binary files a/shf-tests and /dev/null differ diff --git a/test/test.sml b/test/test.sml index 1a28e95..6a08b5e 100644 --- a/test/test.sml +++ b/test/test.sml @@ -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