aboutsummaryrefslogtreecommitdiff
path: root/ttt.jai
diff options
context:
space:
mode:
authordam <devnull@localhost>2024-02-10 16:46:54 +0000
committerdam <devnull@localhost>2024-02-10 16:46:54 +0000
commitb3c9a89d19a3021f56a8d9249307a0c38ee5cfd6 (patch)
treed7a68c9349fe2c16b3ebb050277a078ad601e342 /ttt.jai
parent206b56b08f334fc2fe743f91bebbe070cb72f4d5 (diff)
downloadtask-time-tracker-b3c9a89d19a3021f56a8d9249307a0c38ee5cfd6.tar.zst
task-time-tracker-b3c9a89d19a3021f56a8d9249307a0c38ee5cfd6.zip
Improved TUI tests.
Diffstat (limited to 'ttt.jai')
-rw-r--r--ttt.jai62
1 files changed, 39 insertions, 23 deletions
diff --git a/ttt.jai b/ttt.jai
index 6759342..8987a77 100644
--- a/ttt.jai
+++ b/ttt.jai
@@ -1238,19 +1238,19 @@ main :: () {
// -- -- -- Testing TUI -- START
if 1 {
- print("TEST : set and get cursor position --\n", to_standard_error = true);
+ print("TEST : set and get cursor position\n", to_standard_error = true);
TUI.start();
ROW :: 3;
COLUMN :: 3;
TUI.set_cursor_position(ROW, COLUMN);
row, column := TUI.get_cursor_position();
TUI.stop();
- assert(row == ROW && column == COLUMN, "Failed set/get cursor position.\n");
- print("> success\n", to_standard_error = true);
+ assert(row == ROW && column == COLUMN, "# Failed set/get cursor position.\n");
+ print("- success\n", to_standard_error = true);
}
if 1 {
- print("TEST : test key input --\n", to_standard_error = true);
+ print("TEST : test key input\n", to_standard_error = true);
auto_release_temp();
TUI.start();
TUI.clear_terminal();
@@ -1274,11 +1274,11 @@ main :: () {
set_temporary_storage_mark(__mark);
}
TUI.stop();
- print("> success\n", to_standard_error = true);
+ print("- success\n", to_standard_error = true);
}
- if 0 {
- print("TEST : draw box --\n", to_standard_error = true);
+ if 1 {
+ print("TEST : draw box\n", to_standard_error = true);
auto_release_temp();
TUI.start();
TUI.clear_terminal();
@@ -1287,12 +1287,14 @@ main :: () {
print("Can you see the box below? (y/n)");
key := TUI.get_key();
TUI.stop();
- assert(key == #char "y", "Failed to draw box.\n");
- print("> success\n", to_standard_error = true);
+
+ print("\n\n\rDEBUG DEBUG WIP WIP WIP TODO HACK\n\n\r>%<\n\r", TUI.to_string(key)); // TODO WIP Currently debugging this.
+ assert(key == #char "y", "# Failed to draw box.\n");
+ print("- success\n", to_standard_error = true);
}
- if 0 {
- print("TEST : get terminal size --\n", to_standard_error = true);
+ if 1 {
+ print("TEST : get terminal size\n", to_standard_error = true);
auto_release_temp();
TUI.start();
TUI.clear_terminal();
@@ -1304,15 +1306,30 @@ main :: () {
key = TUI.get_key();
}
TUI.stop();
- assert(key == #char "y", "Failed to get terminal size.\n");
- print("> success\n", to_standard_error = true);
+ assert(key == #char "y", "# Failed to get terminal size.\n");
+ print("- success\n", to_standard_error = true);
+ }
+
+ if 1 {
+ print("TEST : set terminal title\n", to_standard_error = true);
+ TUI.start();
+ title := "BAZINGA";
+ TUI.set_terminal_title(title);
+ TUI.set_cursor_position(1, 1);
+ print("Is terminal title '%'? (y/n)", title);
+ key: TUI.Key = xx TUI.Keys.None;
+ while (key == xx TUI.Keys.None || key == xx TUI.Keys.Resize) {
+ key = TUI.get_key();
+ }
+ TUI.stop();
+ assert(key == #char "y", "# Failed to set terminal title.\n");
+ print("- success\n", to_standard_error = true);
}
if 1 {
- print("TEST : print keys and set terminal title --\n", to_standard_error = true);
+ print("TEST : print keys and set terminal title\n", to_standard_error = true);
TUI.start();
TUI.set_terminal_title("bazinga");
- xcolumns, xrows: int;
key: TUI.Key = #char "d";
last_none_char := "X";
drop_down := 0;
@@ -1361,17 +1378,16 @@ main :: () {
y := ifx size_c > 24 then size_c-24 else 1;
TUI.set_cursor_position(x, y);
print("size(CxR): %x%\n", size_c, size_r);
-
- key = TUI.get_key(3000);
+
+ key = TUI.get_key(1000);
set_temporary_storage_mark(__mark);
}
TUI.stop();
- print("size(CxR): %x%\n", xcolumns, xrows);
}
- if 1 {
- print("TEST : user input --\n", to_standard_error = true);
+ if 0 {
+ print("TEST : user input\n", to_standard_error = true);
auto_release_temp();
TUI.start();
TUI.clear_terminal();
@@ -1384,18 +1400,18 @@ main :: () {
case TUI.Keys.Escape; {
print("Have you pressed Esc? (y/n)");
assert(TUI.get_key() == #char "y", "Failed to read line on Esc.");
- print("> success\n", to_standard_error = true);
+ print("- success\n", to_standard_error = true);
}
case TUI.Keys.Resize; {
print("Have you resized the terminal? (y/n)");
assert(TUI.get_key() == #char "y", "Failed to read line on resize.");
- print("> success\n", to_standard_error = true);
+ print("- success\n", to_standard_error = true);
}
case; {
print("Have you entered '%'? (y/n)", str);
assert(TUI.get_key() == #char "y", "Failed to read line.");
- print("> success\n", to_standard_error = true);
+ print("- success\n", to_standard_error = true);
}
}
TUI.stop();