Skip to content

Commit

Permalink
Fixing test.
Browse files Browse the repository at this point in the history
  • Loading branch information
lahodaj committed Jan 21, 2025
1 parent 881bef1 commit 14e2e59
Showing 1 changed file with 36 additions and 28 deletions.
64 changes: 36 additions & 28 deletions test/langtools/jdk/jshell/ConsoleToolTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,39 +59,47 @@ public void testOutput() {
@Test //JDK-8341631
public void testIO() {
test(new String[] {"--enable-preview"},
a -> {assertCommandWithOutputAndTerminal(a,
"java.lang.IO.readln(\"%%s\");\ninput", //newline automatically appended
"$1 ==> \"input\"",
"""
\u0005java.lang.IO.readln(\"%%s\");
%%sinput
""");},
a -> {assertCommandWithOutputAndTerminal(a,
"java.lang.IO.readln();\ninput!", //newline automatically appended
"$2 ==> \"input!\"",
"""
\u0005java.lang.IO.readln();
input!
""");},
a -> {assertCommandWithOutputAndTerminal(a,
"java.lang.IO.println(\"Hello, World!\");",
"",
"""
\u0005java.lang.IO.println(\"Hello, World!\");
Hello, World!
""");},
a -> {assertCommandWithOutputAndTerminal(a,
"java.lang.IO.println();",
"",
"""
\u0005java.lang.IO.println();
""");}
a -> {assertCommandWithOutputAndInput(a,
"java.lang.IO.readln(\"%%s\");",
"input\n",
"$1 ==> \"input\"",
"%%s",
"""
\u0005java.lang.IO.readln(\"%%s\");
""");},
a -> {assertCommandWithOutputAndInput(a,
"java.lang.IO.readln();",
"input!\n",
"$2 ==> \"input!\"",
"",
"""
\u0005java.lang.IO.readln();
""");},
a -> {assertCommandWithOutputAndInput(a,
"java.lang.IO.println(\"Hello, World!\");",
"",
"",
"Hello, World!\n",
"""
\u0005java.lang.IO.println(\"Hello, World!\");
""");},
a -> {assertCommandWithOutputAndInput(a,
"java.lang.IO.println();",
"",
"",
"\n",
"""
\u0005java.lang.IO.println();
""");}
);
}

void assertCommandWithOutputAndTerminal(boolean a, String command, String out, String terminalOut) {
assertCommand(a, command, out, null, null, null, null, terminalOut);
}

void assertCommandWithOutputAndInput(boolean a, String command, String input, String out, String print, String terminalOut) {
assertCommand(a, command, out, null, input, print, null, terminalOut);
}

}

0 comments on commit 14e2e59

Please sign in to comment.