forked from JavaTX/JavaCompilerCore
87 lines
2.1 KiB
Java
87 lines
2.1 KiB
Java
package bytecode.operators;
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
import java.lang.reflect.Method;
|
|
import org.junit.Test;
|
|
import bytecode.SourceFileBytecodeTest;
|
|
|
|
public abstract class RelOperatorTest extends SourceFileBytecodeTest{
|
|
@Test
|
|
public void testConstruct() throws Exception{
|
|
ClassLoader classLoader = getClassLoader();
|
|
|
|
Class cls = classLoader.loadClass(testName);
|
|
|
|
Object obj = cls.newInstance();
|
|
assertTrue(true);
|
|
}
|
|
|
|
@Test
|
|
public void test1x2() throws Exception{
|
|
ClassLoader classLoader = getClassLoader();
|
|
|
|
Class cls = classLoader.loadClass(testName);
|
|
|
|
Object obj = cls.newInstance();
|
|
|
|
Integer x = new Integer(1);
|
|
Integer y = new Integer(2);
|
|
|
|
Class[] params = new Class[]{
|
|
x.getClass(),
|
|
y.getClass(),
|
|
};
|
|
|
|
Method method = cls.getDeclaredMethod("method", params);
|
|
Boolean returnValue = (Boolean) method.invoke(obj, x, y);
|
|
assertEquals(getTest1x2ReturnValue(), returnValue);
|
|
}
|
|
|
|
@Test
|
|
public void test2x2() throws Exception{
|
|
ClassLoader classLoader = getClassLoader();
|
|
|
|
Class cls = classLoader.loadClass(testName);
|
|
|
|
Object obj = cls.newInstance();
|
|
|
|
Integer x = new Integer(2);
|
|
Integer y = new Integer(2);
|
|
|
|
Class[] params = new Class[]{
|
|
x.getClass(),
|
|
y.getClass(),
|
|
};
|
|
|
|
Method method = cls.getDeclaredMethod("method", params);
|
|
Boolean returnValue = (Boolean) method.invoke(obj, x, y);
|
|
assertEquals(getTest2x2ReturnValue(), returnValue);
|
|
}
|
|
|
|
@Test
|
|
public void test2x1() throws Exception{
|
|
ClassLoader classLoader = getClassLoader();
|
|
|
|
Class cls = classLoader.loadClass(testName);
|
|
|
|
Object obj = cls.newInstance();
|
|
|
|
Integer x = new Integer(2);
|
|
Integer y = new Integer(2);
|
|
|
|
Class[] params = new Class[]{
|
|
x.getClass(),
|
|
y.getClass(),
|
|
};
|
|
|
|
Method method = cls.getDeclaredMethod("method", params);
|
|
Boolean returnValue = (Boolean) method.invoke(obj, x, y);
|
|
assertEquals(getTest2x1ReturnValue(), returnValue);
|
|
}
|
|
|
|
protected abstract Boolean getTest1x2ReturnValue();
|
|
protected abstract Boolean getTest2x2ReturnValue();
|
|
protected abstract Boolean getTest2x1ReturnValue();
|
|
}
|