From 14e2e59343fd923d0c636868f13af583bb961870 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Tue, 21 Jan 2025 10:58:12 +0100 Subject: [PATCH] Fixing test. --- .../langtools/jdk/jshell/ConsoleToolTest.java | 64 +++++++++++-------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/test/langtools/jdk/jshell/ConsoleToolTest.java b/test/langtools/jdk/jshell/ConsoleToolTest.java index 5fa48d55bd4ea..bed4add0d30c6 100644 --- a/test/langtools/jdk/jshell/ConsoleToolTest.java +++ b/test/langtools/jdk/jshell/ConsoleToolTest.java @@ -59,34 +59,38 @@ 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(); + """);} ); } @@ -94,4 +98,8 @@ void assertCommandWithOutputAndTerminal(boolean a, String command, String out, S 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); + } + }