From a5d096be2e3c7b0ea3119ca2bff264eddfa77c77 Mon Sep 17 00:00:00 2001 From: Srinivas Dama Date: Wed, 20 Jan 2016 09:56:29 +0100 Subject: [PATCH] 8144113: enable jjs testing Reviewed-by: mhaupt, sundar --- nashorn/test/script/nosecurity/Hello.java | 34 ++++ nashorn/test/script/nosecurity/jjs-common.js | 190 ++++++++++++++++++ .../test/script/nosecurity/jjs-option-cp.js | 61 ++++++ .../nosecurity/jjs-option-cp.js.EXPECTED | 6 + .../script/nosecurity/jjs-option-define.js | 50 +++++ .../nosecurity/jjs-option-define.js.EXPECTED | 4 + .../test/script/nosecurity/jjs-option-doe.js | 61 ++++++ .../nosecurity/jjs-option-doe.js.EXPECTED | 6 + .../test/script/nosecurity/jjs-option-fv.js | 60 ++++++ .../nosecurity/jjs-option-fv.js.EXPECTED | 6 + .../test/script/nosecurity/jjs-option-fx.js | 49 +++++ .../nosecurity/jjs-option-fx.js.EXPECTED | 4 + .../test/script/nosecurity/jjs-option-lang.js | 60 ++++++ .../nosecurity/jjs-option-lang.js.EXPECTED | 6 + .../test/script/nosecurity/jjs-option-ot.js | 43 ++++ .../nosecurity/jjs-option-ot.js.EXPECTED | 4 + .../script/nosecurity/jjs-option-scripting.js | 60 ++++++ .../jjs-option-scripting.js.EXPECTED | 6 + .../script/nosecurity/jjs-option-strict.js | 55 +++++ .../nosecurity/jjs-option-strict.js.EXPECTED | 6 + .../script/nosecurity/jjs-option-version.js | 50 +++++ .../nosecurity/jjs-option-version.js.EXPECTED | 4 + 22 files changed, 825 insertions(+) create mode 100644 nashorn/test/script/nosecurity/Hello.java create mode 100644 nashorn/test/script/nosecurity/jjs-common.js create mode 100644 nashorn/test/script/nosecurity/jjs-option-cp.js create mode 100644 nashorn/test/script/nosecurity/jjs-option-cp.js.EXPECTED create mode 100644 nashorn/test/script/nosecurity/jjs-option-define.js create mode 100644 nashorn/test/script/nosecurity/jjs-option-define.js.EXPECTED create mode 100644 nashorn/test/script/nosecurity/jjs-option-doe.js create mode 100644 nashorn/test/script/nosecurity/jjs-option-doe.js.EXPECTED create mode 100644 nashorn/test/script/nosecurity/jjs-option-fv.js create mode 100644 nashorn/test/script/nosecurity/jjs-option-fv.js.EXPECTED create mode 100644 nashorn/test/script/nosecurity/jjs-option-fx.js create mode 100644 nashorn/test/script/nosecurity/jjs-option-fx.js.EXPECTED create mode 100644 nashorn/test/script/nosecurity/jjs-option-lang.js create mode 100644 nashorn/test/script/nosecurity/jjs-option-lang.js.EXPECTED create mode 100644 nashorn/test/script/nosecurity/jjs-option-ot.js create mode 100644 nashorn/test/script/nosecurity/jjs-option-ot.js.EXPECTED create mode 100644 nashorn/test/script/nosecurity/jjs-option-scripting.js create mode 100644 nashorn/test/script/nosecurity/jjs-option-scripting.js.EXPECTED create mode 100644 nashorn/test/script/nosecurity/jjs-option-strict.js create mode 100644 nashorn/test/script/nosecurity/jjs-option-strict.js.EXPECTED create mode 100644 nashorn/test/script/nosecurity/jjs-option-version.js create mode 100644 nashorn/test/script/nosecurity/jjs-option-version.js.EXPECTED diff --git a/nashorn/test/script/nosecurity/Hello.java b/nashorn/test/script/nosecurity/Hello.java new file mode 100644 index 00000000000..45879a38e1c --- /dev/null +++ b/nashorn/test/script/nosecurity/Hello.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2016, 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. + */ + +/** + * This is a test program used in the test jjs-option-cp.js + */ +public class Hello { + public Hello() { + } + + public String getString() { + return "hello"; + } +} diff --git a/nashorn/test/script/nosecurity/jjs-common.js b/nashorn/test/script/nosecurity/jjs-common.js new file mode 100644 index 00000000000..3ea30843a84 --- /dev/null +++ b/nashorn/test/script/nosecurity/jjs-common.js @@ -0,0 +1,190 @@ +/* + * Copyright (c) 2016, 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. + */ + +/** + * JDK-8144113: Nashorn: enable jjs testing. + * @subtest + * @summary test used by all other jjs-option* test cases + */ +var javaHome = $ENV.JAVA_HOME, + homeJjs = "${javaHome}/bin/jjs", + altJjs = $EXEC('which jjs').trim(), + homejavac = "${javaHome}/bin/javac", + altjavac = $EXEC('which javac').trim() + +var Files = Java.type('java.nio.file.Files'), + Paths = Java.type('java.nio.file.Paths'), + System = Java.type('java.lang.System') + +// Initialize default values for variables used in different functions +var func_cond_p = < -1 +EOD + +var func_cond_n = <<'EOD' +err.indexOf("internal") <= -1 +EOD + +// one particular test starts here +testjjs_flag_and_func("-doe", "") diff --git a/nashorn/test/script/nosecurity/jjs-option-doe.js.EXPECTED b/nashorn/test/script/nosecurity/jjs-option-doe.js.EXPECTED new file mode 100644 index 00000000000..1925827ab71 --- /dev/null +++ b/nashorn/test/script/nosecurity/jjs-option-doe.js.EXPECTED @@ -0,0 +1,6 @@ +-doe flag positive test: +flag test PASSED +functionality test PASSED +-doe flag negative test: +flag test PASSED +functionality test PASSED diff --git a/nashorn/test/script/nosecurity/jjs-option-fv.js b/nashorn/test/script/nosecurity/jjs-option-fv.js new file mode 100644 index 00000000000..2e36d0bd238 --- /dev/null +++ b/nashorn/test/script/nosecurity/jjs-option-fv.js @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2016, 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. + */ + +/** + * JDK-8144113: Nashorn: enable jjs testing. + * @test + * @option -scripting + * @runif os.not.windows + * @run + * @summary Test if -fv flag its basic funnctionality + */ + +load(__DIR__ + "jjs-common.js") + +// code to check -flag +var msg_flag = "print($OPTIONS._fullversion)" + +// code to check basic functionality +var msg_func = < -1 +EOD + +var func_cond_n = <<'EOD' +err.indexOf("full") <= -1 +EOD + +// one particular test starts here +testjjs_flag_and_func("-fv", "") diff --git a/nashorn/test/script/nosecurity/jjs-option-fv.js.EXPECTED b/nashorn/test/script/nosecurity/jjs-option-fv.js.EXPECTED new file mode 100644 index 00000000000..e364ec60909 --- /dev/null +++ b/nashorn/test/script/nosecurity/jjs-option-fv.js.EXPECTED @@ -0,0 +1,6 @@ +-fv flag positive test: +flag test PASSED +functionality test PASSED +-fv flag negative test: +flag test PASSED +functionality test PASSED diff --git a/nashorn/test/script/nosecurity/jjs-option-fx.js b/nashorn/test/script/nosecurity/jjs-option-fx.js new file mode 100644 index 00000000000..3a5c44cfefb --- /dev/null +++ b/nashorn/test/script/nosecurity/jjs-option-fx.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2016, 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. + */ + +/** + * JDK-8144113: Nashorn: enable jjs testing. + * check -fx option. + * @test + * @option -scripting + * @runif os.not.windows + * @run + * @summary Test -fx flag and its basic functionality + * the JavaFX primary stage is available to Nashorn as a global property $STAGE with -fx + * used this to check with and without -fx + */ + +load(__DIR__ + "jjs-common.js") + +var msg_flag = "print(typeof($STAGE));"; + +// flag test expected output variables +var e_outn = "undefined" + +// positive flag test condition expression string other than the default +var flag_cond_p = <<'EOD' +out != "undefined" +EOD + +// Testing starts here +testjjs_flag("-fx","") diff --git a/nashorn/test/script/nosecurity/jjs-option-fx.js.EXPECTED b/nashorn/test/script/nosecurity/jjs-option-fx.js.EXPECTED new file mode 100644 index 00000000000..92a9f2ad007 --- /dev/null +++ b/nashorn/test/script/nosecurity/jjs-option-fx.js.EXPECTED @@ -0,0 +1,4 @@ +-fx flag positive test: +flag test PASSED +-fx flag negative test: +flag test PASSED diff --git a/nashorn/test/script/nosecurity/jjs-option-lang.js b/nashorn/test/script/nosecurity/jjs-option-lang.js new file mode 100644 index 00000000000..f0ad0622d96 --- /dev/null +++ b/nashorn/test/script/nosecurity/jjs-option-lang.js @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2016, 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. + */ + +/** + * JDK-8144113: Nashorn: enable jjs testing. + * @test + * @option -scripting + * @runif os.not.windows + * @run + * @summary Test -lang flag and its basic functionality + */ + +load(__DIR__ + "jjs-common.js") + +// code to check -flag +var msg_flag = "print($OPTIONS._es6)" + +// code to check basic functionality +var msg_func = <