提交 ce2d77f5 编写于 作者: S sundar

8009140: jtreg tests under sun/tools/jrunscript should use nashorn engine

Reviewed-by: alanb
上级 66b7140e
......@@ -33,7 +33,7 @@ public class CheckEngine {
public static void main(String... args) {
int exitCode = 0;
ScriptEngine engine =
(new ScriptEngineManager()).getEngineByName("js");
(new ScriptEngineManager()).getEngineByName("nashorn");
if (engine == null &&
!(System.getProperty("java.runtime.name").startsWith("Java(TM)"))) {
......
......@@ -43,7 +43,7 @@ fi
# to script as java.lang.System property. sysProps is
# jrunscript shell built-in variable for System properties.
${JRUNSCRIPT} -Djrunscript.foo=bar <<EOF
${JRUNSCRIPT} -l nashorn -Djrunscript.foo=bar <<EOF
if (sysProps["jrunscript.foo"] == "bar") { println("Passed"); exit(0); }
// unexpected value
println("Unexpected System property value");
......
......@@ -41,7 +41,7 @@ fi
# we check whether "excess" args are passed as script arguments
${JRUNSCRIPT} -J-Djava.awt.headless=true -f - hello world <<EOF
${JRUNSCRIPT} -l nashorn -J-Djava.awt.headless=true -f - hello world <<EOF
if (typeof(arguments) == 'undefined') { println("arguments expected"); exit(1); }
......
......@@ -46,7 +46,7 @@ ${JAVAC} ${TESTSRC}/Hello.java -d .
# work with jrunscript. Script should be able to
# access Java class "Hello".
${JRUNSCRIPT} -cp . <<EOF
${JRUNSCRIPT} -l nashorn -cp . <<EOF
var v;
try { v = new Packages.Hello(); } catch (e) { println(e); exit(1) }
if (v.string != 'hello') { println("Unexpected property value"); exit(1); }
......@@ -58,7 +58,7 @@ fi
# -classpath and -cp are synonyms
${JRUNSCRIPT} -classpath . <<EOF
${JRUNSCRIPT} -l nashorn -classpath . <<EOF
var v;
try { v = new Packages.Hello(); } catch (e) { println(e); exit(1) }
if (v.string != 'hello') { println("unexpected property value"); exit(1); }
......
......@@ -39,21 +39,10 @@ if [ $? -eq 2 ]; then
exit 0
fi
rm -f jrunscript-eTest.out 2>/dev/null
${JRUNSCRIPT} -J-Djava.awt.headless=true -e "println('hello')" > jrunscript-eTest.out 2>&1
$golden_diff jrunscript-eTest.out ${TESTSRC}/dash-e.out
if [ $? != 0 ]
then
echo "Output of jrunscript -e differ from expected output. Failed."
rm -f jrunscript-eTest.out 2>/dev/null
exit 1
fi
# -e option with JavaScript explicitly choosen as language
rm -f jrunscript-eTest.out 2>/dev/null
${JRUNSCRIPT} -J-Djava.awt.headless=true -l js -e "println('hello')" > jrunscript-eTest.out 2>&1
${JRUNSCRIPT} -J-Djava.awt.headless=true -l nashorn -e "println('hello')" > jrunscript-eTest.out 2>&1
$golden_diff jrunscript-eTest.out ${TESTSRC}/dash-e.out
if [ $? != 0 ]
......
......@@ -39,22 +39,11 @@ if [ $? -eq 2 ]; then
exit 0
fi
rm -f jrunscript-fTest.out 2>/dev/null
${JRUNSCRIPT} -J-Djava.awt.headless=true -f ${TESTSRC}/hello.js > jrunscript-fTest.out 2>&1
$golden_diff jrunscript-fTest.out ${TESTSRC}/dash-f.out
if [ $? != 0 ]
then
echo "Output of jrunscript -f differ from expected output. Failed."
rm -f jrunscript-fTest.out 2>/dev/null
exit 1
fi
# -f option used with JavaScript as language chosen explicitly
# with -l option
rm -f jrunscript-fTest.out 2>/dev/null
${JRUNSCRIPT} -J-Djava.awt.headless=true -l js -f ${TESTSRC}/hello.js > jrunscript-fTest.out 2>&1
${JRUNSCRIPT} -J-Djava.awt.headless=true -l nashorn -f ${TESTSRC}/hello.js > jrunscript-fTest.out 2>&1
$golden_diff jrunscript-fTest.out ${TESTSRC}/dash-f.out
if [ $? != 0 ]
......
......@@ -40,7 +40,7 @@ if [ $? -eq 2 ]; then
fi
rm -f jrunscriptTest.out 2>/dev/null
${JRUNSCRIPT} -J-Djava.awt.headless=true > jrunscriptTest.out 2>&1 <<EOF
${JRUNSCRIPT} -J-Djava.awt.headless=true -l nashorn > jrunscriptTest.out 2>&1 <<EOF
v = 2 + 5;
v *= 5;
v = v + " is the value";
......@@ -52,25 +52,7 @@ EOF
$golden_diff jrunscriptTest.out ${TESTSRC}/repl.out
if [ $? != 0 ]
then
echo "Output of jrunscript session differ from expected output. Failed."
rm -f jrunscriptTest.out 2>/dev/null
exit 1
fi
rm -f jrunscriptTest.out 2>/dev/null
${JRUNSCRIPT} -J-Djava.awt.headless=true -l js > jrunscriptTest.out 2>&1 <<EOF
v = 2 + 5;
v *= 5;
v = v + " is the value";
if (v != 0) { println('yes v != 0'); }
java.lang.System.out.println('hello world from script');
new java.lang.Runnable() { run: function() { println('I am runnable'); }}.run();
EOF
$golden_diff jrunscriptTest.out ${TESTSRC}/repl.out
if [ $? != 0 ]
then
echo "Output of jrunscript -l js differ from expected output. Failed."
echo "Output of jrunscript -l nashorn differ from expected output. Failed."
rm -f jrunscriptTest.out 2>/dev/null
exit 1
fi
......
js> 7.0
js> 35.0
js> 35 is the value
js> yes v != 0
js> hello world from script
js> I am runnable
js>
\ No newline at end of file
nashorn> 7
nashorn> 35.0
nashorn> 35 is the value
nashorn> yes v != 0
nashorn> hello world from script
nashorn> I am runnable
nashorn>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册