Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
343e1974
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
3
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
343e1974
编写于
2月 27, 2013
作者:
S
sundar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8009115: jtreg tests under jdk/test/javax/script should use nashorn as script engine
Reviewed-by: alanb
上级
a0a23261
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
73 addition
and
39 deletion
+73
-39
test/javax/script/CauseExceptionTest.java
test/javax/script/CauseExceptionTest.java
+3
-3
test/javax/script/ExceptionTest.java
test/javax/script/ExceptionTest.java
+2
-2
test/javax/script/GetInterfaceTest.java
test/javax/script/GetInterfaceTest.java
+3
-2
test/javax/script/Helper.java
test/javax/script/Helper.java
+2
-2
test/javax/script/StringWriterPrintTest.java
test/javax/script/StringWriterPrintTest.java
+2
-2
test/javax/script/Test3.js
test/javax/script/Test3.js
+5
-3
test/javax/script/Test5.java
test/javax/script/Test5.java
+14
-6
test/javax/script/Test5.js
test/javax/script/Test5.js
+4
-5
test/javax/script/Test6.java
test/javax/script/Test6.java
+16
-4
test/javax/script/Test7.js
test/javax/script/Test7.js
+6
-1
test/javax/script/UnescapedBracketRegExTest.java
test/javax/script/UnescapedBracketRegExTest.java
+3
-3
test/javax/script/VersionTest.java
test/javax/script/VersionTest.java
+13
-6
未找到文件。
test/javax/script/CauseExceptionTest.java
浏览文件 @
343e1974
...
...
@@ -24,7 +24,7 @@
/*
* @test
* @bug 6869617
* @summary
Rhino
ScriptEngine bug : ScriptException cause not set (with fix)
* @summary ScriptEngine bug : ScriptException cause not set (with fix)
*/
import
javax.script.*
;
...
...
@@ -33,12 +33,12 @@ import java.io.*;
public
class
CauseExceptionTest
{
public
static
void
main
(
String
[]
args
)
throws
ScriptException
,
NoSuchMethodException
{
ScriptEngineManager
sem
=
new
ScriptEngineManager
();
ScriptEngine
engine
=
sem
.
getEngineByName
(
"
js
"
);
ScriptEngine
engine
=
sem
.
getEngineByName
(
"
nashorn
"
);
if
(
engine
==
null
)
{
System
.
out
.
println
(
"Warning: No js engine found; test vacuously passes."
);
return
;
}
engine
.
eval
(
"function hello_world() { print
ln
('hello world'); throw 'out of here'; } "
);
engine
.
eval
(
"function hello_world() { print('hello world'); throw 'out of here'; } "
);
Invocable
invocable
=
(
Invocable
)
engine
;
try
{
invocable
.
invokeFunction
(
"hello_world"
,
(
Object
[])
null
);
...
...
test/javax/script/
Rhino
ExceptionTest.java
→
test/javax/script/ExceptionTest.java
浏览文件 @
343e1974
...
...
@@ -24,14 +24,14 @@
/*
* @test
* @bug 6474943 6705893
* @summary Test that
Rhino
exception messages are
* @summary Test that
script engine
exception messages are
* available from ScriptException.
*/
import
java.io.*
;
import
javax.script.*
;
public
class
Rhino
ExceptionTest
{
public
class
ExceptionTest
{
private
static
final
String
ERROR_MSG
=
"error from JavaScript"
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
...
...
test/javax/script/GetInterfaceTest.java
浏览文件 @
343e1974
...
...
@@ -22,6 +22,7 @@
*/
/*
* @run ignore
* @test
* @bug 6960211
* @summary JavaScript engine allows creation of interface although methods not available.
...
...
@@ -32,10 +33,10 @@ import javax.script.*;
public
class
GetInterfaceTest
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ScriptEngineManager
manager
=
new
ScriptEngineManager
();
ScriptEngine
engine
=
manager
.
getEngineByName
(
"
js
"
);
ScriptEngine
engine
=
manager
.
getEngineByName
(
"
nashorn
"
);
if
(
engine
==
null
)
{
System
.
out
.
println
(
"Warning: No engine engine found; test vacuously passes."
);
System
.
out
.
println
(
"Warning: No
js
engine engine found; test vacuously passes."
);
return
;
}
...
...
test/javax/script/Helper.java
浏览文件 @
343e1974
...
...
@@ -24,13 +24,13 @@ import javax.script.*;
/**
* Helper class to consolidate testing requirements for a js engine.
* A js engine is required as part of
Sun
's product JDK.
* A js engine is required as part of
Oracle
's product JDK.
*/
public
class
Helper
{
private
Helper
()
{};
// Don't instantiate
public
static
ScriptEngine
getJsEngine
(
ScriptEngineManager
m
)
{
ScriptEngine
e
=
m
.
getEngineByName
(
"
js
"
);
ScriptEngine
e
=
m
.
getEngineByName
(
"
nashorn
"
);
if
(
e
==
null
&&
System
.
getProperty
(
"java.runtime.name"
).
startsWith
(
"Java(TM)"
))
{
// A js engine is requied for Sun's product JDK
...
...
test/javax/script/StringWriterPrintTest.java
浏览文件 @
343e1974
...
...
@@ -33,9 +33,9 @@ import java.io.*;
public
class
StringWriterPrintTest
{
public
static
void
main
(
String
[]
args
)
throws
ScriptException
{
ScriptEngineManager
sem
=
new
ScriptEngineManager
();
ScriptEngine
engine
=
sem
.
getEngineByName
(
"
js
"
);
ScriptEngine
engine
=
sem
.
getEngineByName
(
"
nashorn
"
);
if
(
engine
==
null
)
{
System
.
out
.
println
(
"Warning: No
js
engine found; test vacuously passes."
);
System
.
out
.
println
(
"Warning: No
nashorn
engine found; test vacuously passes."
);
return
;
}
StringWriter
sw
=
new
StringWriter
();
...
...
test/javax/script/Test3.js
浏览文件 @
343e1974
var
ScriptContext
=
javax
.
script
.
ScriptContext
;
if
(
key
==
undefined
||
key
!=
'
engine value
'
)
{
throw
"
unexpected engine scope value
"
;
}
// pre-defined context variable refers to current ScriptContext
if
(
context
.
getAttribute
(
'
key
'
,
c
ontext
.
GLOBAL_SCOPE
)
!=
'
global value
'
)
{
if
(
context
.
getAttribute
(
'
key
'
,
ScriptC
ontext
.
GLOBAL_SCOPE
)
!=
'
global value
'
)
{
throw
"
unexpected global scope value
"
;
}
// change the engine scope value
key
=
'
new engine value
'
;
if
(
context
.
getAttribute
(
'
key
'
,
c
ontext
.
GLOBAL_SCOPE
)
!=
'
global value
'
)
{
if
(
context
.
getAttribute
(
'
key
'
,
ScriptC
ontext
.
GLOBAL_SCOPE
)
!=
'
global value
'
)
{
throw
"
global scope should not change here
"
;
}
// delete engine scope value
delete
key
;
if
(
key
==
undefined
&&
key
!=
'
x
global value
'
)
{
if
(
key
==
undefined
&&
key
!=
'
global value
'
)
{
throw
'
global scope should be visible after engine scope removal
'
;
}
test/javax/script/Test5.java
浏览文件 @
343e1974
...
...
@@ -48,16 +48,24 @@ public class Test5 {
System
.
out
.
println
(
"engine scope only"
);
e
.
put
(
"count"
,
new
Integer
(
1
));
Reader
reader
=
new
FileReader
(
new
File
(
System
.
getProperty
(
"test.src"
,
"."
),
"Test5.js"
));
engine
.
eval
(
reader
,
ctxt
);
try
(
Reader
reader
=
new
FileReader
(
new
File
(
System
.
getProperty
(
"test.src"
,
"."
),
"Test5.js"
)))
{
engine
.
eval
(
reader
,
ctxt
);
}
System
.
out
.
println
(
"both scopes"
);
ctxt
.
setBindings
(
g
,
ScriptContext
.
GLOBAL_SCOPE
);
e
.
put
(
"count"
,
new
Integer
(
2
));
engine
.
eval
(
reader
,
ctxt
);
try
(
Reader
reader
=
new
FileReader
(
new
File
(
System
.
getProperty
(
"test.src"
,
"."
),
"Test5.js"
)))
{
engine
.
eval
(
reader
,
ctxt
);
}
System
.
out
.
println
(
"only global"
);
e
.
put
(
"count"
,
new
Integer
(
3
));
ctxt
.
setAttribute
(
"key"
,
null
,
ScriptContext
.
ENGINE_SCOPE
);
engine
.
eval
(
reader
,
ctxt
);
ctxt
.
removeAttribute
(
"key"
,
ScriptContext
.
ENGINE_SCOPE
);
try
(
Reader
reader
=
new
FileReader
(
new
File
(
System
.
getProperty
(
"test.src"
,
"."
),
"Test5.js"
)))
{
engine
.
eval
(
reader
,
ctxt
);
}
}
}
test/javax/script/Test5.js
浏览文件 @
343e1974
var
key
;
var
count
;
var
ScriptContext
=
javax
.
script
.
ScriptContext
;
print
(
count
);
switch
(
count
)
{
...
...
@@ -9,7 +8,7 @@ switch (count) {
if
(
key
!=
'
value in engine
'
)
{
throw
"
unexpected engine scope value
"
;
}
if
(
context
.
getAttribute
(
"
key
"
,
c
ontext
.
GLOBAL_SCOPE
)
!=
null
)
{
if
(
context
.
getAttribute
(
"
key
"
,
ScriptC
ontext
.
GLOBAL_SCOPE
)
!=
null
)
{
throw
"
unexpected global scope value
"
;
}
break
;
...
...
@@ -19,7 +18,7 @@ switch (count) {
if
(
key
!=
'
value in engine
'
)
{
throw
"
unexpected engine scope value
"
;
}
if
(
context
.
getAttribute
(
"
key
"
,
c
ontext
.
GLOBAL_SCOPE
)
!=
if
(
context
.
getAttribute
(
"
key
"
,
ScriptC
ontext
.
GLOBAL_SCOPE
)
!=
"
value in global
"
)
{
throw
"
unexpected global scope value
"
;
}
...
...
@@ -30,7 +29,7 @@ switch (count) {
if
(
key
!=
'
value in global
'
)
{
throw
"
unexpected global scope value
"
;
}
if
(
context
.
getAttribute
(
"
key
"
,
c
ontext
.
GLOBAL_SCOPE
)
!=
if
(
context
.
getAttribute
(
"
key
"
,
ScriptC
ontext
.
GLOBAL_SCOPE
)
!=
"
value in global
"
)
{
throw
"
unexpected global scope value
"
;
}
...
...
test/javax/script/Test6.java
浏览文件 @
343e1974
...
...
@@ -40,11 +40,23 @@ public class Test6 {
System
.
out
.
println
(
"Warning: No js engine found; test vacuously passes."
);
return
;
}
Reader
reader
=
new
FileReader
(
new
File
(
System
.
getProperty
(
"test.src"
,
"."
),
"Test6.js"
));
engine
.
eval
(
reader
);
try
(
Reader
reader
=
new
FileReader
(
new
File
(
System
.
getProperty
(
"test.src"
,
"."
),
"Test6.js"
)))
{
engine
.
eval
(
reader
);
}
Object
res
=
engine
.
get
(
"res"
);
CompiledScript
scr
=
((
Compilable
)
engine
).
compile
(
reader
);
CompiledScript
scr
=
null
;
try
(
Reader
reader
=
new
FileReader
(
new
File
(
System
.
getProperty
(
"test.src"
,
"."
),
"Test6.js"
)))
{
scr
=
((
Compilable
)
engine
).
compile
(
reader
);
}
if
(
scr
==
null
)
{
throw
new
RuntimeException
(
"compilation failed!"
);
}
scr
.
eval
();
Object
res1
=
engine
.
get
(
"res"
);
if
(!
res
.
equals
(
res1
))
{
...
...
test/javax/script/Test7.js
浏览文件 @
343e1974
//this is the first line of Test7.js
var
filename
;
try
{
load
(
"
nashorn:mozilla_compat.js
"
);
}
catch
(
e
)
{
//ignored
}
importPackage
(
java
.
io
);
importPackage
(
java
);
var
f
=
new
File
(
filename
);
var
r
=
new
BufferedReader
(
new
InputStreamReader
(
new
FileInputStream
(
f
)));
var
firstLine
=
r
.
readLine
()
+
''
;
var
firstLine
=
r
.
readLine
();
print
(
firstLine
);
test/javax/script/UnescapedBracketRegExTest.java
浏览文件 @
343e1974
...
...
@@ -24,7 +24,7 @@
/*
* @test
* @bug 7012701
* @summary 7012701 Add a test to check that R
hino's R
egExp parser accepts unescaped '['
* @summary 7012701 Add a test to check that RegExp parser accepts unescaped '['
*/
import
javax.script.*
;
...
...
@@ -33,9 +33,9 @@ import java.io.*;
public
class
UnescapedBracketRegExTest
{
public
static
void
main
(
String
[]
args
)
throws
ScriptException
{
ScriptEngineManager
sem
=
new
ScriptEngineManager
();
ScriptEngine
engine
=
sem
.
getEngineByName
(
"
js
"
);
ScriptEngine
engine
=
sem
.
getEngineByName
(
"
nashorn
"
);
if
(
engine
==
null
)
{
System
.
out
.
println
(
"Warning: No
js
engine found; test vacuously passes."
);
System
.
out
.
println
(
"Warning: No
nashorn
engine found; test vacuously passes."
);
return
;
}
// the following throws exception
...
...
test/javax/script/VersionTest.java
浏览文件 @
343e1974
...
...
@@ -31,9 +31,7 @@ import javax.script.*;
import
java.io.*
;
public
class
VersionTest
{
private
static
final
String
JS_LANG_VERSION
=
"1.8"
;
private
static
final
String
JS_ENGINE_VERSION
=
"1.7 release 3 PRERELEASE"
;
private
static
final
String
JS_LANG_VERSION
=
"ECMA - 262 Edition 5.1"
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ScriptEngineManager
manager
=
new
ScriptEngineManager
();
...
...
@@ -48,9 +46,18 @@ public class VersionTest {
JS_LANG_VERSION
);
}
String
engineVersion
=
jsengine
.
getFactory
().
getEngineVersion
();
if
(!
engineVersion
.
equals
(
JS_ENGINE_VERSION
))
{
throw
new
RuntimeException
(
"Expected Rhino version is "
+
JS_ENGINE_VERSION
);
String
expectedVersion
=
getNashornVersion
();
if
(!
engineVersion
.
equals
(
expectedVersion
))
{
throw
new
RuntimeException
(
"Expected version is "
+
expectedVersion
);
}
}
private
static
String
getNashornVersion
()
{
try
{
Class
versionClass
=
Class
.
forName
(
"jdk.nashorn.internal.runtime.Version"
);
return
(
String
)
versionClass
.
getMethod
(
"version"
).
invoke
(
null
);
}
catch
(
Exception
e
)
{
return
"Version Unknown!"
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录