Skip to content

Commit

Permalink
update tests for repl use
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanStarup committed Oct 30, 2022
1 parent e40c6bf commit 0cbec4d
Showing 1 changed file with 34 additions and 12 deletions.
46 changes: 34 additions & 12 deletions test/TestTerminal.flix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ namespace TestTerminal {

def sleepTime(): Int64 = 1000i64

def nextLineIsh(): Unit \ IO = {
Terminal.cursorDown(1);
outputLine("")
}

pub def testCursorUp(): Unit \ IO =
outputLine("Expected Line: <<<x>>>");
outputLine("<<< >>>");
Expand All @@ -21,7 +26,8 @@ namespace TestTerminal {
Terminal.cursorUp(1);
sleep(sleepTime());

output("x")
output("x");
nextLineIsh()

pub def testCursorDown(): Unit \ IO =
outputLine("Expected Line: <<<x>>>");
Expand All @@ -34,7 +40,8 @@ namespace TestTerminal {
Terminal.cursorDown(1);
sleep(sleepTime());

output("x")
output("x");
nextLineIsh()

pub def testCursorForward(): Unit \ IO =
outputLine("Expected Line: <<<x>>>");
Expand All @@ -46,7 +53,8 @@ namespace TestTerminal {
Terminal.cursorForward(3);
sleep(sleepTime());

output("x")
output("x");
nextLineIsh()

pub def testCursorBack(): Unit \ IO =
outputLine("Expected Line: <<<x>>>");
Expand All @@ -59,7 +67,8 @@ namespace TestTerminal {
Terminal.cursorBack(4);
sleep(sleepTime());

output("x")
output("x");
nextLineIsh()

pub def testCursorTo(): Unit \ IO =
Terminal.clearScreenAndReset();
Expand All @@ -71,7 +80,8 @@ namespace TestTerminal {
Terminal.cursorTo(row = 1, 3);
sleep(sleepTime());

output("x")
output("x");
nextLineIsh()

pub def testClearScreenAfterCursor(): Unit \ IO =
outputLine("Expected Line: <<<x>>>");
Expand All @@ -84,7 +94,8 @@ namespace TestTerminal {
Terminal.cursorForward(7);
sleep(sleepTime());
Terminal.clearScreenAfterCursor();
sleep(sleepTime())
sleep(sleepTime());
nextLineIsh()

pub def testClearScreenBeforeCursor(): Unit \ IO =
outputLine("Expected Line: <<<x>>>");
Expand All @@ -97,7 +108,8 @@ namespace TestTerminal {
Terminal.cursorForward(3);
sleep(sleepTime());
Terminal.clearScreenBeforeCursor();
sleep(sleepTime())
sleep(sleepTime());
nextLineIsh()

pub def testClearScreenAndReset(): Unit \ IO =
outputLine("Expected Line: <<<x>>>");
Expand All @@ -107,7 +119,8 @@ namespace TestTerminal {
sleep(sleepTime());
Terminal.clearScreenAndReset();
sleep(sleepTime());
outputLine("<<<x>>>")
outputLine("<<<x>>>");
nextLineIsh()

pub def testClearLineAfterCursor(): Unit \ IO =
outputLine("Expected Line: <<<x>>>");
Expand All @@ -117,7 +130,8 @@ namespace TestTerminal {
Terminal.cursorBack(7);
sleep(sleepTime());
Terminal.clearLineAfterCursor();
sleep(sleepTime())
sleep(sleepTime());
nextLineIsh()

pub def testClearLineBeforeCursor(): Unit \ IO =
outputLine("Expected Line: <<<x>>>");
Expand All @@ -127,7 +141,8 @@ namespace TestTerminal {
Terminal.cursorBack(8);
sleep(sleepTime());
Terminal.clearLineBeforeCursor();
sleep(sleepTime())
sleep(sleepTime());
nextLineIsh()

pub def testClearLine(): Unit \ IO =
outputLine("Expected Line: <<<x>>>");
Expand All @@ -138,10 +153,16 @@ namespace TestTerminal {
Terminal.cursorBack(3);
sleep(sleepTime());
Terminal.clearLine();
sleep(sleepTime())
sleep(sleepTime());
nextLineIsh()

pub def testSaveAndRestore(): Unit \ IO =
outputLine("Expected Line: <<<x>>>");

// avoid scrolling
outputLine("");
Terminal.cursorUp(1);

output("<<<");
Terminal.saveCursor();
outputLine(" >>>");
Expand All @@ -150,6 +171,7 @@ namespace TestTerminal {
Terminal.restoreCursor();
sleep(sleepTime());

output("x")
output("x");
nextLineIsh()

}

0 comments on commit 0cbec4d

Please sign in to comment.