Skip to content

Commit

Permalink
Fix #198 - Check for unintialized raw stream.
Browse files Browse the repository at this point in the history
  • Loading branch information
bakpakin committed Sep 17, 2024
1 parent 253a67e commit 4c77afc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/rawterm.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ static void rawterm_begin(void) {
}

static void rawterm_getch(JanetBuffer *buf) {
if (rawterm_stream == NULL) janet_panic("call rawterm/begin to initialize");
janet_ev_read(rawterm_stream, buf, 1);
janet_await();
}
Expand Down
2 changes: 2 additions & 0 deletions test/suite-rawterm.janet
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

(start-suite)

(assert-error "issue #198" (rawterm/getch))

# TODO: This tests the reduced set of codepoints based on the original set in
# Bestline:
# https://github.com/jart/bestline/blob/4a09bf4355c15c96526/bestline.c#L274-L287
Expand Down

0 comments on commit 4c77afc

Please sign in to comment.