evaltest.java
来自「Groovy动态语言 运行在JVM中的动态语言 可以方便的处理业务逻辑变化大的业」· Java 代码 · 共 39 行
JAVA
39 行
package groovy.util;
import junit.framework.TestCase;
import org.codehaus.groovy.control.CompilationFailedException;
/**
* Testing the simple Groovy integration with Eval.
*
* @author Dierk Koenig
*/
public class EvalTest extends TestCase {
public void testMeSimple() throws CompilationFailedException {
Object result = Eval.me("10");
assertEquals("10", result.toString());
}
public void testMeWithSymbolAndObject() throws CompilationFailedException {
Object result = Eval.me("x", new Integer(10), "x");
assertEquals("10", result.toString());
}
public void testX() throws CompilationFailedException {
Object result = Eval.x(new Integer(10), "x");
assertEquals("10", result.toString());
}
public void testXY() throws CompilationFailedException {
Integer ten = new Integer(10);
Object result = Eval.xy(ten,ten, "x+y");
assertEquals("20", result.toString());
}
public void testXYZ() throws CompilationFailedException {
Integer ten = new Integer(10);
Object result = Eval.xyz(ten,ten,ten, "x+y+z");
assertEquals("30", result.toString());
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?