mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -1,39 +0,0 @@
|
||||
package org.dromara.hutool.extra.script;
|
||||
|
||||
import org.dromara.hutool.core.exceptions.UtilException;
|
||||
import org.dromara.hutool.core.io.resource.ResourceUtil;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import javax.script.CompiledScript;
|
||||
import javax.script.ScriptException;
|
||||
|
||||
/**
|
||||
* 脚本单元测试类
|
||||
*
|
||||
* @author looly
|
||||
*
|
||||
*/
|
||||
public class ScriptUtilTest {
|
||||
|
||||
@Test
|
||||
public void compileTest() {
|
||||
final CompiledScript script = ScriptUtil.compile("print('Script test!');");
|
||||
try {
|
||||
script.eval();
|
||||
} catch (final ScriptException e) {
|
||||
throw new UtilException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void evalTest() {
|
||||
ScriptUtil.eval("print('Script test!');");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invokeTest() {
|
||||
final Object result = ScriptUtil.invoke(ResourceUtil.readUtf8Str("filter1.js"), "filter1", 2, 1);
|
||||
Assertions.assertTrue((Boolean) result);
|
||||
}
|
||||
}
|
@@ -1,6 +0,0 @@
|
||||
function filter1(a, b) {
|
||||
if (a > b) {
|
||||
return a > b;
|
||||
}
|
||||
return false;
|
||||
}
|
Reference in New Issue
Block a user