/* * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
// Test handling of bogus options publicvoid testUnknown() {
startExCe(1, "Unknown option: u", "-unknown");
startExCe(1, "Unknown option: unknown", "--unknown");
}
// Test that input is read with "-" and there is no extra output. publicvoid testHypenFile() {
setIn("System.out.print(\"Hello\");\n");
startUo("Hello", "-");
setIn("System.out.print(\"Hello\");\n");
startUo("Hello", "-", "-");
String fn = writeToFile("System.out.print(\"===\");");
setIn("System.out.print(\"Hello\");\n");
startUo("===Hello===", fn, "-", fn); // check that errors go to standard error
setIn(") Foobar");
startExCe(0, s -> assertTrue(s.contains("illegal start of expression"), "cmderr: illegal start of expression"), "-");
}
// Test that non-existent load file sends output to stderr and does not startExCe (no welcome). publicvoid testUnknownLoadFile() {
startExCe(1, "File 'UNKNOWN' for 'jshell' is not found.", "UNKNOWN");
}
// Test bad usage of the --startup option publicvoid testStartup() {
String fn = writeToFile("");
startExCe(1, "Argument to startup missing.", "--startup");
startExCe(1, "Conflicting options: both --startup and --no-startup were used.", "--no-startup", "--startup", fn);
startExCe(1, "Conflicting options: both --startup and --no-startup were used.", "--startup", fn, "--no-startup");
startExCe(1, "Argument to startup missing.", "--no-startup", "--startup");
}
// Test an option that causes the back-end to fail is propagated publicvoid testStartupFailedOption() {
startExCe(1, s -> assertTrue(s.contains("Unrecognized option: -hoge-foo-bar"), "cmderr: " + s), "-R-hoge-foo-bar");
}
// Test the use of non-existant files with the --startup option publicvoid testStartupUnknown() {
startExCe(1, "File 'UNKNOWN' for '--startup' is not found.", "--startup", "UNKNOWN");
startExCe(1, "File 'UNKNOWN' for '--startup' is not found.", "--startup", "DEFAULT", "--startup", "UNKNOWN");
}
// Test bad usage of --class-path option publicvoid testClasspath() { for (String cp : new String[]{"--class-path"}) {
startExCe(1, "Only one --class-path option may be used.", cp, ".", "--class-path", ".");
startExCe(1, "Argument to class-path missing.", cp);
}
}
// Test bogus module on --add-modules option publicvoid testUnknownModule() {
startExCe(1, s -> assertTrue(s.contains("rror") && s.contains("unKnown"), "cmderr: " + s), "--add-modules", "unKnown");
}
// Test that muliple feedback options fail publicvoid testFeedbackOptionConflict() {
startExCe(1, "Only one feedback option (--feedback, -q, -s, or -v) may be used.", "--feedback", "concise", "--feedback", "verbose");
startExCe(1, "Only one feedback option (--feedback, -q, -s, or -v) may be used.", "--feedback", "concise", "-s");
startExCe(1, "Only one feedback option (--feedback, -q, -s, or -v) may be used.", "--feedback", "verbose", "-q");
startExCe(1, "Only one feedback option (--feedback, -q, -s, or -v) may be used.", "--feedback", "concise", "-v");
startExCe(1, "Only one feedback option (--feedback, -q, -s, or -v) may be used.", "-v", "--feedback", "concise");
startExCe(1, "Only one feedback option (--feedback, -q, -s, or -v) may be used.", "-q", "-v");
startExCe(1, "Only one feedback option (--feedback, -q, -s, or -v) may be used.", "-s", "-v");
startExCe(1, "Only one feedback option (--feedback, -q, -s, or -v) may be used.", "-v", "-q");
startExCe(1, "Only one feedback option (--feedback, -q, -s, or -v) may be used.", "-q", "-s");
}
// Test bogus arguments to the --feedback option publicvoid testNegFeedbackOption() {
startExCe(1, "Argument to feedback missing.", "--feedback");
startExCe(1, "Does not match any current feedback mode: blorp -- --feedback blorp", "--feedback", "blorp");
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.