forked from JavaTX/JavaCompilerCore
- Tests für Vergleichsoperatoren angelegt
This commit is contained in:
parent
b3e13d09b9
commit
bbb79b1a1d
@ -2,31 +2,29 @@ package bytecode.operators;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import bytecode.SourceFileBytecodeTest;
|
||||
|
||||
public class EqualOperatorTest extends SourceFileBytecodeTest{
|
||||
public class EqualOperatorTest extends RelOperatorTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "EqualOperator";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/operators/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstruct() throws Exception{
|
||||
ClassLoader classLoader = getClassLoader();
|
||||
@Override
|
||||
protected Boolean getTest1x2ReturnValue() {
|
||||
return new Boolean(false);
|
||||
}
|
||||
|
||||
Class cls = classLoader.loadClass(testName);
|
||||
@Override
|
||||
protected Boolean getTest2x2ReturnValue() {
|
||||
return new Boolean(true);
|
||||
}
|
||||
|
||||
Object obj = cls.newInstance();
|
||||
assertTrue(true);
|
||||
@Override
|
||||
protected Boolean getTest2x1ReturnValue() {
|
||||
return new Boolean(false);
|
||||
}
|
||||
}
|
||||
|
5
test/bytecode/operators/GreaterEqualOperator.jav
Normal file
5
test/bytecode/operators/GreaterEqualOperator.jav
Normal file
@ -0,0 +1,5 @@
|
||||
class GreaterEqualOperator{
|
||||
Boolean method(Integer x, Integer y){
|
||||
return x >= y;
|
||||
}
|
||||
}
|
30
test/bytecode/operators/GreaterEqualOperatorTest.java
Normal file
30
test/bytecode/operators/GreaterEqualOperatorTest.java
Normal file
@ -0,0 +1,30 @@
|
||||
package bytecode.operators;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import org.junit.Test;
|
||||
import bytecode.SourceFileBytecodeTest;
|
||||
|
||||
public class GreaterEqualOperatorTest extends RelOperatorTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "GreaterEqualOperator";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/operators/";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean getTest1x2ReturnValue() {
|
||||
return new Boolean(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean getTest2x2ReturnValue() {
|
||||
return new Boolean(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean getTest2x1ReturnValue() {
|
||||
return new Boolean(true);
|
||||
}
|
||||
}
|
5
test/bytecode/operators/GreaterOperator.jav
Normal file
5
test/bytecode/operators/GreaterOperator.jav
Normal file
@ -0,0 +1,5 @@
|
||||
class GreaterOperator{
|
||||
Boolean method(Integer x, Integer y){
|
||||
return x > y;
|
||||
}
|
||||
}
|
30
test/bytecode/operators/GreaterOperatorTest.java
Normal file
30
test/bytecode/operators/GreaterOperatorTest.java
Normal file
@ -0,0 +1,30 @@
|
||||
package bytecode.operators;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import org.junit.Test;
|
||||
import bytecode.SourceFileBytecodeTest;
|
||||
|
||||
public class GreaterOperatorTest extends RelOperatorTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "GreaterOperator";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/operators/";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean getTest1x2ReturnValue() {
|
||||
return new Boolean(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean getTest2x2ReturnValue() {
|
||||
return new Boolean(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean getTest2x1ReturnValue() {
|
||||
return new Boolean(true);
|
||||
}
|
||||
}
|
5
test/bytecode/operators/ModuloOperator.jav
Normal file
5
test/bytecode/operators/ModuloOperator.jav
Normal file
@ -0,0 +1,5 @@
|
||||
class ModuloOperator{
|
||||
Integer method(Integer x, Integer y){
|
||||
return x % y;
|
||||
}
|
||||
}
|
53
test/bytecode/operators/ModuloOperatorTest.java
Normal file
53
test/bytecode/operators/ModuloOperatorTest.java
Normal file
@ -0,0 +1,53 @@
|
||||
package bytecode.operators;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import bytecode.SourceFileBytecodeTest;
|
||||
|
||||
public class ModuloOperatorTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "ModuloOperator";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/operators/";
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConstruct() throws Exception{
|
||||
ClassLoader classLoader = getClassLoader();
|
||||
|
||||
Class cls = classLoader.loadClass(testName);
|
||||
|
||||
Object obj = cls.newInstance();
|
||||
assertTrue(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTwoIntegers() 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);
|
||||
Integer returnValue = (Integer) method.invoke(obj, x, y);
|
||||
assertEquals(new Integer(1), returnValue);
|
||||
}
|
||||
}
|
5
test/bytecode/operators/NotEqualOperator.jav
Normal file
5
test/bytecode/operators/NotEqualOperator.jav
Normal file
@ -0,0 +1,5 @@
|
||||
class NotEqualOperator{
|
||||
Boolean method(Integer x, Integer y){
|
||||
return x != y;
|
||||
}
|
||||
}
|
30
test/bytecode/operators/NotEqualOperatorTest.java
Normal file
30
test/bytecode/operators/NotEqualOperatorTest.java
Normal file
@ -0,0 +1,30 @@
|
||||
package bytecode.operators;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import org.junit.Test;
|
||||
import bytecode.SourceFileBytecodeTest;
|
||||
|
||||
public class NotEqualOperatorTest extends RelOperatorTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "NotEqualOperator";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/operators/";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean getTest1x2ReturnValue() {
|
||||
return new Boolean(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean getTest2x2ReturnValue() {
|
||||
return new Boolean(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean getTest2x1ReturnValue() {
|
||||
return new Boolean(true);
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ import org.junit.Test;
|
||||
|
||||
import bytecode.SourceFileBytecodeTest;
|
||||
|
||||
public class OROperatorTest extends SourceFileBytecodeTest{
|
||||
public class OrOperatorTest extends SourceFileBytecodeTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "OrOperator";
|
86
test/bytecode/operators/RelOperatorTest.java
Normal file
86
test/bytecode/operators/RelOperatorTest.java
Normal file
@ -0,0 +1,86 @@
|
||||
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();
|
||||
}
|
5
test/bytecode/operators/SmallerEqualOperator.jav
Normal file
5
test/bytecode/operators/SmallerEqualOperator.jav
Normal file
@ -0,0 +1,5 @@
|
||||
class SmallerEqualOperator{
|
||||
Boolean method(Integer x, Integer y){
|
||||
return x <= y;
|
||||
}
|
||||
}
|
30
test/bytecode/operators/SmallerEqualOperatorTest.java
Normal file
30
test/bytecode/operators/SmallerEqualOperatorTest.java
Normal file
@ -0,0 +1,30 @@
|
||||
package bytecode.operators;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import org.junit.Test;
|
||||
import bytecode.SourceFileBytecodeTest;
|
||||
|
||||
public class SmallerEqualOperatorTest extends RelOperatorTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "SmallerEqual";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/operators/";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean getTest1x2ReturnValue() {
|
||||
return new Boolean(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean getTest2x2ReturnValue() {
|
||||
return new Boolean(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean getTest2x1ReturnValue() {
|
||||
return new Boolean(false);
|
||||
}
|
||||
}
|
5
test/bytecode/operators/SmallerOperator.jav
Normal file
5
test/bytecode/operators/SmallerOperator.jav
Normal file
@ -0,0 +1,5 @@
|
||||
class SmallerOperator{
|
||||
Boolean method(Integer x, Integer y){
|
||||
return x < y;
|
||||
}
|
||||
}
|
30
test/bytecode/operators/SmallerOperatorTest.java
Normal file
30
test/bytecode/operators/SmallerOperatorTest.java
Normal file
@ -0,0 +1,30 @@
|
||||
package bytecode.operators;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import org.junit.Test;
|
||||
import bytecode.SourceFileBytecodeTest;
|
||||
|
||||
public class SmallerOperatorTest extends RelOperatorTest{
|
||||
@Override
|
||||
protected void init() {
|
||||
testName = "Smaller";
|
||||
rootDirectory = System.getProperty("user.dir")+"/test/bytecode/operators/";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean getTest1x2ReturnValue() {
|
||||
return new Boolean(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean getTest2x2ReturnValue() {
|
||||
return new Boolean(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean getTest2x1ReturnValue() {
|
||||
return new Boolean(false);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user