forked from JavaTX/JavaCompilerCore
Merge branch 'bytecode2' into plugin
Conflicts: pom.xml src/main/java/de/dhbwstuttgart/bytecode/BytecodeGen.java src/main/java/de/dhbwstuttgart/bytecode/BytecodeGenMethod.java src/main/java/de/dhbwstuttgart/bytecode/descriptor/DescriptorToString.java src/main/java/de/dhbwstuttgart/bytecode/signature/Signature.java src/main/java/de/dhbwstuttgart/bytecode/utilities/Simplify.java src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java src/main/java/de/dhbwstuttgart/typeinference/unify/RuleSet.java src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnify.java src/main/java/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java src/main/java/de/dhbwstuttgart/typeinference/unify/model/FiniteClosure.java src/main/java/de/dhbwstuttgart/typeinference/unify/model/OrderingUnifyPair.java src/main/java/de/dhbwstuttgart/typeinference/unify/model/PlaceholderType.java src/test/java/asp/ClingoTest.java src/test/java/asp/gencay/GeneratorTest.java src/test/java/bytecode/BinaryTest.java src/test/java/bytecode/FacTest.java src/test/java/bytecode/FacultyTest.java src/test/java/bytecode/FieldTest.java src/test/java/bytecode/FunOLTest.java src/test/java/bytecode/GenTest.java src/test/java/bytecode/GreaterEqualTest.java src/test/java/bytecode/GreaterThanTest.java src/test/java/bytecode/LambdaTest.java src/test/java/bytecode/LambdaVoidTest.java src/test/java/bytecode/LessEqualTest.java src/test/java/bytecode/LessThanTest.java src/test/java/bytecode/MatrixOpTest.java src/test/java/bytecode/MatrixTest.java src/test/java/bytecode/MergeTest.java src/test/java/bytecode/OLTest.java src/test/java/bytecode/OpTest.java src/test/java/bytecode/OverloadingSortingTest.java src/test/java/bytecode/OverloadingTest.java src/test/java/bytecode/PlusTest.java src/test/java/bytecode/PostIncTest.java src/test/java/bytecode/PreIncTest.java src/test/java/bytecode/RelOpsTest.java src/test/java/bytecode/SortingTest.java src/test/java/bytecode/SubMatTest.java src/test/java/bytecode/Tph2Test.java src/test/java/bytecode/Tph3Test.java src/test/java/bytecode/Tph5Test.java src/test/java/bytecode/TphTest.java src/test/java/bytecode/WhileTest.java src/test/java/bytecode/YTest.java src/test/java/bytecode/applyLambdaTest.java src/test/java/parser/GeneralParserTest.java src/test/java/typeinference/UnifyTest.java
This commit is contained in:
commit
d9cda2779f
23
pom.xml
23
pom.xml
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||||
@ -54,8 +55,6 @@
|
|||||||
<outputDirectory>target/classes</outputDirectory>
|
<outputDirectory>target/classes</outputDirectory>
|
||||||
<finalName>${project.artifactId}-${project.version}</finalName>
|
<finalName>${project.artifactId}-${project.version}</finalName>
|
||||||
<testOutputDirectory>target/test-classes</testOutputDirectory>
|
<testOutputDirectory>target/test-classes</testOutputDirectory>
|
||||||
<sourceDirectory>src/</sourceDirectory>
|
|
||||||
<testSourceDirectory>test/</testSourceDirectory>
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.antlr</groupId>
|
<groupId>org.antlr</groupId>
|
||||||
@ -68,8 +67,8 @@
|
|||||||
<goal>antlr4</goal>
|
<goal>antlr4</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<sourceDirectory>src/de/dhbwstuttgart/parser/antlr/</sourceDirectory>
|
<sourceDirectory>src/main/antlr4/java8</sourceDirectory>
|
||||||
<outputDirectory>src/de/dhbwstuttgart/parser/antlr/</outputDirectory>
|
<outputDirectory>${project.basedir}/target/generated-sources/antlr4/de/dhbwstuttgart/parser/antlr</outputDirectory>
|
||||||
<arguments>
|
<arguments>
|
||||||
<argument>-package</argument>
|
<argument>-package</argument>
|
||||||
<argument>de.dhbwstuttgart.parser.antlr</argument>
|
<argument>de.dhbwstuttgart.parser.antlr</argument>
|
||||||
@ -82,8 +81,8 @@
|
|||||||
<goal>antlr4</goal>
|
<goal>antlr4</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<sourceDirectory>src/de/dhbwstuttgart/sat/asp/parser/antlr/</sourceDirectory>
|
<sourceDirectory>src/main/antlr4/sat</sourceDirectory>
|
||||||
<outputDirectory>src/de/dhbwstuttgart/sat/asp/parser/antlr/</outputDirectory>
|
<outputDirectory>${project.basedir}/target/generated-sources/antlr4/de/dhbwstuttgart/sat/asp/parser/antlr</outputDirectory>
|
||||||
<arguments>
|
<arguments>
|
||||||
<argument>-package</argument>
|
<argument>-package</argument>
|
||||||
<argument>de.dhbwstuttgart.sat.asp.parser.antlr</argument>
|
<argument>de.dhbwstuttgart.sat.asp.parser.antlr</argument>
|
||||||
@ -140,7 +139,7 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<!-- plugin>
|
||||||
<groupId>org.eclipse.tycho</groupId>
|
<groupId>org.eclipse.tycho</groupId>
|
||||||
<artifactId>tycho-p2-repository-plugin</artifactId>
|
<artifactId>tycho-p2-repository-plugin</artifactId>
|
||||||
<version>${tycho.version}</version>
|
<version>${tycho.version}</version>
|
||||||
@ -152,15 +151,7 @@
|
|||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin -->
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<source>9</source>
|
|
||||||
<target>9</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<pluginRepositories>
|
<pluginRepositories>
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# A basic script to compile the necessary packages and their subpackages to work with the parser.
|
|
||||||
# Messages are logged to stderr.
|
|
||||||
>&2 echo "Building de.dhbwstuttgart.typecheck..."
|
|
||||||
javac -d ../bin ./de/dhbwstuttgart/typecheck/*.java
|
|
||||||
>&2 echo "Building de.dhbwstuttgart.syntaxtree..."
|
|
||||||
javac -d ../bin ./de/dhbwstuttgart/syntaxtree/*.java
|
|
||||||
>&2 echo "Building de.dhbwstuttgart.syntaxtree.factory..."
|
|
||||||
javac -d ../bin ./de/dhbwstuttgart/syntaxtree/factory/*.java
|
|
||||||
>&2 echo "Building de.dhbwstuttgart.syntaxtree.operator..."
|
|
||||||
javac -d ../bin ./de/dhbwstuttgart/syntaxtree/operator/*.java
|
|
||||||
>&2 echo "Building de.dhbwstuttgart.syntaxtree.statement..."
|
|
||||||
javac -d ../bin ./de/dhbwstuttgart/syntaxtree/statement/*.java
|
|
||||||
>&2 echo "Building de.dhbwstuttgart.syntaxtree.statement.literal..."
|
|
||||||
javac -d ../bin ./de/dhbwstuttgart/syntaxtree/statement/literal/*.java
|
|
||||||
>&2 echo "Building de.dhbwstuttgart.syntaxtree.type..."
|
|
||||||
javac -d ../bin ./de/dhbwstuttgart/syntaxtree/type/*.java
|
|
||||||
>&2 echo "Building de.dhbwstuttgart.parser..."
|
|
||||||
javac -d ../bin ./de/dhbwstuttgart/parser/*.java
|
|
||||||
>&2 echo "Building de.dhbwstuttgart.parser.SyntaxTreeGenerator..."
|
|
||||||
javac -d ../bin ./de/dhbwstuttgart/parser/SyntaxTreeGenerator/*.java
|
|
||||||
>&2 echo "Building de.dhbwstuttgart.parser.antlr..."
|
|
||||||
javac -d ../bin ./de/dhbwstuttgart/parser/antlr/*.java
|
|
||||||
echo "Done. Now its your turn to debug:)."
|
|
@ -6,6 +6,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
import de.dhbwstuttgart.exceptions.NotImplementedException;
|
||||||
@ -62,6 +63,8 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
|
|
||||||
private String superClass;
|
private String superClass;
|
||||||
|
|
||||||
|
private ArrayList<TypePlaceholder> tphsClass;
|
||||||
|
|
||||||
// stores parameter, local vars and the next index on the local variable table, which use for aload_i, astore_i,...
|
// stores parameter, local vars and the next index on the local variable table, which use for aload_i, astore_i,...
|
||||||
HashMap<String, Integer> paramsAndLocals = new HashMap<>();
|
HashMap<String, Integer> paramsAndLocals = new HashMap<>();
|
||||||
// stores generics and their bounds of class
|
// stores generics and their bounds of class
|
||||||
@ -131,20 +134,44 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
superClass = classOrInterface.getSuperClass().acceptTV(new TypeToDescriptor());
|
superClass = classOrInterface.getSuperClass().acceptTV(new TypeToDescriptor());
|
||||||
resultSet = rs;
|
resultSet = rs;
|
||||||
tphExtractor.setResultSet(resultSet);
|
tphExtractor.setResultSet(resultSet);
|
||||||
|
|
||||||
// Nur einmal ausführen!!
|
// Nur einmal ausführen!!
|
||||||
if(!isVisited) {
|
if(!isVisited) {
|
||||||
classOrInterface.accept(tphExtractor);
|
classOrInterface.accept(tphExtractor);
|
||||||
|
|
||||||
getCommonTPHS(tphExtractor);
|
getCommonTPHS(tphExtractor);
|
||||||
|
|
||||||
|
tphsClass = new ArrayList<>();
|
||||||
|
for(TypePlaceholder t : tphExtractor.allTPHS.keySet()) {
|
||||||
|
if(!tphExtractor.allTPHS.get(t))
|
||||||
|
tphsClass.add(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<TPHConstraint> consClass = new ArrayList<>();
|
||||||
|
for(TPHConstraint cons : tphExtractor.allCons) {
|
||||||
|
TypePlaceholder right = null;
|
||||||
|
for(TypePlaceholder tph : tphsClass) {
|
||||||
|
if(cons.getLeft().equals(tph.getName())) {
|
||||||
|
|
||||||
|
consClass.add(cons);
|
||||||
|
right = getTPH(cons.getRight());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(right != null) {
|
||||||
|
tphsClass.add(right);
|
||||||
|
removeFromMethod(right.getName());
|
||||||
|
right = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
String sig = null;
|
String sig = null;
|
||||||
/* if class has generics then creates signature
|
/* if class has generics then creates signature
|
||||||
* Signature looks like:
|
* Signature looks like:
|
||||||
* <E:Ljava/...>Superclass
|
* <E:Ljava/...>Superclass
|
||||||
*/
|
*/
|
||||||
if(classOrInterface.getGenerics().iterator().hasNext() || !commonPairs.isEmpty() ||
|
if(classOrInterface.getGenerics().iterator().hasNext() || !commonPairs.isEmpty() ||
|
||||||
classOrInterface.getSuperClass().acceptTV(new TypeToSignature()).contains("<")) {
|
classOrInterface.getSuperClass().acceptTV(new TypeToSignature()).contains("<")
|
||||||
Signature signature = new Signature(classOrInterface, genericsAndBounds,commonPairs);
|
|| !tphsClass.isEmpty()) {
|
||||||
|
Signature signature = new Signature(classOrInterface, genericsAndBounds,commonPairs,tphsClass, consClass);
|
||||||
sig = signature.toString();
|
sig = signature.toString();
|
||||||
System.out.println("Signature: => " + sig);
|
System.out.println("Signature: => " + sig);
|
||||||
}
|
}
|
||||||
@ -176,6 +203,31 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeFromMethod(String name) {
|
||||||
|
for(MethodAndTPH m : tphExtractor.ListOfMethodsAndTph) {
|
||||||
|
ArrayList<String> toRemove = new ArrayList<>();
|
||||||
|
for(String tph : m.getTphs()) {
|
||||||
|
if(tph.equals(name)) {
|
||||||
|
toRemove.add(tph);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!toRemove.isEmpty()) {
|
||||||
|
m.getTphs().removeAll(toRemove);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private TypePlaceholder getTPH(String name) {
|
||||||
|
for(TypePlaceholder tph: tphExtractor.allTPHS.keySet()) {
|
||||||
|
if(tph.getName().equals(name))
|
||||||
|
return tph;
|
||||||
|
}
|
||||||
|
throw new NoSuchElementException("TPH "+name +" does not exist");
|
||||||
|
}
|
||||||
|
|
||||||
private void getCommonTPHS(TPHExtractor tphExtractor) {
|
private void getCommonTPHS(TPHExtractor tphExtractor) {
|
||||||
// Gemeinsame TPHs
|
// Gemeinsame TPHs
|
||||||
ArrayList<TypePlaceholder> cTPHs = new ArrayList<>();
|
ArrayList<TypePlaceholder> cTPHs = new ArrayList<>();
|
||||||
@ -220,7 +272,8 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
|
|
||||||
for(String paramName : methodParamsAndTypes.keySet()) {
|
for(String paramName : methodParamsAndTypes.keySet()) {
|
||||||
String typeOfParam = methodParamsAndTypes.get(paramName).acceptTV(new TypeToSignature());
|
String typeOfParam = methodParamsAndTypes.get(paramName).acceptTV(new TypeToSignature());
|
||||||
if(genericsAndBounds.containsKey(typeOfParam) ||typeOfParam.substring(0, 4).equals("TPH ")
|
System.out.println(typeOfParam);
|
||||||
|
if(genericsAndBounds.containsKey(typeOfParam) ||typeOfParam.contains("$")
|
||||||
|| typeOfParam.contains("<")) {
|
|| typeOfParam.contains("<")) {
|
||||||
hasGen = true;
|
hasGen = true;
|
||||||
break;
|
break;
|
||||||
@ -228,7 +281,7 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
}
|
}
|
||||||
String sig = null;
|
String sig = null;
|
||||||
if(hasGen) {
|
if(hasGen) {
|
||||||
HashMap<TPHConstraint, HashSet<String>> constraints = Simplify.simplifyConstraints(field.name, tphExtractor);
|
HashMap<TPHConstraint, HashSet<String>> constraints = Simplify.simplifyConstraints(field.name, tphExtractor,tphsClass);
|
||||||
Signature signature = new Signature(field, genericsAndBounds,methodParamsAndTypes,resultSet,constraints);
|
Signature signature = new Signature(field, genericsAndBounds,methodParamsAndTypes,resultSet,constraints);
|
||||||
sig = signature.toString();
|
sig = signature.toString();
|
||||||
}
|
}
|
||||||
@ -307,7 +360,7 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
System.out.println("ALL CONST: " + tphExtractor.allCons.size());
|
System.out.println("ALL CONST: " + tphExtractor.allCons.size());
|
||||||
tphExtractor.allCons.forEach(c->System.out.println(c.toString()));
|
tphExtractor.allCons.forEach(c->System.out.println(c.toString()));
|
||||||
System.out.println("----------------");
|
System.out.println("----------------");
|
||||||
HashMap<TPHConstraint, HashSet<String>> constraints = Simplify.simplifyConstraints(method.name, tphExtractor);
|
HashMap<TPHConstraint, HashSet<String>> constraints = Simplify.simplifyConstraints(method.name, tphExtractor, tphsClass);
|
||||||
// ArrayList<GenericInsertPair> pairs = simplifyPairs(method.name,tphExtractor.allPairs,tphExtractor.allCons);
|
// ArrayList<GenericInsertPair> pairs = simplifyPairs(method.name,tphExtractor.allPairs,tphExtractor.allCons);
|
||||||
Signature signature = new Signature(method, genericsAndBoundsMethod, genericsAndBounds,methodParamsAndTypes,resultSet,constraints);
|
Signature signature = new Signature(method, genericsAndBoundsMethod, genericsAndBounds,methodParamsAndTypes,resultSet,constraints);
|
||||||
sig = signature.toString();
|
sig = signature.toString();
|
||||||
@ -388,9 +441,21 @@ public class BytecodeGen implements ASTVisitor {
|
|||||||
@Override
|
@Override
|
||||||
public void visit(Field field) {
|
public void visit(Field field) {
|
||||||
System.out.println("In Field ---");
|
System.out.println("In Field ---");
|
||||||
|
String des = "L";
|
||||||
|
if(resultSet.resolveType(field.getType()).resolvedType instanceof TypePlaceholder) {
|
||||||
|
des += Type.getInternalName(Object.class);
|
||||||
|
} else {
|
||||||
|
des += resultSet.resolveType(field.getType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||||
|
}
|
||||||
|
des +=";";
|
||||||
|
System.out.println(des);
|
||||||
|
String sig = resultSet.resolveType(field.getType()).resolvedType.acceptTV(new TypeToSignature());
|
||||||
|
System.out.println(sig);
|
||||||
|
if(sig.charAt(sig.length()-1) != (";").charAt(0)) {
|
||||||
|
sig +=";";
|
||||||
|
}
|
||||||
cw.visitField(field.modifier, field.getName(),
|
cw.visitField(field.modifier, field.getName(),
|
||||||
"L"+resultSet.resolveType(field.getType()).resolvedType.acceptTV(new TypeToDescriptor())+";",
|
des, sig,
|
||||||
resultSet.resolveType(field.getType()).resolvedType.acceptTV(new TypeToSignature()),
|
|
||||||
null);
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -708,7 +708,13 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
@Override
|
@Override
|
||||||
public void visit(FieldVar fieldVar) {
|
public void visit(FieldVar fieldVar) {
|
||||||
fieldName = fieldVar.fieldVarName;
|
fieldName = fieldVar.fieldVarName;
|
||||||
fieldDesc = "L" + getResolvedType(fieldVar.getType()) + ";";
|
fieldDesc = "L";
|
||||||
|
if(resultSet.resolveType(fieldVar.getType()).resolvedType instanceof TypePlaceholder) {
|
||||||
|
fieldDesc += Type.getInternalName(Object.class);
|
||||||
|
} else {
|
||||||
|
fieldDesc += resultSet.resolveType(fieldVar.getType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||||
|
}
|
||||||
|
fieldDesc +=";";
|
||||||
|
|
||||||
fieldVar.receiver.accept(this);
|
fieldVar.receiver.accept(this);
|
||||||
// test (if)
|
// test (if)
|
||||||
@ -1405,9 +1411,18 @@ public class BytecodeGenMethod implements StatementVisitor {
|
|||||||
// array slot onto the top of the operand stack.
|
// array slot onto the top of the operand stack.
|
||||||
assignLeftSide.field.receiver.accept(this);
|
assignLeftSide.field.receiver.accept(this);
|
||||||
this.rightSideTemp.accept(this);
|
this.rightSideTemp.accept(this);
|
||||||
|
String fDesc = "L";
|
||||||
|
if(resultSet.resolveType(assignLeftSide.field.getType()).resolvedType instanceof TypePlaceholder) {
|
||||||
|
fDesc += Type.getInternalName(Object.class);
|
||||||
|
} else {
|
||||||
|
fDesc += resultSet.resolveType(assignLeftSide.field.getType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||||
|
}
|
||||||
|
fDesc +=";";
|
||||||
|
|
||||||
|
|
||||||
System.out.println("Receiver = " + getResolvedType(assignLeftSide.field.receiver.getType()));
|
System.out.println("Receiver = " + getResolvedType(assignLeftSide.field.receiver.getType()));
|
||||||
mv.visitFieldInsn(Opcodes.PUTFIELD, getResolvedType(assignLeftSide.field.receiver.getType()),
|
mv.visitFieldInsn(Opcodes.PUTFIELD, getResolvedType(assignLeftSide.field.receiver.getType()),
|
||||||
assignLeftSide.field.fieldVarName, "L"+getResolvedType(assignLeftSide.field.getType())+";");
|
assignLeftSide.field.fieldVarName, fDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -106,10 +106,17 @@ public class DescriptorToString implements DescriptorVisitor{
|
|||||||
if(constructor.getGenericsAndBounds().containsKey(fpDesc)){
|
if(constructor.getGenericsAndBounds().containsKey(fpDesc)){
|
||||||
desc += "L"+constructor.getGenericsAndBounds().get(fpDesc)+ ";";
|
desc += "L"+constructor.getGenericsAndBounds().get(fpDesc)+ ";";
|
||||||
}else {
|
}else {
|
||||||
desc += "L"+resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor())+ ";";
|
// desc += "L"+resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor())+ ";";
|
||||||
|
String resType = resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor());
|
||||||
|
if(resType.subSequence(0, 4).equals("TPH ")) {
|
||||||
|
// Bound ist immer Object
|
||||||
|
desc += "L"+Type.getInternalName(Object.class)+ ";";
|
||||||
|
} else {
|
||||||
|
desc += "L"+resType+ ";";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
// System.out.println("Cons has NOT Gens");
|
// System.out.println("Cons has NO Gens");
|
||||||
desc += "L"+resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor())+ ";";
|
desc += "L"+resultSet.resolveType(fp.getType()).resolvedType.acceptTV(new TypeToDescriptor())+ ";";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,11 +41,16 @@ public class Signature {
|
|||||||
private ResultSet resultSet;
|
private ResultSet resultSet;
|
||||||
private ArrayList<GenericInsertPair> commonPairs;
|
private ArrayList<GenericInsertPair> commonPairs;
|
||||||
private HashMap<TPHConstraint,HashSet<String>> methodConstraints;
|
private HashMap<TPHConstraint,HashSet<String>> methodConstraints;
|
||||||
|
private ArrayList<TypePlaceholder> tphsClass;
|
||||||
|
private ArrayList<TPHConstraint> consClass;
|
||||||
|
|
||||||
public Signature(ClassOrInterface classOrInterface, HashMap<String, String> genericsAndBounds,ArrayList<GenericInsertPair> commonPairs) {
|
public Signature(ClassOrInterface classOrInterface, HashMap<String, String> genericsAndBounds,
|
||||||
|
ArrayList<GenericInsertPair> commonPairs, ArrayList<TypePlaceholder> tphsClass, ArrayList<TPHConstraint> consClass) {
|
||||||
this.classOrInterface = classOrInterface;
|
this.classOrInterface = classOrInterface;
|
||||||
this.genericsAndBounds = genericsAndBounds;
|
this.genericsAndBounds = genericsAndBounds;
|
||||||
this.commonPairs = commonPairs;
|
this.commonPairs = commonPairs;
|
||||||
|
this.tphsClass = tphsClass;
|
||||||
|
this.consClass = consClass;
|
||||||
sw = new SignatureWriter();
|
sw = new SignatureWriter();
|
||||||
createSignatureForClassOrInterface();
|
createSignatureForClassOrInterface();
|
||||||
}
|
}
|
||||||
@ -367,7 +372,37 @@ public class Signature {
|
|||||||
GenericTypeVar g = itr.next();
|
GenericTypeVar g = itr.next();
|
||||||
getBoundsOfTypeVar(g,genericsAndBounds);
|
getBoundsOfTypeVar(g,genericsAndBounds);
|
||||||
}
|
}
|
||||||
if(!commonPairs.isEmpty()) {
|
|
||||||
|
if(!consClass.isEmpty()) {
|
||||||
|
ArrayList<String> types = new ArrayList<>();
|
||||||
|
ArrayList<String> superTypes = new ArrayList<>();
|
||||||
|
|
||||||
|
for(TPHConstraint cons : consClass) {
|
||||||
|
types.add(cons.getLeft());
|
||||||
|
superTypes.add(cons.getRight());
|
||||||
|
}
|
||||||
|
|
||||||
|
for(TPHConstraint cons : consClass) {
|
||||||
|
String t = cons.getLeft()+"$";
|
||||||
|
String bound = cons.getRight()+"$";
|
||||||
|
sw.visitFormalTypeParameter(t);
|
||||||
|
sw.visitClassBound().visitTypeVariable(bound);
|
||||||
|
genericsAndBounds.put(t, bound);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(TPHConstraint cons : consClass) {
|
||||||
|
if(!types.contains(cons.getRight())) {
|
||||||
|
String t = cons.getRight()+"$";
|
||||||
|
String bound = Type.getInternalName(Object.class);
|
||||||
|
sw.visitFormalTypeParameter(t);
|
||||||
|
sw.visitClassBound().visitClassType(bound);
|
||||||
|
genericsAndBounds.put(t, bound);
|
||||||
|
sw.visitClassBound().visitEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/*if(!commonPairs.isEmpty()) {
|
||||||
ArrayList<TypePlaceholder> types = new ArrayList<>();
|
ArrayList<TypePlaceholder> types = new ArrayList<>();
|
||||||
ArrayList<TypePlaceholder> superTypes = new ArrayList<>();
|
ArrayList<TypePlaceholder> superTypes = new ArrayList<>();
|
||||||
|
|
||||||
@ -395,6 +430,14 @@ public class Signature {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for(TypePlaceholder t : tphsClass) {
|
||||||
|
String n = t.getName()+"$";
|
||||||
|
String bound = Type.getInternalName(Object.class);
|
||||||
|
sw.visitFormalTypeParameter(n);
|
||||||
|
sw.visitClassBound().visitClassType(bound);
|
||||||
|
genericsAndBounds.put(n, bound);
|
||||||
|
sw.visitClassBound().visitEnd();
|
||||||
|
}*/
|
||||||
String sClass = classOrInterface.getSuperClass().acceptTV(new TypeToSignature());
|
String sClass = classOrInterface.getSuperClass().acceptTV(new TypeToSignature());
|
||||||
sw.visitSuperclass().visitClassType(sClass.substring(1, sClass.length()-1));
|
sw.visitSuperclass().visitClassType(sClass.substring(1, sClass.length()-1));
|
||||||
sw.visitEnd();
|
sw.visitEnd();
|
||||||
|
@ -8,6 +8,7 @@ import java.util.LinkedList;
|
|||||||
import org.objectweb.asm.Type;
|
import org.objectweb.asm.Type;
|
||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
||||||
|
import de.dhbwstuttgart.bytecode.constraint.EqualConstraint;
|
||||||
import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint;
|
import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint;
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||||
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
||||||
@ -15,7 +16,7 @@ import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
|||||||
|
|
||||||
public class Simplify {
|
public class Simplify {
|
||||||
|
|
||||||
public static HashMap<TPHConstraint, HashSet<String>> simplifyConstraints(String name, TPHExtractor tphExtractor) {
|
public static HashMap<TPHConstraint, HashSet<String>> simplifyConstraints(String name, TPHExtractor tphExtractor, ArrayList<TypePlaceholder> tphsClass) {
|
||||||
// 1. check if there are any simple cycles like L<R and R<L:
|
// 1. check if there are any simple cycles like L<R and R<L:
|
||||||
// a) yes => set L=R and:
|
// a) yes => set L=R and:
|
||||||
// * remove both constraints
|
// * remove both constraints
|
||||||
@ -42,7 +43,7 @@ public class Simplify {
|
|||||||
if(revCon != null) {
|
if(revCon != null) {
|
||||||
revCon.setRel(Relation.EQUAL);
|
revCon.setRel(Relation.EQUAL);
|
||||||
// the reverse constraint is removed because
|
// the reverse constraint is removed because
|
||||||
// otherwise there is twice the same constraint
|
// otherwise there is the same constraint twice
|
||||||
// (e.g. A<B and B<A => A=B and B=A)
|
// (e.g. A<B and B<A => A=B and B=A)
|
||||||
consToRemove.add(revCon);
|
consToRemove.add(revCon);
|
||||||
c.setRel(Relation.EQUAL);
|
c.setRel(Relation.EQUAL);
|
||||||
@ -199,6 +200,7 @@ public class Simplify {
|
|||||||
// if yes => check if the super type in the method, if not
|
// if yes => check if the super type in the method, if not
|
||||||
// then ignore it.
|
// then ignore it.
|
||||||
HashMap<String, String> subAndSuper = new HashMap<>();
|
HashMap<String, String> subAndSuper = new HashMap<>();
|
||||||
|
ArrayList<TPHConstraint> eqCons = new ArrayList<>();
|
||||||
for(TPHConstraint c : allCons) {
|
for(TPHConstraint c : allCons) {
|
||||||
if(subAndSuper.containsKey(c.getLeft())) {
|
if(subAndSuper.containsKey(c.getLeft())) {
|
||||||
LinkedList<String> all = new LinkedList<>();
|
LinkedList<String> all = new LinkedList<>();
|
||||||
@ -216,9 +218,28 @@ public class Simplify {
|
|||||||
if(!containTPH(methodTphs, all.getLast()))
|
if(!containTPH(methodTphs, all.getLast()))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if(subAndSuper.containsKey(c.getLeft())) {
|
||||||
|
System.out.println(c.getLeft());
|
||||||
|
String r = c.getRight();
|
||||||
|
String r2 = subAndSuper.get(c.getLeft());
|
||||||
|
EqualConstraint eq = new EqualConstraint(r2, r, Relation.EQUAL);
|
||||||
|
eqCons.add(eq);
|
||||||
|
substituteInMap(subAndSuper,eqCons,allCons,r,r2);
|
||||||
|
}
|
||||||
subAndSuper.put(c.getLeft(), c.getRight());
|
subAndSuper.put(c.getLeft(), c.getRight());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println("SAME LEFT SIDE: ");
|
||||||
|
subAndSuper.forEach((c,hs)->{
|
||||||
|
if(c!=null) {
|
||||||
|
System.out.print(c+ " -> " + hs);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
System.out.println();
|
||||||
|
});
|
||||||
|
System.out.println("----------------");
|
||||||
int numOfVisitedPairs = 0;
|
int numOfVisitedPairs = 0;
|
||||||
for(String sub : subAndSuper.keySet()) {
|
for(String sub : subAndSuper.keySet()) {
|
||||||
if(isTPHInConstraint(result,sub))
|
if(isTPHInConstraint(result,sub))
|
||||||
@ -280,17 +301,27 @@ public class Simplify {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!containTPH(methodTphs, superTphRes)) {
|
if(!containTPH(methodTphs, superTphRes)) {
|
||||||
result.put(new ExtendsConstraint(subTphRes, Type.getInternalName(Object.class), Relation.EXTENDS), null);
|
HashSet<String> equals = getEqualsTphsFromEqualCons(eqCons,superTphRes);
|
||||||
|
if(classTPHSContainsTPH(tphsClass,superTphRes)) {
|
||||||
|
result.put(new ExtendsConstraint(subTphRes, superTphRes, Relation.EXTENDS), equals);
|
||||||
|
} else {
|
||||||
|
result.put(new ExtendsConstraint(subTphRes, Type.getInternalName(Object.class), Relation.EXTENDS), equals);
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
result.put(new ExtendsConstraint(subTphRes, superTphRes, Relation.EXTENDS), null);
|
HashSet<String> equals = getEqualsTphsFromEqualCons(eqCons,subTphRes);
|
||||||
if(!isTPHInConstraint(result, superTphRes))
|
result.put(new ExtendsConstraint(subTphRes, superTphRes, Relation.EXTENDS), equals);
|
||||||
result.put(new ExtendsConstraint(superTphRes, Type.getInternalName(Object.class), Relation.EXTENDS), null);
|
if(!isTPHInConstraint(result, superTphRes) && !isTphInEqualSet(result,superTphRes)) {
|
||||||
|
HashSet<String> equals2 = getEqualsTphsFromEqualCons(eqCons,superTphRes);
|
||||||
|
result.put(new ExtendsConstraint(superTphRes, Type.getInternalName(Object.class), Relation.EXTENDS), equals2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(String tph : methodTphs) {
|
for(String tph : methodTphs) {
|
||||||
if(!isTPHInConstraint(result, tph)) {
|
if(!isTPHInConstraint(result, tph) && !isTphInEqualSet(result,tph)) {
|
||||||
result.put(new ExtendsConstraint(tph, Type.getInternalName(Object.class), Relation.EXTENDS), null);
|
HashSet<String> equals = getEqualsTphsFromEqualCons(eqCons,tph);
|
||||||
|
result.put(new ExtendsConstraint(tph, Type.getInternalName(Object.class), Relation.EXTENDS), equals);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,6 +345,51 @@ public class Simplify {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean classTPHSContainsTPH(ArrayList<TypePlaceholder> tphsClass, String superTphRes) {
|
||||||
|
for(TypePlaceholder tph : tphsClass) {
|
||||||
|
if(tph.getName().equals(superTphRes))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isTphInEqualSet(HashMap<TPHConstraint, HashSet<String>> result, String tph) {
|
||||||
|
for(HashSet<String> hs: result.values()) {
|
||||||
|
if(hs.contains(tph))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HashSet<String> getEqualsTphsFromEqualCons(ArrayList<TPHConstraint> eqCons, String tph) {
|
||||||
|
HashSet<String> ee = new HashSet<>();
|
||||||
|
for(TPHConstraint c : eqCons) {
|
||||||
|
if(c.getLeft().equals(tph))
|
||||||
|
ee.add(c.getRight());
|
||||||
|
if(c.getRight().equals(tph))
|
||||||
|
ee.add(c.getLeft());
|
||||||
|
}
|
||||||
|
return ee;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void substituteInMap(HashMap<String, String> subAndSuper, ArrayList<TPHConstraint> allCons,ArrayList<TPHConstraint> eqCons, String toSubs,
|
||||||
|
String tph) {
|
||||||
|
substituteTPH(allCons, toSubs, tph);
|
||||||
|
if(subAndSuper.containsKey(toSubs) && subAndSuper.containsKey(tph)) {
|
||||||
|
toSubs = subAndSuper.remove(toSubs);
|
||||||
|
EqualConstraint eq = new EqualConstraint(subAndSuper.get(tph), toSubs, Relation.EQUAL);
|
||||||
|
eqCons.add(eq);
|
||||||
|
substituteInMap(subAndSuper, allCons,eqCons,toSubs, subAndSuper.get(tph));
|
||||||
|
} else if(subAndSuper.containsKey(toSubs) && !subAndSuper.containsKey(tph)) {
|
||||||
|
String val = subAndSuper.remove(toSubs);
|
||||||
|
subAndSuper.put(tph, val);
|
||||||
|
} else {
|
||||||
|
for(String k : subAndSuper.keySet()) {
|
||||||
|
subAndSuper.replace(k, toSubs, tph);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static TPHConstraint getConstraint(String oldRight, String right, ArrayList<TPHConstraint> allCons) {
|
private static TPHConstraint getConstraint(String oldRight, String right, ArrayList<TPHConstraint> allCons) {
|
||||||
for(TPHConstraint c : allCons) {
|
for(TPHConstraint c : allCons) {
|
||||||
if(c.getLeft().equals(oldRight) && c.getRight().equals(right))
|
if(c.getLeft().equals(oldRight) && c.getRight().equals(right))
|
||||||
|
@ -120,12 +120,14 @@ public class JavaTXCompiler {
|
|||||||
TypeUnify unify = new TypeUnify();
|
TypeUnify unify = new TypeUnify();
|
||||||
Set<Set<UnifyPair>> results = new HashSet<>();
|
Set<Set<UnifyPair>> results = new HashSet<>();
|
||||||
try {
|
try {
|
||||||
//FileWriter logFile = new FileWriter(new File(System.getProperty("user.dir")+"/test/logFiles/"+"log"));
|
File logPath = new File(System.getProperty("user.dir")+"/target/logFiles/");
|
||||||
//logFile.write("FC:\\" + finiteClosure.toString()+"\n");
|
logPath.mkdirs();
|
||||||
//for(SourceFile sf : this.sourceFiles.values()) {
|
FileWriter logFile = new FileWriter(new File(logPath, "log"));
|
||||||
// logFile.write(ASTTypePrinter.print(sf));
|
logFile.write("FC:\\" + finiteClosure.toString()+"\n");
|
||||||
//}
|
for(SourceFile sf : this.sourceFiles.values()) {
|
||||||
//logFile.flush();
|
logFile.write(ASTTypePrinter.print(sf));
|
||||||
|
}
|
||||||
|
logFile.flush();
|
||||||
Set<List<Constraint<UnifyPair>>> cardProd = unifyCons.cartesianProduct();
|
Set<List<Constraint<UnifyPair>>> cardProd = unifyCons.cartesianProduct();
|
||||||
for (List<Constraint<UnifyPair>> xCons : cardProd ){
|
for (List<Constraint<UnifyPair>> xCons : cardProd ){
|
||||||
Set<UnifyPair> xConsSet = new HashSet<>();
|
Set<UnifyPair> xConsSet = new HashSet<>();
|
||||||
@ -150,21 +152,21 @@ public class JavaTXCompiler {
|
|||||||
paraTypeVarNames.addAll(constructorParaTypeVarNames);
|
paraTypeVarNames.addAll(constructorParaTypeVarNames);
|
||||||
|
|
||||||
Set<String> returnTypeVarNames = allClasses.stream().map(x -> x.getMethods().stream().filter(y -> y.getReturnType() instanceof TypePlaceholder)
|
Set<String> returnTypeVarNames = allClasses.stream().map(x -> x.getMethods().stream().filter(y -> y.getReturnType() instanceof TypePlaceholder)
|
||||||
.map(z -> ((TypePlaceholder)z.getReturnType()).getName()).collect(Collectors.toCollection(HashSet::new))).reduce((a,b) -> { a.addAll(b); return a;}).get();
|
.map(z -> ((TypePlaceholder)z.getReturnType()).getName()).collect(Collectors.toCollection(HashSet::new))).reduce((a,b) -> { a.addAll(b); return a;} ).get();
|
||||||
|
|
||||||
Set<String> fieldTypeVarNames = allClasses.stream().map(x -> x.getFieldDecl().stream().filter(y -> y.getReturnType() instanceof TypePlaceholder)
|
Set<String> fieldTypeVarNames = allClasses.stream().map(x -> x.getFieldDecl().stream().filter(y -> y.getReturnType() instanceof TypePlaceholder)
|
||||||
.map(z -> ((TypePlaceholder)z.getReturnType()).getName()).collect(Collectors.toCollection(HashSet::new))).reduce((a,b) -> { a.addAll(b); return a;}).get();
|
.map(z -> ((TypePlaceholder)z.getReturnType()).getName()).collect(Collectors.toCollection(HashSet::new))).reduce((a,b) -> { a.addAll(b); return a;} ).get();
|
||||||
|
|
||||||
returnTypeVarNames.addAll(fieldTypeVarNames);
|
returnTypeVarNames.addAll(fieldTypeVarNames);
|
||||||
|
|
||||||
xConsSet = xConsSet.stream().map(x -> {
|
xConsSet = xConsSet.stream().map(x -> {
|
||||||
//Hier muss ueberlegt werden, ob
|
//Hier muss ueberlegt werden, ob
|
||||||
//1. alle Argument- und Retuntyp-Variablen in allen UnifyPairs
|
//1. alle Argument- und Retuntyp-Variablen in allen UnifyPairs
|
||||||
// mit disableWildcardtable() werden.
|
// mit disableWildcardtable() werden.
|
||||||
//2. alle Typvariablen mit Argument- oder Retuntyp-Variablen
|
//2. alle Typvariablen mit Argument- oder Retuntyp-Variablen
|
||||||
//in Beziehung auch auf disableWildcardtable() gesetzt werden muessen
|
//in Beziehung auch auf disableWildcardtable() gesetzt werden muessen
|
||||||
//PL 2018-04-23
|
//PL 2018-04-23
|
||||||
if ((x.getLhsType() instanceof PlaceholderType)) {
|
if ((x.getLhsType() instanceof PlaceholderType)) {
|
||||||
if (paraTypeVarNames.contains(x.getLhsType().getName())) {
|
if (paraTypeVarNames.contains(x.getLhsType().getName())) {
|
||||||
((PlaceholderType)x.getLhsType()).setVariance((byte)1);
|
((PlaceholderType)x.getLhsType()).setVariance((byte)1);
|
||||||
((PlaceholderType)x.getLhsType()).disableWildcardtable();
|
((PlaceholderType)x.getLhsType()).disableWildcardtable();
|
||||||
@ -173,8 +175,8 @@ public class JavaTXCompiler {
|
|||||||
((PlaceholderType)x.getLhsType()).setVariance((byte)-1);
|
((PlaceholderType)x.getLhsType()).setVariance((byte)-1);
|
||||||
((PlaceholderType)x.getLhsType()).disableWildcardtable();
|
((PlaceholderType)x.getLhsType()).disableWildcardtable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((x.getRhsType() instanceof PlaceholderType)) {
|
if ((x.getRhsType() instanceof PlaceholderType)) {
|
||||||
if (paraTypeVarNames.contains(x.getRhsType().getName())) {
|
if (paraTypeVarNames.contains(x.getRhsType().getName())) {
|
||||||
((PlaceholderType)x.getRhsType()).setVariance((byte)1);
|
((PlaceholderType)x.getRhsType()).setVariance((byte)1);
|
||||||
((PlaceholderType)x.getRhsType()).disableWildcardtable();
|
((PlaceholderType)x.getRhsType()).disableWildcardtable();
|
||||||
@ -188,6 +190,7 @@ public class JavaTXCompiler {
|
|||||||
})
|
})
|
||||||
/* PL 2018-11-07 wird in varianceInheritance erledigt
|
/* PL 2018-11-07 wird in varianceInheritance erledigt
|
||||||
.map( y -> {
|
.map( y -> {
|
||||||
|
|
||||||
if ((y.getLhsType() instanceof PlaceholderType) && (y.getRhsType() instanceof PlaceholderType)) {
|
if ((y.getLhsType() instanceof PlaceholderType) && (y.getRhsType() instanceof PlaceholderType)) {
|
||||||
if (((PlaceholderType)y.getLhsType()).getVariance() != 0 && ((PlaceholderType)y.getRhsType()).getVariance() == 0) {
|
if (((PlaceholderType)y.getLhsType()).getVariance() != 0 && ((PlaceholderType)y.getRhsType()).getVariance() == 0) {
|
||||||
((PlaceholderType)y.getRhsType()).setVariance(((PlaceholderType)y.getLhsType()).getVariance());
|
((PlaceholderType)y.getRhsType()).setVariance(((PlaceholderType)y.getLhsType()).getVariance());
|
||||||
@ -199,12 +202,18 @@ public class JavaTXCompiler {
|
|||||||
return y; } )
|
return y; } )
|
||||||
*/
|
*/
|
||||||
.collect(Collectors.toCollection(HashSet::new));
|
.collect(Collectors.toCollection(HashSet::new));
|
||||||
varianceInheritance(xConsSet);
|
varianceInheritance(xConsSet);
|
||||||
Set<Set<UnifyPair>> result = unify.unifySequential(xConsSet, finiteClosure);
|
|
||||||
//Set<Set<UnifyPair>> result = unify.unify(xConsSet, finiteClosure);
|
|
||||||
System.out.println("RESULT: " + result);
|
|
||||||
results.addAll(result);
|
Set<Set<UnifyPair>> result = unify.unifySequential(xConsSet, finiteClosure, logFile, log);
|
||||||
}
|
//Set<Set<UnifyPair>> result = unify.unify(xConsSet, finiteClosure);
|
||||||
|
System.out.println("RESULT: " + result);
|
||||||
|
logFile.write("RES: " + result.toString()+"\n");
|
||||||
|
logFile.flush();
|
||||||
|
results.addAll(result);
|
||||||
|
}
|
||||||
|
|
||||||
results = results.stream().map(x -> {
|
results = results.stream().map(x -> {
|
||||||
Optional<Set<UnifyPair>> res = new RuleSet().subst(x.stream().map(y -> {
|
Optional<Set<UnifyPair>> res = new RuleSet().subst(x.stream().map(y -> {
|
||||||
if (y.getPairOp() == PairOperator.SMALLERDOTWC) y.setPairOp(PairOperator.EQUALSDOT);
|
if (y.getPairOp() == PairOperator.SMALLERDOTWC) y.setPairOp(PairOperator.EQUALSDOT);
|
||||||
@ -216,6 +225,14 @@ public class JavaTXCompiler {
|
|||||||
else return x; //wenn nichts veraendert wurde wird x zurueckgegeben
|
else return x; //wenn nichts veraendert wurde wird x zurueckgegeben
|
||||||
}).collect(Collectors.toCollection(HashSet::new));
|
}).collect(Collectors.toCollection(HashSet::new));
|
||||||
System.out.println("RESULT Final: " + results);
|
System.out.println("RESULT Final: " + results);
|
||||||
|
logFile.write("RES_FINAL: " + results.toString()+"\n");
|
||||||
|
logFile.flush();
|
||||||
|
logFile.write("PLACEHOLDERS: " + PlaceholderType.EXISTING_PLACEHOLDERS);
|
||||||
|
logFile.flush();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
return results.stream().map((unifyPairs ->
|
return results.stream().map((unifyPairs ->
|
||||||
new ResultSet(UnifyTypeFactory.convert(unifyPairs, generateTPHMap(cons))))).collect(Collectors.toList());
|
new ResultSet(UnifyTypeFactory.convert(unifyPairs, generateTPHMap(cons))))).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
numeric = new Constraint<>();
|
numeric = new Constraint<>();
|
||||||
numeric.add(new Pair(binary.lexpr.getType(), integer, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(binary.lexpr.getType(), integer, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.rexpr.getType(), integer, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(binary.rexpr.getType(), integer, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.getType(), integer, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(integer, binary.getType(), PairOperator.SMALLERDOT));
|
||||||
numericAdditionOrStringConcatenation.add(numeric);
|
numericAdditionOrStringConcatenation.add(numeric);
|
||||||
}
|
}
|
||||||
//PL eingefuegt 2018-07-17
|
//PL eingefuegt 2018-07-17
|
||||||
@ -262,7 +262,7 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
numeric = new Constraint<>();
|
numeric = new Constraint<>();
|
||||||
numeric.add(new Pair(binary.lexpr.getType(), longg, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(binary.lexpr.getType(), longg, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.rexpr.getType(), longg, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(binary.rexpr.getType(), longg, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.getType(), longg, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(longg, binary.getType(), PairOperator.SMALLERDOT));
|
||||||
numericAdditionOrStringConcatenation.add(numeric);
|
numericAdditionOrStringConcatenation.add(numeric);
|
||||||
}
|
}
|
||||||
//PL eingefuegt 2018-07-17
|
//PL eingefuegt 2018-07-17
|
||||||
@ -270,7 +270,7 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
numeric = new Constraint<>();
|
numeric = new Constraint<>();
|
||||||
numeric.add(new Pair(binary.lexpr.getType(), floatt, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(binary.lexpr.getType(), floatt, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.rexpr.getType(), floatt, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(binary.rexpr.getType(), floatt, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.getType(), floatt, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(floatt, binary.getType(), PairOperator.SMALLERDOT));
|
||||||
numericAdditionOrStringConcatenation.add(numeric);
|
numericAdditionOrStringConcatenation.add(numeric);
|
||||||
}
|
}
|
||||||
//PL eingefuegt 2018-07-17
|
//PL eingefuegt 2018-07-17
|
||||||
@ -278,7 +278,7 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
numeric = new Constraint<>();
|
numeric = new Constraint<>();
|
||||||
numeric.add(new Pair(binary.lexpr.getType(), doublee, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(binary.lexpr.getType(), doublee, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.rexpr.getType(), doublee, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(binary.rexpr.getType(), doublee, PairOperator.SMALLERDOT));
|
||||||
numeric.add(new Pair(binary.getType(), doublee, PairOperator.SMALLERDOT));
|
numeric.add(new Pair(doublee, binary.getType(), PairOperator.SMALLERDOT));
|
||||||
numericAdditionOrStringConcatenation.add(numeric);
|
numericAdditionOrStringConcatenation.add(numeric);
|
||||||
}
|
}
|
||||||
/* PL auskommentiert Anfang 2018-07-17
|
/* PL auskommentiert Anfang 2018-07-17
|
||||||
@ -298,7 +298,7 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
Constraint<Pair> stringConcat = new Constraint<>();
|
Constraint<Pair> stringConcat = new Constraint<>();
|
||||||
stringConcat.add(new Pair(binary.lexpr.getType(), string, PairOperator.EQUALSDOT));
|
stringConcat.add(new Pair(binary.lexpr.getType(), string, PairOperator.EQUALSDOT));
|
||||||
stringConcat.add(new Pair(binary.rexpr.getType(), string, PairOperator.EQUALSDOT));
|
stringConcat.add(new Pair(binary.rexpr.getType(), string, PairOperator.EQUALSDOT));
|
||||||
stringConcat.add(new Pair(binary.getType(), string, PairOperator.EQUALSDOT));
|
stringConcat.add(new Pair(string, binary.getType(), PairOperator.EQUALSDOT));
|
||||||
numericAdditionOrStringConcatenation.add(stringConcat);
|
numericAdditionOrStringConcatenation.add(stringConcat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,10 +36,16 @@ import java.io.IOException;
|
|||||||
*/
|
*/
|
||||||
public class RuleSet implements IRuleSet{
|
public class RuleSet implements IRuleSet{
|
||||||
|
|
||||||
|
FileWriter logFile;
|
||||||
|
|
||||||
public RuleSet() {
|
public RuleSet() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RuleSet(FileWriter logFile) {
|
||||||
|
this.logFile = logFile;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<UnifyPair> reduceUp(UnifyPair pair) {
|
public Optional<UnifyPair> reduceUp(UnifyPair pair) {
|
||||||
// Check if reduce up is applicable
|
// Check if reduce up is applicable
|
||||||
@ -793,6 +799,14 @@ public class RuleSet implements IRuleSet{
|
|||||||
UnifyType r = x.getRhsType();
|
UnifyType r = x.getRhsType();
|
||||||
if (r instanceof PlaceholderType) { ((PlaceholderType)r).disableWildcardtable(); }
|
if (r instanceof PlaceholderType) { ((PlaceholderType)r).disableWildcardtable(); }
|
||||||
} );
|
} );
|
||||||
|
try {
|
||||||
|
logFile.write("FUNgreater: " + pair + "\n");
|
||||||
|
logFile.write("FUNred: " + result + "\n");
|
||||||
|
logFile.flush();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
System.out.println("logFile-Error");
|
||||||
|
}
|
||||||
return Optional.of(result);
|
return Optional.of(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -835,6 +849,14 @@ public class RuleSet implements IRuleSet{
|
|||||||
UnifyType r = x.getRhsType();
|
UnifyType r = x.getRhsType();
|
||||||
if (r instanceof PlaceholderType) { ((PlaceholderType)r).disableWildcardtable(); }
|
if (r instanceof PlaceholderType) { ((PlaceholderType)r).disableWildcardtable(); }
|
||||||
} );
|
} );
|
||||||
|
try {
|
||||||
|
logFile.write("FUNgreater: " + pair + "\n");
|
||||||
|
logFile.write("FUNgreater: " + result + "\n");
|
||||||
|
logFile.flush();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
System.out.println("lofFile-Error");
|
||||||
|
}
|
||||||
return Optional.of(result);
|
return Optional.of(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -877,6 +899,14 @@ public class RuleSet implements IRuleSet{
|
|||||||
UnifyType r = x.getRhsType();
|
UnifyType r = x.getRhsType();
|
||||||
if (r instanceof PlaceholderType) { ((PlaceholderType)r).disableWildcardtable(); }
|
if (r instanceof PlaceholderType) { ((PlaceholderType)r).disableWildcardtable(); }
|
||||||
} );
|
} );
|
||||||
|
try {
|
||||||
|
logFile.write("FUNgreater: " + pair + "\n");
|
||||||
|
logFile.write("FUNsmaller: " + result + "\n");
|
||||||
|
logFile.flush();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
System.out.println("lofFile-Error");
|
||||||
|
}
|
||||||
return Optional.of(result);
|
return Optional.of(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,16 +8,16 @@ import de.dhbwstuttgart.typeinference.unify.interfaces.IFiniteClosure;
|
|||||||
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
import de.dhbwstuttgart.typeinference.unify.model.UnifyPair;
|
||||||
|
|
||||||
public class TypeUnify {
|
public class TypeUnify {
|
||||||
public Set<Set<UnifyPair>> unify(Set<UnifyPair> eq, IFiniteClosure fc) {
|
public Set<Set<UnifyPair>> unify(Set<UnifyPair> eq, IFiniteClosure fc, FileWriter logFile, Boolean log) {
|
||||||
TypeUnifyTask unifyTask = new TypeUnifyTask(eq, fc, true);
|
TypeUnifyTask unifyTask = new TypeUnifyTask(eq, fc, true, logFile, log);
|
||||||
ForkJoinPool pool = new ForkJoinPool();
|
ForkJoinPool pool = new ForkJoinPool();
|
||||||
pool.invoke(unifyTask);
|
pool.invoke(unifyTask);
|
||||||
Set<Set<UnifyPair>> res = unifyTask.join();
|
Set<Set<UnifyPair>> res = unifyTask.join();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Set<UnifyPair>> unifySequential(Set<UnifyPair> eq, IFiniteClosure fc) {
|
public Set<Set<UnifyPair>> unifySequential(Set<UnifyPair> eq, IFiniteClosure fc, FileWriter logFile, Boolean log) {
|
||||||
TypeUnifyTask unifyTask = new TypeUnifyTask(eq, fc, false);
|
TypeUnifyTask unifyTask = new TypeUnifyTask(eq, fc, false, logFile, log);
|
||||||
Set<Set<UnifyPair>> res = unifyTask.compute();
|
Set<Set<UnifyPair>> res = unifyTask.compute();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
private static int i = 0;
|
private static int i = 0;
|
||||||
private boolean printtag = false;
|
private boolean printtag = false;
|
||||||
|
Boolean log = true; //gibt an ob ein Log-File nach System.getProperty("user.dir")+"/test/logFiles/log" geschrieben werden soll?
|
||||||
|
|
||||||
|
public static final String rootDirectory = System.getProperty("user.dir")+"/test/logFiles/";
|
||||||
|
FileWriter logFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The implementation of setOps that will be used during the unification
|
* The implementation of setOps that will be used during the unification
|
||||||
@ -88,12 +91,14 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
rules = new RuleSet();
|
rules = new RuleSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TypeUnifyTask(Set<UnifyPair> eq, IFiniteClosure fc, boolean parallel) {
|
public TypeUnifyTask(Set<UnifyPair> eq, IFiniteClosure fc, boolean parallel, FileWriter logFile, Boolean log) {
|
||||||
this.eq = eq;
|
this.eq = eq;
|
||||||
this.fc = fc;
|
this.fc = fc;
|
||||||
this.oup = new OrderingUnifyPair(fc);
|
this.oup = new OrderingUnifyPair(fc);
|
||||||
this.parallel = parallel;
|
this.parallel = parallel;
|
||||||
rules = new RuleSet();
|
this.logFile = logFile;
|
||||||
|
this.log = log;
|
||||||
|
rules = new RuleSet(logFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -153,6 +158,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
* Step 1: Repeated application of reduce, adapt, erase, swap
|
* Step 1: Repeated application of reduce, adapt, erase, swap
|
||||||
*/
|
*/
|
||||||
nOfUnify++;
|
nOfUnify++;
|
||||||
|
writeLog(nOfUnify.toString() + " Unifikation: " + eq.toString());
|
||||||
//eq = eq.stream().map(x -> {x.setVariance((byte)-1); return x;}).collect(Collectors.toCollection(HashSet::new));
|
//eq = eq.stream().map(x -> {x.setVariance((byte)-1); return x;}).collect(Collectors.toCollection(HashSet::new));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -228,6 +234,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
// those pairs are contradictory and the unification is impossible.
|
// those pairs are contradictory and the unification is impossible.
|
||||||
if(!undefinedPairs.isEmpty()) {
|
if(!undefinedPairs.isEmpty()) {
|
||||||
noUndefPair++;
|
noUndefPair++;
|
||||||
|
for (UnifyPair up : undefinedPairs) {
|
||||||
|
writeLog(noUndefPair.toString() + " UndefinedPairs; " + up);
|
||||||
|
writeLog("BasePair; " + up.getBasePair());
|
||||||
|
}
|
||||||
Set<Set<UnifyPair>> error = new HashSet<>();
|
Set<Set<UnifyPair>> error = new HashSet<>();
|
||||||
undefinedPairs = undefinedPairs.stream().map(x -> { x.setUndefinedPair(); return x;}).collect(Collectors.toCollection(HashSet::new));
|
undefinedPairs = undefinedPairs.stream().map(x -> { x.setUndefinedPair(); return x;}).collect(Collectors.toCollection(HashSet::new));
|
||||||
error.add(undefinedPairs);
|
error.add(undefinedPairs);
|
||||||
@ -316,13 +326,13 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
eqPrimePrimeSet.add(eqPrime);
|
eqPrimePrimeSet.add(eqPrime);
|
||||||
else if(eqPrimePrime.isPresent()) {
|
else if(eqPrimePrime.isPresent()) {
|
||||||
//System.out.println("nextStep: " + eqPrimePrime.get());
|
//System.out.println("nextStep: " + eqPrimePrime.get());
|
||||||
TypeUnifyTask fork = new TypeUnifyTask(eqPrimePrime.get(), fc, true);
|
TypeUnifyTask fork = new TypeUnifyTask(eqPrimePrime.get(), fc, true, logFile, log);
|
||||||
forks.add(fork);
|
forks.add(fork);
|
||||||
fork.fork();
|
fork.fork();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//System.out.println("nextStep: " + eqPrime);
|
//System.out.println("nextStep: " + eqPrime);
|
||||||
TypeUnifyTask fork = new TypeUnifyTask(eqPrime, fc, true);
|
TypeUnifyTask fork = new TypeUnifyTask(eqPrime, fc, true, logFile, log);
|
||||||
forks.add(fork);
|
forks.add(fork);
|
||||||
fork.fork();
|
fork.fork();
|
||||||
}
|
}
|
||||||
@ -333,6 +343,13 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
//PL 2017-09-29 dies ersetzt //(!eqPrimePrime.isPresent())
|
//PL 2017-09-29 dies ersetzt //(!eqPrimePrime.isPresent())
|
||||||
//PL 2018-05-18 beide Bedingungen muessen gelten, da eqPrime Veränderungen in allem ausser subst
|
//PL 2018-05-18 beide Bedingungen muessen gelten, da eqPrime Veränderungen in allem ausser subst
|
||||||
//eqPrimePrime Veraenderungen in subst repraesentieren.
|
//eqPrimePrime Veraenderungen in subst repraesentieren.
|
||||||
|
try {
|
||||||
|
if (isSolvedForm(eqPrime)) {
|
||||||
|
logFile.write(eqPrime.toString()+"\n");
|
||||||
|
logFile.flush();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IOException e) { }
|
||||||
eqPrimePrimeSet.add(eqPrime);
|
eqPrimePrimeSet.add(eqPrime);
|
||||||
}
|
}
|
||||||
else if(eqPrimePrime.isPresent()) {
|
else if(eqPrimePrime.isPresent()) {
|
||||||
@ -363,7 +380,8 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
* Step 7: Filter empty sets;
|
* Step 7: Filter empty sets;
|
||||||
*/
|
*/
|
||||||
eqPrimePrimeSet = eqPrimePrimeSet.stream().filter(x -> isSolvedForm(x) || this.isUndefinedPairSet(x)).collect(Collectors.toCollection(HashSet::new));
|
eqPrimePrimeSet = eqPrimePrimeSet.stream().filter(x -> isSolvedForm(x) || this.isUndefinedPairSet(x)).collect(Collectors.toCollection(HashSet::new));
|
||||||
|
if (!eqPrimePrimeSet.isEmpty() && !isUndefinedPairSetSet(eqPrimePrimeSet))
|
||||||
|
writeLog("Result1 " + eqPrimePrimeSet.toString());
|
||||||
return eqPrimePrimeSet;
|
return eqPrimePrimeSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,7 +401,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
Set<Set<UnifyPair>> nextSet = remainingSets.remove(0);
|
Set<Set<UnifyPair>> nextSet = remainingSets.remove(0);
|
||||||
|
writeLog("nextSet: " + nextSet.toString());
|
||||||
List<Set<UnifyPair>> nextSetasList =new ArrayList<>(nextSet);
|
List<Set<UnifyPair>> nextSetasList =new ArrayList<>(nextSet);
|
||||||
try {
|
try {
|
||||||
//List<Set<UnifyPair>>
|
//List<Set<UnifyPair>>
|
||||||
@ -433,9 +451,10 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
System.out.print("");
|
System.out.print("");
|
||||||
if (nextSetasList.iterator().next().stream().filter(x -> x.getLhsType().getName().equals("D")).findFirst().isPresent() && nextSetasList.size()>1)
|
if (nextSetasList.iterator().next().stream().filter(x -> x.getLhsType().getName().equals("D")).findFirst().isPresent() && nextSetasList.size()>1)
|
||||||
System.out.print("");
|
System.out.print("");
|
||||||
|
writeLog("nextSetasList: " + nextSetasList.toString());
|
||||||
|
Set<UnifyPair> a = null;
|
||||||
while (nextSetasList.size() > 0) { //(nextSetasList.size() != 0) {
|
while (nextSetasList.size() > 0) { //(nextSetasList.size() != 0) {
|
||||||
Set<UnifyPair> a = null;
|
Set<UnifyPair> a_last = a;
|
||||||
if (variance == 1) {
|
if (variance == 1) {
|
||||||
a = oup.max(nextSetasList.iterator());
|
a = oup.max(nextSetasList.iterator());
|
||||||
nextSetasList.remove(a);
|
nextSetasList.remove(a);
|
||||||
@ -485,9 +504,57 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
if ((isUndefinedPairSetSet(res) && isUndefinedPairSetSet(result))
|
if ((isUndefinedPairSetSet(res) && isUndefinedPairSetSet(result))
|
||||||
|| (!isUndefinedPairSetSet(res) && !isUndefinedPairSetSet(result))
|
|| (!isUndefinedPairSetSet(res) && !isUndefinedPairSetSet(result))
|
||||||
|| result.isEmpty()) {
|
|| result.isEmpty()) {
|
||||||
|
|
||||||
|
if (!result.isEmpty() && !res.isEmpty() && !isUndefinedPairSetSet(res) && !isUndefinedPairSetSet(result)) {
|
||||||
|
|
||||||
|
//Alle Variablen bestimmen die nicht hinzugefügt wurden in a
|
||||||
|
List<PlaceholderType> vars_a = a.stream().filter(x -> (x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName())
|
||||||
|
||x.getLhsType().getName().equals(x.getBasePair().getRhsType().getName()))).map(y -> (PlaceholderType)y.getLhsType()).collect(Collectors.toCollection(ArrayList::new));
|
||||||
|
Set<UnifyPair> fstElemRes = res.iterator().next();
|
||||||
|
Set<UnifyPair> compRes = fstElemRes.stream().filter(x -> vars_a.contains(((PlaceholderType)x.getLhsType()))).collect(Collectors.toCollection(HashSet::new));
|
||||||
|
|
||||||
|
//Alle Variablen bestimmen die nicht hinzugefügt wurden in a_last
|
||||||
|
List<PlaceholderType> varsLast_a = a_last.stream().filter(x -> (x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName())
|
||||||
|
||x.getLhsType().getName().equals(x.getBasePair().getRhsType().getName()))).map(y -> (PlaceholderType)y.getLhsType()).collect(Collectors.toCollection(ArrayList::new));
|
||||||
|
//erstes Element genügt, da vars immer auf die gleichen Elemente zugeordnet werden muessen
|
||||||
|
Set<UnifyPair> fstElemResult = result.iterator().next();
|
||||||
|
Set<UnifyPair> compResult = fstElemResult.stream().filter(x -> varsLast_a.contains(((PlaceholderType)x.getLhsType()))).collect(Collectors.toCollection(HashSet::new));;
|
||||||
|
|
||||||
|
if (variance == 1) {
|
||||||
|
int resOfCompare = oup.compare(compResult, compRes);
|
||||||
|
if (resOfCompare == -1) {
|
||||||
|
writeLog("Geloescht result: " + result);
|
||||||
|
result = res;
|
||||||
|
} else {
|
||||||
|
if (resOfCompare == 0) {
|
||||||
|
result.addAll(res);
|
||||||
|
} //else {
|
||||||
|
if (resOfCompare == 1) {
|
||||||
|
writeLog("Geloescht res: " + res);
|
||||||
|
//result = result;
|
||||||
|
}}}
|
||||||
|
else { if (variance == -1) {
|
||||||
|
int resOfCompare = oup.compare(compResult, compRes);
|
||||||
|
if (resOfCompare == 1) {
|
||||||
|
writeLog("Geloescht result: " + result);
|
||||||
|
result = res;
|
||||||
|
} else {
|
||||||
|
if (resOfCompare == 0) {
|
||||||
|
result.addAll(res);
|
||||||
|
} else {
|
||||||
|
if (resOfCompare == -1) {
|
||||||
|
writeLog("Geloescht res: " + res);
|
||||||
|
//result = result;
|
||||||
|
}}}}
|
||||||
|
else { if (variance == 0) {
|
||||||
|
result.addAll(res);
|
||||||
|
}}}
|
||||||
//alle Fehlerfaelle und alle korrekten Ergebnis jeweils adden
|
//alle Fehlerfaelle und alle korrekten Ergebnis jeweils adden
|
||||||
result.addAll(res);
|
}
|
||||||
}
|
else {
|
||||||
|
result.addAll(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
//else {
|
//else {
|
||||||
//wenn Korrekte Ergebnisse da und Feherfälle dazukommen Fehlerfälle ignorieren
|
//wenn Korrekte Ergebnisse da und Feherfälle dazukommen Fehlerfälle ignorieren
|
||||||
// if (isUndefinedPairSetSet(res) && !isUndefinedPairSetSet(result)) {
|
// if (isUndefinedPairSetSet(res) && !isUndefinedPairSetSet(result)) {
|
||||||
@ -505,7 +572,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
if (!result.isEmpty() && !isUndefinedPairSetSet(res)) {
|
if (!result.isEmpty() && !isUndefinedPairSetSet(res)) {
|
||||||
if (nextSetasList.iterator().hasNext() && nextSetasList.iterator().next().stream().filter(x -> x.getLhsType().getName().equals("B")).findFirst().isPresent() && nextSetasList.size()>1)
|
if (nextSetasList.iterator().hasNext() && nextSetasList.iterator().next().stream().filter(x -> x.getLhsType().getName().equals("B")).findFirst().isPresent() && nextSetasList.size()>1)
|
||||||
System.out.print("");
|
System.out.print("");
|
||||||
Iterator<Set<UnifyPair>> nextSetasListIt = new ArrayList<Set<UnifyPair>>(nextSetasList).iterator();
|
Iterator<Set<UnifyPair>> nextSetasListIt = new ArrayList<Set<UnifyPair>>(nextSetasList).iterator();
|
||||||
if (variance == 1) {
|
if (variance == 1) {
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
while (nextSetasListIt.hasNext()) {
|
while (nextSetasListIt.hasNext()) {
|
||||||
@ -570,11 +637,25 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
// ret = ret || x.stream().map(b -> b.getLhsType().equals(var)).reduce((c,d) -> c || d).get();
|
// ret = ret || x.stream().map(b -> b.getLhsType().equals(var)).reduce((c,d) -> c || d).get();
|
||||||
//}
|
//}
|
||||||
return (!x.containsAll(durchschnitt));
|
return (!x.containsAll(durchschnitt));
|
||||||
}).collect(Collectors.toCollection(ArrayList::new));
|
})//.filter(y -> couldBecorrect(reducedUndefResSubstGroundedBasePair, y)) //fuer testzwecke auskommentiert um nofstred zu bestimmen PL 2018-10-10
|
||||||
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
|
nofstred = nextSetasList.size();
|
||||||
|
//NOCH NICHT korrekt PL 2018-10-12
|
||||||
|
//nextSetasList = nextSetasList.stream().filter(y -> couldBecorrect(reducedUndefResSubstGroundedBasePair, y))
|
||||||
|
// .collect(Collectors.toCollection(ArrayList::new));
|
||||||
|
writeLog("res (undef): " + res.toString());
|
||||||
|
writeLog("abhSubst: " + abhSubst.toString());
|
||||||
|
writeLog("a: " + a.toString());
|
||||||
|
writeLog("Durchschnitt: " + durchschnitt.toString());
|
||||||
|
writeLog("nextSet: " + nextSet.toString());
|
||||||
|
writeLog("nextSetasList: " + nextSetasList.toString());
|
||||||
|
writeLog("Number first erased Elements (undef): " + (len - nofstred));
|
||||||
|
writeLog("Number second erased Elements (undef): " + (nofstred- nextSetasList.size()));
|
||||||
|
writeLog("Number erased Elements (undef): " + (len - nextSetasList.size()));
|
||||||
noAllErasedElements = noAllErasedElements + (len - nextSetasList.size());
|
noAllErasedElements = noAllErasedElements + (len - nextSetasList.size());
|
||||||
|
writeLog("Number of all erased Elements (undef): " + noAllErasedElements.toString());
|
||||||
noBacktracking++;
|
noBacktracking++;
|
||||||
|
writeLog("Number of Backtracking: " + noBacktracking);
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
}
|
}
|
||||||
//if (nextSetasList.size() == 0 && isUndefinedPairSetSet(result) && nextSet.size() > 1) {
|
//if (nextSetasList.size() == 0 && isUndefinedPairSetSet(result) && nextSet.size() > 1) {
|
||||||
@ -667,6 +748,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
// Through application of the rules, every pair should have one of the above forms.
|
// Through application of the rules, every pair should have one of the above forms.
|
||||||
// Pairs that do not have one of the aboves form are contradictory.
|
// Pairs that do not have one of the aboves form are contradictory.
|
||||||
else {
|
else {
|
||||||
|
writeLog("Second erase:" +checkPair.toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//*/
|
//*/
|
||||||
@ -1111,7 +1193,7 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
Set<UnifyPair> resultPrime = new HashSet<>();
|
Set<UnifyPair> resultPrime = new HashSet<>();
|
||||||
|
|
||||||
for(int i = 0; !allGen && i < theta.getTypeParams().size(); i++) {
|
for(int i = 0; !allGen && i < theta.getTypeParams().size(); i++) {
|
||||||
if(freshTphs.size()-1 < i)
|
if(freshTphs.size()-1 < i)//IST DAS RICHTIG??? PL 2018-12-12
|
||||||
freshTphs.add(PlaceholderType.freshPlaceholder());
|
freshTphs.add(PlaceholderType.freshPlaceholder());
|
||||||
resultPrime.add(new UnifyPair(freshTphs.get(i), theta.getTypeParams().get(i), PairOperator.SMALLERDOTWC, pair.getSubstitution(), pair));
|
resultPrime.add(new UnifyPair(freshTphs.get(i), theta.getTypeParams().get(i), PairOperator.SMALLERDOTWC, pair.getSubstitution(), pair));
|
||||||
}
|
}
|
||||||
@ -1321,4 +1403,15 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
permuteParams(candidates, idx+1, result, current);
|
permuteParams(candidates, idx+1, result, current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void writeLog(String str) {
|
||||||
|
if (log) {
|
||||||
|
try {
|
||||||
|
logFile.write(str+"\n");
|
||||||
|
logFile.flush();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (IOException e) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import java.util.Arrays;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
@ -26,7 +27,8 @@ import de.dhbwstuttgart.typeinference.unify.interfaces.IUnify;
|
|||||||
* The finite closure for the type unification
|
* The finite closure for the type unification
|
||||||
* @author Florian Steurer
|
* @author Florian Steurer
|
||||||
*/
|
*/
|
||||||
public class FiniteClosure extends Ordering<UnifyType> implements IFiniteClosure {
|
public class FiniteClosure //extends Ordering<UnifyType> //entfernt PL 2018-12-11
|
||||||
|
implements IFiniteClosure {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A map that maps every type to the node in the inheritance graph that contains that type.
|
* A map that maps every type to the node in the inheritance graph that contains that type.
|
||||||
@ -561,14 +563,53 @@ public class FiniteClosure extends Ordering<UnifyType> implements IFiniteClosure
|
|||||||
return this.inheritanceGraph.toString();
|
return this.inheritanceGraph.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* entfernt PL 2018-12-11
|
||||||
public int compare (UnifyType left, UnifyType right) {
|
public int compare (UnifyType left, UnifyType right) {
|
||||||
return compare(left, right, PairOperator.SMALLERDOT);
|
return compare(left, right, PairOperator.SMALLERDOT);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public int compare (UnifyType left, UnifyType right, PairOperator pairop) {
|
public int compare (UnifyType left, UnifyType right, PairOperator pairop) {
|
||||||
if ((left instanceof ExtendsType && right instanceof ReferenceType)
|
if ((left instanceof ExtendsType && right instanceof ReferenceType)
|
||||||
|| (right instanceof ExtendsType && left instanceof ReferenceType))
|
|| (right instanceof ExtendsType && left instanceof ReferenceType))
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
|
/*
|
||||||
|
List<UnifyType> al = new ArrayList<>();
|
||||||
|
PlaceholderType xx =new PlaceholderType("xx");
|
||||||
|
al.add(xx);
|
||||||
|
left = new ExtendsType(new ReferenceType("Vector", new TypeParams(al)));
|
||||||
|
right = new ReferenceType("Vector", new TypeParams(new ArrayList<>(al)));
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
List<UnifyType> al = new ArrayList<>();
|
||||||
|
PlaceholderType xx =new PlaceholderType("xx");
|
||||||
|
al.add(xx);
|
||||||
|
left = new ExtendsType(xx);
|
||||||
|
right = xx;
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
List<UnifyType> al = new ArrayList<>();
|
||||||
|
PlaceholderType xx =new PlaceholderType("xx");
|
||||||
|
PlaceholderType yy =new PlaceholderType("yy");
|
||||||
|
al.add(xx);
|
||||||
|
left = yy;
|
||||||
|
right = new ExtendsType(xx);
|
||||||
|
*/
|
||||||
|
//Die Faelle abfangen, bei den Variablen verglichen werden PL 2018-12-11
|
||||||
|
UnifyType ex;
|
||||||
|
if (left instanceof PlaceholderType) {
|
||||||
|
if ((right instanceof WildcardType)
|
||||||
|
&& ((ex = ((WildcardType)right).wildcardedType) instanceof PlaceholderType)
|
||||||
|
&& ((PlaceholderType)left).getName().equals(((PlaceholderType)ex).getName())) {// a <.? ? extends a oder a <.? ? super a
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((right instanceof PlaceholderType) && (left instanceof WildcardType)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
UnifyPair up = new UnifyPair(left, right, pairop);
|
UnifyPair up = new UnifyPair(left, right, pairop);
|
||||||
TypeUnifyTask unifyTask = new TypeUnifyTask();
|
TypeUnifyTask unifyTask = new TypeUnifyTask();
|
||||||
HashSet<UnifyPair> hs = new HashSet<>();
|
HashSet<UnifyPair> hs = new HashSet<>();
|
||||||
|
@ -151,7 +151,7 @@ public class OrderingUnifyPair extends Ordering<Set<UnifyPair>> {
|
|||||||
System.out.print("");
|
System.out.print("");
|
||||||
//Set<PlaceholderType> varsleft = lefteq.stream().map(x -> (PlaceholderType)x.getLhsType()).collect(Collectors.toCollection(HashSet::new));
|
//Set<PlaceholderType> varsleft = lefteq.stream().map(x -> (PlaceholderType)x.getLhsType()).collect(Collectors.toCollection(HashSet::new));
|
||||||
//Set<PlaceholderType> varsright = righteq.stream().map(x -> (PlaceholderType)x.getLhsType()).collect(Collectors.toCollection(HashSet::new));
|
//Set<PlaceholderType> varsright = righteq.stream().map(x -> (PlaceholderType)x.getLhsType()).collect(Collectors.toCollection(HashSet::new));
|
||||||
//filtern des Paares a = Theta, das durch a <. Thata' generiert wurde (nur im Fall 1 relevant)
|
//filtern des Paares a = Theta, das durch a <. Thata' generiert wurde (nur im Fall 1 relevant) andere Substitutioen werden rausgefiltert
|
||||||
lefteq.removeIf(x -> !(x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName())
|
lefteq.removeIf(x -> !(x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName())
|
||||||
||x.getLhsType().getName().equals(x.getBasePair().getRhsType().getName())));//removeIf(x -> !varsright.contains(x.getLhsType()));
|
||x.getLhsType().getName().equals(x.getBasePair().getRhsType().getName())));//removeIf(x -> !varsright.contains(x.getLhsType()));
|
||||||
righteq.removeIf(x -> !(x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName())
|
righteq.removeIf(x -> !(x.getLhsType().getName().equals(x.getBasePair().getLhsType().getName())
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package de.dhbwstuttgart.typeinference.unify.model;
|
package de.dhbwstuttgart.typeinference.unify.model;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -21,7 +23,7 @@ public final class PlaceholderType extends UnifyType{
|
|||||||
* Static list containing the names of all existing placeholders.
|
* Static list containing the names of all existing placeholders.
|
||||||
* Used for generating fresh placeholders.
|
* Used for generating fresh placeholders.
|
||||||
*/
|
*/
|
||||||
protected static final HashSet<String> EXISTING_PLACEHOLDERS = new HashSet<String>();
|
public static final ArrayList<String> EXISTING_PLACEHOLDERS = new ArrayList<String>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prefix of auto-generated placeholder names.
|
* Prefix of auto-generated placeholder names.
|
||||||
@ -81,11 +83,12 @@ public final class PlaceholderType extends UnifyType{
|
|||||||
* A user could later instantiate a type using the same name that is equivalent to this type.
|
* A user could later instantiate a type using the same name that is equivalent to this type.
|
||||||
* @return A fresh placeholder type.
|
* @return A fresh placeholder type.
|
||||||
*/
|
*/
|
||||||
public static PlaceholderType freshPlaceholder() {
|
public synchronized static PlaceholderType freshPlaceholder() {
|
||||||
String name = nextName + (char) (rnd.nextInt(22) + 97); // Returns random char between 'a' and 'z'
|
String name = nextName + (char) (rnd.nextInt(22) + 97); // Returns random char between 'a' and 'z'
|
||||||
// Add random chars while the name is in use.
|
// Add random chars while the name is in use.
|
||||||
while(EXISTING_PLACEHOLDERS.contains(name));
|
while(EXISTING_PLACEHOLDERS.contains(name)) {
|
||||||
name += (char) (rnd.nextInt(22) + 97); // Returns random char between 'a' and 'z'
|
name += (char) (rnd.nextInt(22) + 97); // Returns random char between 'a' and 'z'
|
||||||
|
}
|
||||||
return new PlaceholderType(name, true);
|
return new PlaceholderType(name, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,9 +12,6 @@ import de.dhbwstuttgart.typeinference.constraints.ConstraintSet;
|
|||||||
import de.dhbwstuttgart.typeinference.constraints.Pair;
|
import de.dhbwstuttgart.typeinference.constraints.Pair;
|
||||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
|
import de.dhbwstuttgart.typeinference.unify.model.PairOperator;
|
||||||
//import jdk.jfr.StackTrace;
|
|
||||||
|
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import javax.json.Json;
|
import javax.json.Json;
|
||||||
@ -25,13 +22,11 @@ import java.util.*;
|
|||||||
public class ClingoTest {
|
public class ClingoTest {
|
||||||
public static final String tempDirectory = "/tmp/";
|
public static final String tempDirectory = "/tmp/";
|
||||||
private final TypePlaceholder testType = TypePlaceholder.fresh(new NullToken());
|
private final TypePlaceholder testType = TypePlaceholder.fresh(new NullToken());
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void test() throws IOException, InterruptedException, ClassNotFoundException {
|
public void test() throws IOException, InterruptedException, ClassNotFoundException {
|
||||||
String content = "";
|
String content = "";
|
||||||
content = ASPFactory.generateASP(this.getPairs(), this.getFC());
|
content = ASPFactory.generateASP(this.getPairs(), this.getFC());
|
||||||
|
|
||||||
PrintWriter writer = new PrintWriter(tempDirectory + "test.lp", "UTF-8");
|
PrintWriter writer = new PrintWriter(tempDirectory + "test.lp", "UTF-8");
|
||||||
writer.println(content);
|
writer.println(content);
|
||||||
writer.close();
|
writer.close();
|
||||||
|
@ -27,7 +27,6 @@ import java.io.PrintWriter;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ArrayBlockingQueue;
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
|
|
||||||
@Ignore
|
|
||||||
public class GeneratorTest extends UnifyWithoutWildcards{
|
public class GeneratorTest extends UnifyWithoutWildcards{
|
||||||
@Test
|
@Test
|
||||||
public void simple() throws ClassNotFoundException {
|
public void simple() throws ClassNotFoundException {
|
||||||
|
@ -13,37 +13,38 @@ import org.junit.Test;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class BinaryTest {
|
public class BinaryTest {
|
||||||
private static String path;
|
private static String path;
|
||||||
private static File fileToTest;
|
private static File fileToTest;
|
||||||
private static JavaTXCompiler compiler;
|
private static JavaTXCompiler compiler;
|
||||||
private static ClassLoader loader;
|
private static ClassLoader loader;
|
||||||
private static Class<?> classToTest;
|
private static Class<?> classToTest;
|
||||||
private static String pathToClassFile;
|
private static String pathToClassFile;
|
||||||
private static Object instanceOfClass;
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/BinaryInMeth.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
compiler.generateBytecode(pathToClassFile);
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("BinaryInMeth");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@Test
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public void test() throws Exception {
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/BinaryInMeth.jav";
|
Method m2 = classToTest.getDeclaredMethod("m2", Integer.class,Integer.class);
|
||||||
fileToTest = new File(path);
|
Integer res = (Integer) m2.invoke(instanceOfClass, 2,3);
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
assertEquals(6, res);
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
}
|
||||||
compiler.generateBytecode(pathToClassFile);
|
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
@Test
|
||||||
classToTest = loader.loadClass("BinaryInMeth");
|
public void testM3() throws Exception {
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
Method m3 = classToTest.getDeclaredMethod("m3", Integer.class);
|
||||||
}
|
Integer res = (Integer) m3.invoke(instanceOfClass, 2);
|
||||||
|
assertEquals(4, res);
|
||||||
@Test
|
}
|
||||||
public void test() throws Exception {
|
|
||||||
Method m2 = classToTest.getDeclaredMethod("m2", Integer.class,Integer.class);
|
|
||||||
Integer res = (Integer) m2.invoke(instanceOfClass, 2,3);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testM3() throws Exception {
|
|
||||||
Method m3 = classToTest.getDeclaredMethod("m3", Integer.class);
|
|
||||||
Integer res = (Integer) m3.invoke(instanceOfClass, 2);
|
|
||||||
assertEquals(Integer.valueOf(4), res);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,31 +14,31 @@ import org.junit.Test;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class FacTest {
|
public class FacTest {
|
||||||
private static String path;
|
private static String path;
|
||||||
private static File fileToTest;
|
private static File fileToTest;
|
||||||
private static JavaTXCompiler compiler;
|
private static JavaTXCompiler compiler;
|
||||||
private static ClassLoader loader;
|
private static ClassLoader loader;
|
||||||
private static Class<?> classToTest;
|
private static Class<?> classToTest;
|
||||||
private static String pathToClassFile;
|
private static String pathToClassFile;
|
||||||
private static Object instanceOfClass;
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public static void setUpBeforeClass() throws Exception {
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/Fac.jav";
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/Fac.jav";
|
||||||
fileToTest = new File(path);
|
fileToTest = new File(path);
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
compiler.generateBytecode(pathToClassFile);
|
compiler.generateBytecode(pathToClassFile);
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
classToTest = loader.loadClass("Fac");
|
classToTest = loader.loadClass("Fac");
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInteger() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
public void testInteger() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Method getFac = classToTest.getDeclaredMethod("getFac", Integer.class);
|
Method getFac = classToTest.getDeclaredMethod("getFac", Integer.class);
|
||||||
Integer result = (Integer) getFac.invoke(instanceOfClass,3);
|
Integer result = (Integer) getFac.invoke(instanceOfClass,3);
|
||||||
assertEquals(result, Integer.valueOf(6));
|
assertEquals(result, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,41 +14,45 @@ import org.junit.Test;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class FacultyTest {
|
public class FacultyTest {
|
||||||
private static String path;
|
private static String path;
|
||||||
private static File fileToTest;
|
private static File fileToTest;
|
||||||
private static JavaTXCompiler compiler;
|
private static JavaTXCompiler compiler;
|
||||||
private static ClassLoader loader;
|
private static ClassLoader loader;
|
||||||
private static Class<?> classToTest;
|
private static Class<?> classToTest;
|
||||||
private static String pathToClassFile;
|
private static String pathToClassFile;
|
||||||
private static Object instanceOfClass;
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void generateBC() throws Exception {
|
public void generateBC() throws Exception {
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/Faculty.jav";
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/Faculty.jav";
|
||||||
fileToTest = new File(path);
|
fileToTest = new File(path);
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
classToTest = loader.loadClass("Faculty");
|
classToTest = loader.loadClass("Faculty");
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
|
||||||
// Method m = classToTest.getDeclaredMethod("m", Integer.class);
|
Method getFact = classToTest.getDeclaredMethod("getFact", Integer.class);
|
||||||
Field fact = classToTest.getDeclaredField("fact");
|
// Field fact = classToTest.getDeclaredField("fact");
|
||||||
// Class<?> lambda = m.invoke(instanceOfClass).getClass();
|
// Class<?> lambda = m.invoke(instanceOfClass).getClass();
|
||||||
Class<?> lambda = fact.getType();
|
// Class<?> lambda = fact.getType();
|
||||||
Method apply = lambda.getMethod("apply", Object.class);
|
// System.out.println(fact.getType().getName());
|
||||||
//
|
// Method apply = lambda.getMethod("apply", Object.class);
|
||||||
|
// System.out.println(lambda.getMethods()[0]);
|
||||||
|
// System.out.println(instanceOfClass.toString());
|
||||||
// // Damit man auf die Methode zugreifen kann
|
// // Damit man auf die Methode zugreifen kann
|
||||||
apply.setAccessible(true);
|
// apply.setAccessible(true);
|
||||||
|
// Field value
|
||||||
|
// Object fieldVal = fact.get(instanceOfClass);
|
||||||
|
Integer i = 3;
|
||||||
|
// Method applyFromField = fieldVal.getClass().getDeclaredMethod("apply", Object.class);
|
||||||
|
// applyFromField.setAccessible(true);
|
||||||
|
// Integer result = (Integer) apply.invoke(lambda,i);
|
||||||
|
Integer result = (Integer) getFact.invoke(instanceOfClass,i);
|
||||||
|
|
||||||
Integer i = 3;
|
assertEquals(6, result);
|
||||||
|
}
|
||||||
Integer result = (Integer) apply.invoke(instanceOfClass, i);
|
|
||||||
// Integer result = (Integer) m.invoke(instanceOfClass,i);
|
|
||||||
|
|
||||||
assertEquals(Integer.valueOf(6), result);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,31 +13,31 @@ import java.net.URLClassLoader;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class FieldTest {
|
public class FieldTest {
|
||||||
|
|
||||||
|
private static String path;
|
||||||
|
private static File fileToTest;
|
||||||
|
private static JavaTXCompiler compiler;
|
||||||
|
private static ClassLoader loader;
|
||||||
|
private static Class<?> classToTest;
|
||||||
|
private static String pathToClassFile;
|
||||||
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/Field.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("Field");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
private static String path;
|
@Test
|
||||||
private static File fileToTest;
|
public void test() {
|
||||||
private static JavaTXCompiler compiler;
|
Field[] fields = classToTest.getFields();
|
||||||
private static ClassLoader loader;
|
assertEquals(1, fields.length);
|
||||||
private static Class<?> classToTest;
|
}
|
||||||
private static String pathToClassFile;
|
|
||||||
private static Object instanceOfClass;
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void setUpBeforeClass() throws Exception {
|
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/Field.jav";
|
|
||||||
fileToTest = new File(path);
|
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
|
||||||
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
|
||||||
classToTest = loader.loadClass("Field");
|
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
Field[] fields = classToTest.getFields();
|
|
||||||
assertEquals(1, fields.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
43
src/test/java/bytecode/FieldTph.java
Normal file
43
src/test/java/bytecode/FieldTph.java
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package bytecode;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
|
public class FieldTph {
|
||||||
|
|
||||||
|
private static String path;
|
||||||
|
private static File fileToTest;
|
||||||
|
private static JavaTXCompiler compiler;
|
||||||
|
private static ClassLoader loader;
|
||||||
|
private static Class<?> classToTest;
|
||||||
|
private static String pathToClassFile;
|
||||||
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/FieldTph.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("FieldTph");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() {
|
||||||
|
Field[] fields = classToTest.getFields();
|
||||||
|
assertEquals(1, fields.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
52
src/test/java/bytecode/FieldTph2Test.java
Normal file
52
src/test/java/bytecode/FieldTph2Test.java
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
package bytecode;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
|
public class FieldTph2Test {
|
||||||
|
|
||||||
|
private static String path;
|
||||||
|
private static File fileToTest;
|
||||||
|
private static JavaTXCompiler compiler;
|
||||||
|
private static ClassLoader loader;
|
||||||
|
private static Class<?> classToTest;
|
||||||
|
private static String pathToClassFile;
|
||||||
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/FieldTph2.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("FieldTph2");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() throws Exception {
|
||||||
|
Field a = classToTest.getDeclaredField("a");
|
||||||
|
a.setAccessible(true);
|
||||||
|
|
||||||
|
Method m2 = classToTest.getDeclaredMethod("m2", Object.class);
|
||||||
|
m2.invoke(instanceOfClass, 1);
|
||||||
|
|
||||||
|
Method m = classToTest.getDeclaredMethod("m", Object.class);
|
||||||
|
Object result = m.invoke(instanceOfClass, 1);
|
||||||
|
|
||||||
|
assertEquals(1,result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
49
src/test/java/bytecode/FieldTphConsMethTest.java
Normal file
49
src/test/java/bytecode/FieldTphConsMethTest.java
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package bytecode;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
|
public class FieldTphConsMethTest {
|
||||||
|
|
||||||
|
private static String path;
|
||||||
|
private static File fileToTest;
|
||||||
|
private static JavaTXCompiler compiler;
|
||||||
|
private static ClassLoader loader;
|
||||||
|
private static Class<?> classToTest;
|
||||||
|
private static String pathToClassFile;
|
||||||
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/FieldTphConsMeth.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("FieldTphConsMeth");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() throws Exception {
|
||||||
|
Field a = classToTest.getDeclaredField("a");
|
||||||
|
a.setAccessible(true);
|
||||||
|
|
||||||
|
Method m = classToTest.getDeclaredMethod("m", Object.class);
|
||||||
|
Object result = m.invoke(instanceOfClass, 42);
|
||||||
|
|
||||||
|
assertEquals(42,result);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -13,40 +13,40 @@ import org.junit.Test;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class FunOLTest {
|
public class FunOLTest {
|
||||||
private static String path;
|
private static String path;
|
||||||
private static File fileToTest;
|
private static File fileToTest;
|
||||||
private static JavaTXCompiler compiler;
|
private static JavaTXCompiler compiler;
|
||||||
private static ClassLoader loader;
|
private static ClassLoader loader;
|
||||||
private static Class<?> classToTest;
|
private static Class<?> classToTest;
|
||||||
private static String pathToClassFile;
|
private static String pathToClassFile;
|
||||||
private static Object instanceOfClass;
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void generateBC() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/FunOL.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("FunOL");
|
||||||
|
/*
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
|
||||||
@Test
|
Method m = classToTest.getDeclaredMethod("m");
|
||||||
public void generateBC() throws Exception {
|
Class<?> lambda = m.invoke(instanceOfClass).getClass();
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/FunOL.jav";
|
Method apply = lambda.getMethod("apply", Object.class);
|
||||||
fileToTest = new File(path);
|
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
|
||||||
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
|
||||||
classToTest = loader.loadClass("FunOL");
|
|
||||||
/*
|
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
|
||||||
|
|
||||||
Method m = classToTest.getDeclaredMethod("m");
|
// Damit man auf die Methode zugreifen kann
|
||||||
Class<?> lambda = m.invoke(instanceOfClass).getClass();
|
apply.setAccessible(true);
|
||||||
Method apply = lambda.getMethod("apply", Object.class);
|
|
||||||
|
|
||||||
// Damit man auf die Methode zugreifen kann
|
Integer i = 77;
|
||||||
apply.setAccessible(true);
|
|
||||||
|
Integer result = (Integer) apply.invoke(m.invoke(instanceOfClass), i);
|
||||||
|
|
||||||
Integer i = 77;
|
assertEquals(77, result);
|
||||||
|
*/
|
||||||
Integer result = (Integer) apply.invoke(m.invoke(instanceOfClass), i);
|
}
|
||||||
|
|
||||||
assertEquals(77, result);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,18 +13,18 @@ import de.dhbwstuttgart.core.JavaTXCompiler;
|
|||||||
|
|
||||||
public class GenTest {
|
public class GenTest {
|
||||||
|
|
||||||
private static String path;
|
private static String path;
|
||||||
private static File fileToTest;
|
private static File fileToTest;
|
||||||
private static JavaTXCompiler compiler;
|
private static JavaTXCompiler compiler;
|
||||||
private static String pathToClassFile;
|
private static String pathToClassFile;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void generateBC() throws Exception {
|
public void generateBC() throws Exception {
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/Gen.jav";
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/Gen.jav";
|
||||||
fileToTest = new File(path);
|
fileToTest = new File(path);
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
compiler.generateBytecode(pathToClassFile);
|
compiler.generateBytecode(pathToClassFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,126 +15,126 @@ import de.dhbwstuttgart.core.JavaTXCompiler;
|
|||||||
|
|
||||||
public class GreaterEqualTest {
|
public class GreaterEqualTest {
|
||||||
|
|
||||||
private static String path;
|
private static String path;
|
||||||
private static File fileToTest;
|
private static File fileToTest;
|
||||||
private static JavaTXCompiler compiler;
|
private static JavaTXCompiler compiler;
|
||||||
private static ClassLoader loader;
|
private static ClassLoader loader;
|
||||||
private static Class<?> classToTest;
|
private static Class<?> classToTest;
|
||||||
private static String pathToClassFile;
|
private static String pathToClassFile;
|
||||||
private static Object instanceOfClass;
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/GreaterEqual.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
compiler.generateBytecode(pathToClassFile);
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("File://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("GreaterEqual");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@Test
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public void testName() {
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/GreaterEqual.jav";
|
assertEquals("GreaterEqual", classToTest.getName());
|
||||||
fileToTest = new File(path);
|
}
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
@Test
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
public void testIntegers() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
compiler.generateBytecode(pathToClassFile);
|
Method gE = classToTest.getDeclaredMethod("gE", Integer.class, Integer.class);
|
||||||
loader = new URLClassLoader(new URL[] {new URL("File://"+pathToClassFile)});
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 7, 5);
|
||||||
classToTest = loader.loadClass("GreaterEqual");
|
assertTrue(result);
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
|
public void testIntegers2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gE = classToTest.getDeclaredMethod("gE", Integer.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 5, 7);
|
||||||
|
assertFalse(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testEqIntegers() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gE = classToTest.getDeclaredMethod("gE", Integer.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 5, 5);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLongs() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method gE = classToTest.getDeclaredMethod("gE", Long.class, Long.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 10L,7L);
|
||||||
|
assertTrue(result);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testName() {
|
public void testFloats() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
assertEquals("GreaterEqual", classToTest.getName());
|
Method gE = classToTest.getDeclaredMethod("gE", Float.class, Float.class);
|
||||||
}
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 5F,7F);
|
||||||
@Test
|
assertFalse(result);
|
||||||
public void testIntegers() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
}
|
||||||
Method gE = classToTest.getDeclaredMethod("gE", Integer.class, Integer.class);
|
|
||||||
Boolean result = (Boolean) gE.invoke(instanceOfClass, 7, 5);
|
@Test
|
||||||
assertTrue(result);
|
public void testDoubles() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
}
|
Method gE = classToTest.getDeclaredMethod("gE", Double.class, Double.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 5.0,7.0);
|
||||||
@Test
|
assertFalse(result);
|
||||||
public void testIntegers2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
}
|
||||||
Method gE = classToTest.getDeclaredMethod("gE", Integer.class, Integer.class);
|
|
||||||
Boolean result = (Boolean) gE.invoke(instanceOfClass, 5, 7);
|
@Test
|
||||||
assertFalse(result);
|
public void testLongInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
}
|
Method gE = classToTest.getDeclaredMethod("gE", Long.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 15L,7);
|
||||||
@Test
|
assertTrue(result);
|
||||||
public void testEqIntegers() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
}
|
||||||
Method gE = classToTest.getDeclaredMethod("gE", Integer.class, Integer.class);
|
|
||||||
Boolean result = (Boolean) gE.invoke(instanceOfClass, 5, 5);
|
@Test
|
||||||
assertTrue(result);
|
public void testFloatInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
}
|
Method gE = classToTest.getDeclaredMethod("gE", Float.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 5F,7);
|
||||||
@Test
|
assertFalse(result);
|
||||||
public void testLongs() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
}
|
||||||
Method gE = classToTest.getDeclaredMethod("gE", Long.class, Long.class);
|
|
||||||
Boolean result = (Boolean) gE.invoke(instanceOfClass, 10L,7L);
|
@Test
|
||||||
assertTrue(result);
|
public void testDoubleInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
}
|
Method gE = classToTest.getDeclaredMethod("gE", Double.class, Integer.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 25.0,17);
|
||||||
@Test
|
assertTrue(result);
|
||||||
public void testFloats() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
}
|
||||||
Method gE = classToTest.getDeclaredMethod("gE", Float.class, Float.class);
|
|
||||||
Boolean result = (Boolean) gE.invoke(instanceOfClass, 5F,7F);
|
@Test
|
||||||
assertFalse(result);
|
public void testFloatLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
}
|
Method gE = classToTest.getDeclaredMethod("gE", Float.class, Long.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 75F,70L);
|
||||||
@Test
|
assertTrue(result);
|
||||||
public void testDoubles() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
}
|
||||||
Method gE = classToTest.getDeclaredMethod("gE", Double.class, Double.class);
|
|
||||||
Boolean result = (Boolean) gE.invoke(instanceOfClass, 5.0,7.0);
|
@Test
|
||||||
assertFalse(result);
|
public void testDoubleLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
}
|
Method gE = classToTest.getDeclaredMethod("gE", Double.class, Long.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 5.0,7L);
|
||||||
@Test
|
assertFalse(result);
|
||||||
public void testLongInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
}
|
||||||
Method gE = classToTest.getDeclaredMethod("gE", Long.class, Integer.class);
|
|
||||||
Boolean result = (Boolean) gE.invoke(instanceOfClass, 15L,7);
|
@Test
|
||||||
assertTrue(result);
|
public void testEqDoubleFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
}
|
Method gE = classToTest.getDeclaredMethod("gE", Double.class, Float.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 7.0,7F);
|
||||||
@Test
|
assertTrue(result);
|
||||||
public void testFloatInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
}
|
||||||
Method gE = classToTest.getDeclaredMethod("gE", Float.class, Integer.class);
|
|
||||||
Boolean result = (Boolean) gE.invoke(instanceOfClass, 5F,7);
|
@Test
|
||||||
assertFalse(result);
|
public void testDoubleFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
}
|
Method gE = classToTest.getDeclaredMethod("gE", Double.class, Float.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 15.0,7F);
|
||||||
@Test
|
assertTrue(result);
|
||||||
public void testDoubleInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
}
|
||||||
Method gE = classToTest.getDeclaredMethod("gE", Double.class, Integer.class);
|
|
||||||
Boolean result = (Boolean) gE.invoke(instanceOfClass, 25.0,17);
|
@Test
|
||||||
assertTrue(result);
|
public void testDoubleFloat3() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
}
|
Method gE = classToTest.getDeclaredMethod("gE", Double.class, Float.class);
|
||||||
|
Boolean result = (Boolean) gE.invoke(instanceOfClass, 9.0,17F);
|
||||||
@Test
|
assertFalse(result);
|
||||||
public void testFloatLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
}
|
||||||
Method gE = classToTest.getDeclaredMethod("gE", Float.class, Long.class);
|
|
||||||
Boolean result = (Boolean) gE.invoke(instanceOfClass, 75F,70L);
|
|
||||||
assertTrue(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDoubleLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method gE = classToTest.getDeclaredMethod("gE", Double.class, Long.class);
|
|
||||||
Boolean result = (Boolean) gE.invoke(instanceOfClass, 5.0,7L);
|
|
||||||
assertFalse(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testEqDoubleFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method gE = classToTest.getDeclaredMethod("gE", Double.class, Float.class);
|
|
||||||
Boolean result = (Boolean) gE.invoke(instanceOfClass, 7.0,7F);
|
|
||||||
assertTrue(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDoubleFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method gE = classToTest.getDeclaredMethod("gE", Double.class, Float.class);
|
|
||||||
Boolean result = (Boolean) gE.invoke(instanceOfClass, 15.0,7F);
|
|
||||||
assertTrue(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDoubleFloat3() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method gE = classToTest.getDeclaredMethod("gE", Double.class, Float.class);
|
|
||||||
Boolean result = (Boolean) gE.invoke(instanceOfClass, 9.0,17F);
|
|
||||||
assertFalse(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,125 +15,125 @@ import de.dhbwstuttgart.core.JavaTXCompiler;
|
|||||||
|
|
||||||
public class GreaterThanTest {
|
public class GreaterThanTest {
|
||||||
|
|
||||||
private static String path;
|
private static String path;
|
||||||
private static File fileToTest;
|
private static File fileToTest;
|
||||||
private static JavaTXCompiler compiler;
|
private static JavaTXCompiler compiler;
|
||||||
private static ClassLoader loader;
|
private static ClassLoader loader;
|
||||||
private static Class<?> classToTest;
|
private static Class<?> classToTest;
|
||||||
private static String pathToClassFile;
|
private static String pathToClassFile;
|
||||||
private static Object instanceOfClass;
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/GreaterThan.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
compiler.generateBytecode(pathToClassFile);
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("File://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("GreaterThan");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@Test
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public void testName() {
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/GreaterThan.jav";
|
assertEquals("GreaterThan", classToTest.getName());
|
||||||
fileToTest = new File(path);
|
}
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
public void testIntegers() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
compiler.generateBytecode(pathToClassFile);
|
Method gT = classToTest.getDeclaredMethod("gT", Integer.class, Integer.class);
|
||||||
loader = new URLClassLoader(new URL[] {new URL("File://"+pathToClassFile)});
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 7, 5);
|
||||||
classToTest = loader.loadClass("GreaterThan");
|
assertTrue(result);
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testIntegers2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
public void testName() {
|
Method gT = classToTest.getDeclaredMethod("gT", Integer.class, Integer.class);
|
||||||
assertEquals("GreaterThan", classToTest.getName());
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 5, 7);
|
||||||
}
|
assertFalse(result);
|
||||||
|
}
|
||||||
public void testIntegers() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method gT = classToTest.getDeclaredMethod("gT", Integer.class, Integer.class);
|
@Test
|
||||||
Boolean result = (Boolean) gT.invoke(instanceOfClass, 7, 5);
|
public void testEqIntegers() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
assertTrue(result);
|
Method gT = classToTest.getDeclaredMethod("gT", Integer.class, Integer.class);
|
||||||
}
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 5, 5);
|
||||||
|
assertFalse(result);
|
||||||
@Test
|
}
|
||||||
public void testIntegers2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method gT = classToTest.getDeclaredMethod("gT", Integer.class, Integer.class);
|
@Test
|
||||||
Boolean result = (Boolean) gT.invoke(instanceOfClass, 5, 7);
|
public void testLongs() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
assertFalse(result);
|
Method gT = classToTest.getDeclaredMethod("gT", Long.class, Long.class);
|
||||||
}
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 10L,7L);
|
||||||
|
assertTrue(result);
|
||||||
@Test
|
}@Test
|
||||||
public void testEqIntegers() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method gT = classToTest.getDeclaredMethod("gT", Integer.class, Integer.class);
|
public void testFloats() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Boolean result = (Boolean) gT.invoke(instanceOfClass, 5, 5);
|
Method gT = classToTest.getDeclaredMethod("gT", Float.class, Float.class);
|
||||||
assertFalse(result);
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 5F,7F);
|
||||||
}
|
assertFalse(result);
|
||||||
|
}
|
||||||
@Test
|
|
||||||
public void testLongs() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
@Test
|
||||||
Method gT = classToTest.getDeclaredMethod("gT", Long.class, Long.class);
|
public void testDoubles() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Boolean result = (Boolean) gT.invoke(instanceOfClass, 10L,7L);
|
Method gT = classToTest.getDeclaredMethod("gT", Double.class, Double.class);
|
||||||
assertTrue(result);
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 5.0,7.0);
|
||||||
}@Test
|
assertFalse(result);
|
||||||
|
}
|
||||||
public void testFloats() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method gT = classToTest.getDeclaredMethod("gT", Float.class, Float.class);
|
@Test
|
||||||
Boolean result = (Boolean) gT.invoke(instanceOfClass, 5F,7F);
|
public void testLongInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
assertFalse(result);
|
Method gT = classToTest.getDeclaredMethod("gT", Long.class, Integer.class);
|
||||||
}
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 15L,7);
|
||||||
|
assertTrue(result);
|
||||||
@Test
|
}
|
||||||
public void testDoubles() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method gT = classToTest.getDeclaredMethod("gT", Double.class, Double.class);
|
@Test
|
||||||
Boolean result = (Boolean) gT.invoke(instanceOfClass, 5.0,7.0);
|
public void testFloatInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
assertFalse(result);
|
Method gT = classToTest.getDeclaredMethod("gT", Float.class, Integer.class);
|
||||||
}
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 5F,7);
|
||||||
|
assertFalse(result);
|
||||||
@Test
|
}
|
||||||
public void testLongInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method gT = classToTest.getDeclaredMethod("gT", Long.class, Integer.class);
|
@Test
|
||||||
Boolean result = (Boolean) gT.invoke(instanceOfClass, 15L,7);
|
public void testDoubleInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
assertTrue(result);
|
Method gT = classToTest.getDeclaredMethod("gT", Double.class, Integer.class);
|
||||||
}
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 25.0,17);
|
||||||
|
assertTrue(result);
|
||||||
@Test
|
}
|
||||||
public void testFloatInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method gT = classToTest.getDeclaredMethod("gT", Float.class, Integer.class);
|
@Test
|
||||||
Boolean result = (Boolean) gT.invoke(instanceOfClass, 5F,7);
|
public void testFloatLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
assertFalse(result);
|
Method gT = classToTest.getDeclaredMethod("gT", Float.class, Long.class);
|
||||||
}
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 75F,70L);
|
||||||
|
assertTrue(result);
|
||||||
@Test
|
}
|
||||||
public void testDoubleInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method gT = classToTest.getDeclaredMethod("gT", Double.class, Integer.class);
|
@Test
|
||||||
Boolean result = (Boolean) gT.invoke(instanceOfClass, 25.0,17);
|
public void testDoubleLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
assertTrue(result);
|
Method gT = classToTest.getDeclaredMethod("gT", Double.class, Long.class);
|
||||||
}
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 5.0,7L);
|
||||||
|
assertFalse(result);
|
||||||
@Test
|
}
|
||||||
public void testFloatLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method gT = classToTest.getDeclaredMethod("gT", Float.class, Long.class);
|
@Test
|
||||||
Boolean result = (Boolean) gT.invoke(instanceOfClass, 75F,70L);
|
public void testEqDoubleFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
assertTrue(result);
|
Method gT = classToTest.getDeclaredMethod("gT", Double.class, Float.class);
|
||||||
}
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 7.0,7F);
|
||||||
|
assertFalse(result);
|
||||||
@Test
|
}
|
||||||
public void testDoubleLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method gT = classToTest.getDeclaredMethod("gT", Double.class, Long.class);
|
@Test
|
||||||
Boolean result = (Boolean) gT.invoke(instanceOfClass, 5.0,7L);
|
public void testDoubleFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
assertFalse(result);
|
Method gT = classToTest.getDeclaredMethod("gT", Double.class, Float.class);
|
||||||
}
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 15.0,7F);
|
||||||
|
assertTrue(result);
|
||||||
@Test
|
}
|
||||||
public void testEqDoubleFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method gT = classToTest.getDeclaredMethod("gT", Double.class, Float.class);
|
@Test
|
||||||
Boolean result = (Boolean) gT.invoke(instanceOfClass, 7.0,7F);
|
public void testDoubleFloat3() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
assertFalse(result);
|
Method gT = classToTest.getDeclaredMethod("gT", Double.class, Float.class);
|
||||||
}
|
Boolean result = (Boolean) gT.invoke(instanceOfClass, 9.0,17F);
|
||||||
|
assertFalse(result);
|
||||||
@Test
|
}
|
||||||
public void testDoubleFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method gT = classToTest.getDeclaredMethod("gT", Double.class, Float.class);
|
|
||||||
Boolean result = (Boolean) gT.invoke(instanceOfClass, 15.0,7F);
|
|
||||||
assertTrue(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDoubleFloat3() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method gT = classToTest.getDeclaredMethod("gT", Double.class, Float.class);
|
|
||||||
Boolean result = (Boolean) gT.invoke(instanceOfClass, 9.0,17F);
|
|
||||||
assertFalse(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
43
src/test/java/bytecode/LambdaCapturetest.java
Normal file
43
src/test/java/bytecode/LambdaCapturetest.java
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package bytecode;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author fayez
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class LambdaCapturetest {
|
||||||
|
private static String path;
|
||||||
|
private static File fileToTest;
|
||||||
|
private static JavaTXCompiler compiler;
|
||||||
|
private static ClassLoader loader;
|
||||||
|
private static Class<?> classToTest;
|
||||||
|
private static String pathToClassFile;
|
||||||
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void generateBC() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/LambdaCapture.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("LambdaCapture");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -13,38 +13,38 @@ import org.junit.Test;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class LambdaTest {
|
public class LambdaTest {
|
||||||
private static String path;
|
private static String path;
|
||||||
private static File fileToTest;
|
private static File fileToTest;
|
||||||
private static JavaTXCompiler compiler;
|
private static JavaTXCompiler compiler;
|
||||||
private static ClassLoader loader;
|
private static ClassLoader loader;
|
||||||
private static Class<?> classToTest;
|
private static Class<?> classToTest;
|
||||||
private static String pathToClassFile;
|
private static String pathToClassFile;
|
||||||
private static Object instanceOfClass;
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void generateBC() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/Lambda.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("Lambda");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
|
||||||
@Test
|
Method m = classToTest.getDeclaredMethod("m");
|
||||||
public void generateBC() throws Exception {
|
Class<?> lambda = m.invoke(instanceOfClass).getClass();
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/Lambda.jav";
|
Method apply = lambda.getMethod("apply", Object.class);
|
||||||
fileToTest = new File(path);
|
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
|
||||||
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
|
||||||
classToTest = loader.loadClass("Lambda");
|
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
|
||||||
|
|
||||||
Method m = classToTest.getDeclaredMethod("m");
|
// Damit man auf die Methode zugreifen kann
|
||||||
Class<?> lambda = m.invoke(instanceOfClass).getClass();
|
apply.setAccessible(true);
|
||||||
Method apply = lambda.getMethod("apply", Object.class);
|
|
||||||
|
|
||||||
// Damit man auf die Methode zugreifen kann
|
Integer i = 77;
|
||||||
apply.setAccessible(true);
|
System.out.println(m.invoke(instanceOfClass).toString());
|
||||||
|
Integer result = (Integer) apply.invoke(m.invoke(instanceOfClass), i);
|
||||||
|
|
||||||
Integer i = 77;
|
assertEquals(77, result);
|
||||||
|
}
|
||||||
Integer result = (Integer) apply.invoke(m.invoke(instanceOfClass), i);
|
|
||||||
|
|
||||||
assertEquals(Integer.valueOf(77), result);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,35 +13,35 @@ import org.junit.Test;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class LambdaVoidTest {
|
public class LambdaVoidTest {
|
||||||
private static String path;
|
private static String path;
|
||||||
private static File fileToTest;
|
private static File fileToTest;
|
||||||
private static JavaTXCompiler compiler;
|
private static JavaTXCompiler compiler;
|
||||||
private static ClassLoader loader;
|
private static ClassLoader loader;
|
||||||
private static Class<?> classToTest;
|
private static Class<?> classToTest;
|
||||||
private static String pathToClassFile;
|
private static String pathToClassFile;
|
||||||
private static Object instanceOfClass;
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void generateBC() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/Lambda.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("Lambda");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
|
||||||
@Test
|
Method m = classToTest.getDeclaredMethod("m");
|
||||||
public void generateBC() throws Exception {
|
Class<?> lambda = m.invoke(instanceOfClass).getClass();
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/Lambda.jav";
|
Method apply = lambda.getMethod("apply", Object.class);
|
||||||
fileToTest = new File(path);
|
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
|
||||||
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
|
||||||
classToTest = loader.loadClass("Lambda");
|
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
|
||||||
|
|
||||||
Method m = classToTest.getDeclaredMethod("m");
|
// Damit man auf die Methode zugreifen kann
|
||||||
Class<?> lambda = m.invoke(instanceOfClass).getClass();
|
apply.setAccessible(true);
|
||||||
Method apply = lambda.getMethod("apply", Object.class);
|
|
||||||
|
|
||||||
// Damit man auf die Methode zugreifen kann
|
Integer i = 77;
|
||||||
apply.setAccessible(true);
|
apply.invoke(m.invoke(instanceOfClass), i);
|
||||||
|
}
|
||||||
Integer i = 77;
|
|
||||||
apply.invoke(m.invoke(instanceOfClass), i);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,120 +14,120 @@ import org.junit.Test;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class LessEqualTest {
|
public class LessEqualTest {
|
||||||
|
|
||||||
|
private static String path;
|
||||||
|
private static File fileToTest;
|
||||||
|
private static JavaTXCompiler compiler;
|
||||||
|
private static ClassLoader loader;
|
||||||
|
private static Class<?> classToTest;
|
||||||
|
private static String pathToClassFile;
|
||||||
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/LessEqual.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
compiler.generateBytecode(pathToClassFile);
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("LessEqual");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
private static String path;
|
@Test
|
||||||
private static File fileToTest;
|
public void testName() {
|
||||||
private static JavaTXCompiler compiler;
|
assertEquals("LessEqual", classToTest.getName());
|
||||||
private static ClassLoader loader;
|
}
|
||||||
private static Class<?> classToTest;
|
|
||||||
private static String pathToClassFile;
|
@Test
|
||||||
private static Object instanceOfClass;
|
public void testIntegers() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Integer.class, Integer.class);
|
||||||
@BeforeClass
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5,7);
|
||||||
public static void setUpBeforeClass() throws Exception {
|
assertTrue(result);
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/LessEqual.jav";
|
}
|
||||||
fileToTest = new File(path);
|
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
@Test
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
public void testEqualIntegers() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
compiler.generateBytecode(pathToClassFile);
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Integer.class, Integer.class);
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5,5);
|
||||||
classToTest = loader.loadClass("LessEqual");
|
assertTrue(result);
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testLongs() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
public void testName() {
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Long.class, Long.class);
|
||||||
assertEquals("LessEqual", classToTest.getName());
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5L,7L);
|
||||||
}
|
assertTrue(result);
|
||||||
|
}@Test
|
||||||
@Test
|
|
||||||
public void testIntegers() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
public void testFloats() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Integer.class, Integer.class);
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Float.class, Float.class);
|
||||||
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5,7);
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5F,7F);
|
||||||
assertTrue(result);
|
assertTrue(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEqualIntegers() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
public void testDoubles() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Integer.class, Integer.class);
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Double.class, Double.class);
|
||||||
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5,5);
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5.0,7.0);
|
||||||
assertTrue(result);
|
assertTrue(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLongs() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
public void testLongInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Long.class, Long.class);
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Long.class, Integer.class);
|
||||||
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5L,7L);
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5L,7);
|
||||||
assertTrue(result);
|
assertTrue(result);
|
||||||
}@Test
|
}
|
||||||
|
|
||||||
public void testFloats() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
@Test
|
||||||
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Float.class, Float.class);
|
public void testFloatInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5F,7F);
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Float.class, Integer.class);
|
||||||
assertTrue(result);
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5F,7);
|
||||||
}
|
assertTrue(result);
|
||||||
|
}
|
||||||
@Test
|
|
||||||
public void testDoubles() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
@Test
|
||||||
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Double.class, Double.class);
|
public void testDoubleInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5.0,7.0);
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Double.class, Integer.class);
|
||||||
assertTrue(result);
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5.0,7);
|
||||||
}
|
assertTrue(result);
|
||||||
|
}
|
||||||
@Test
|
|
||||||
public void testLongInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
@Test
|
||||||
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Long.class, Integer.class);
|
public void testFloatLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5L,7);
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Float.class, Long.class);
|
||||||
assertTrue(result);
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5F,7L);
|
||||||
}
|
assertTrue(result);
|
||||||
|
}
|
||||||
@Test
|
|
||||||
public void testFloatInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
@Test
|
||||||
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Float.class, Integer.class);
|
public void testDoubleLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5F,7);
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Double.class, Long.class);
|
||||||
assertTrue(result);
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5.0,7L);
|
||||||
}
|
assertTrue(result);
|
||||||
|
}
|
||||||
@Test
|
|
||||||
public void testDoubleInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
@Test
|
||||||
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Double.class, Integer.class);
|
public void testEqDoubleFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5.0,7);
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Double.class, Float.class);
|
||||||
assertTrue(result);
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 7.0,7F);
|
||||||
}
|
assertTrue(result);
|
||||||
|
}
|
||||||
@Test
|
|
||||||
public void testFloatLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
@Test
|
||||||
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Float.class, Long.class);
|
public void testDoubleFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5F,7L);
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Double.class, Float.class);
|
||||||
assertTrue(result);
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5.0,7F);
|
||||||
}
|
assertTrue(result);
|
||||||
|
}
|
||||||
@Test
|
|
||||||
public void testDoubleLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
@Test
|
||||||
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Double.class, Long.class);
|
public void testDoubleFloat3() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5.0,7L);
|
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Double.class, Float.class);
|
||||||
assertTrue(result);
|
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 9.0,7F);
|
||||||
}
|
assertFalse(result);
|
||||||
|
}
|
||||||
@Test
|
|
||||||
public void testEqDoubleFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Double.class, Float.class);
|
|
||||||
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 7.0,7F);
|
|
||||||
assertTrue(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDoubleFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Double.class, Float.class);
|
|
||||||
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 5.0,7F);
|
|
||||||
assertTrue(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDoubleFloat3() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method lessEqual = classToTest.getDeclaredMethod("lessEqual", Double.class, Float.class);
|
|
||||||
Boolean result = (Boolean) lessEqual.invoke(instanceOfClass, 9.0,7F);
|
|
||||||
assertFalse(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,128 +14,128 @@ import org.junit.Test;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class LessThanTest {
|
public class LessThanTest {
|
||||||
|
|
||||||
|
private static String path;
|
||||||
|
private static File fileToTest;
|
||||||
|
private static JavaTXCompiler compiler;
|
||||||
|
private static ClassLoader loader;
|
||||||
|
private static Class<?> classToTest;
|
||||||
|
private static String pathToClassFile;
|
||||||
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/LessThan.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
compiler.generateBytecode(pathToClassFile);
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("LessThan");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
private static String path;
|
@Test
|
||||||
private static File fileToTest;
|
public void testClassName() {
|
||||||
private static JavaTXCompiler compiler;
|
assertEquals("LessThan", classToTest.getName());
|
||||||
private static ClassLoader loader;
|
}
|
||||||
private static Class<?> classToTest;
|
|
||||||
private static String pathToClassFile;
|
@Test
|
||||||
private static Object instanceOfClass;
|
public void testLessThanInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Integer.class,Integer.class);
|
||||||
@BeforeClass
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 5, 7);
|
||||||
public static void setUpBeforeClass() throws Exception {
|
assertTrue(result);
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/LessThan.jav";
|
}
|
||||||
fileToTest = new File(path);
|
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
@Test
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
public void testLessThanInt2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
compiler.generateBytecode(pathToClassFile);
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Integer.class, Integer.class);
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7, 5);
|
||||||
classToTest = loader.loadClass("LessThan");
|
assertFalse(result);
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
}
|
||||||
}
|
|
||||||
|
@Test
|
||||||
@Test
|
public void testLessThanInt3() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
public void testClassName() {
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Integer.class, Integer.class);
|
||||||
assertEquals("LessThan", classToTest.getName());
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 5, 5);
|
||||||
}
|
assertFalse(result);
|
||||||
|
}
|
||||||
@Test
|
|
||||||
public void testLessThanInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
@Test
|
||||||
Method lessThan = classToTest.getDeclaredMethod("lessThan", Integer.class,Integer.class);
|
public void testLessThanLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 5, 7);
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Long.class,Long.class);
|
||||||
assertTrue(result);
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 5L, 7L);
|
||||||
}
|
assertTrue(result);
|
||||||
|
}
|
||||||
@Test
|
|
||||||
public void testLessThanInt2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
@Test
|
||||||
Method lessThan = classToTest.getDeclaredMethod("lessThan", Integer.class, Integer.class);
|
public void testLessThanLong2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7, 5);
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Long.class, Long.class);
|
||||||
assertFalse(result);
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7L, 5L);
|
||||||
}
|
assertFalse(result);
|
||||||
|
}
|
||||||
@Test
|
|
||||||
public void testLessThanInt3() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
@Test
|
||||||
Method lessThan = classToTest.getDeclaredMethod("lessThan", Integer.class, Integer.class);
|
public void testLessThanLong3() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 5, 5);
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Long.class, Long.class);
|
||||||
assertFalse(result);
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 5L, 5L);
|
||||||
}
|
assertFalse(result);
|
||||||
|
}
|
||||||
@Test
|
|
||||||
public void testLessThanLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
@Test
|
||||||
Method lessThan = classToTest.getDeclaredMethod("lessThan", Long.class,Long.class);
|
public void testLessThanFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 5L, 7L);
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Float.class, Float.class);
|
||||||
assertTrue(result);
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7F, 5F);
|
||||||
}
|
assertFalse(result);
|
||||||
|
}
|
||||||
@Test
|
|
||||||
public void testLessThanLong2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
@Test
|
||||||
Method lessThan = classToTest.getDeclaredMethod("lessThan", Long.class, Long.class);
|
public void testLessThanDouble() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7L, 5L);
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Double.class, Double.class);
|
||||||
assertFalse(result);
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7.0, 5.0);
|
||||||
}
|
assertFalse(result);
|
||||||
|
}
|
||||||
@Test
|
|
||||||
public void testLessThanLong3() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
@Test
|
||||||
Method lessThan = classToTest.getDeclaredMethod("lessThan", Long.class, Long.class);
|
public void testLessThanLongInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 5L, 5L);
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Long.class, Integer.class);
|
||||||
assertFalse(result);
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7L, 5);
|
||||||
}
|
assertFalse(result);
|
||||||
|
}
|
||||||
@Test
|
|
||||||
public void testLessThanFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
@Test
|
||||||
Method lessThan = classToTest.getDeclaredMethod("lessThan", Float.class, Float.class);
|
public void testLessThanFloatInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7F, 5F);
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Float.class, Integer.class);
|
||||||
assertFalse(result);
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7F, 5);
|
||||||
}
|
assertFalse(result);
|
||||||
|
}
|
||||||
@Test
|
|
||||||
public void testLessThanDouble() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
@Test
|
||||||
Method lessThan = classToTest.getDeclaredMethod("lessThan", Double.class, Double.class);
|
public void testLessThanDoubleInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7.0, 5.0);
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Double.class, Integer.class);
|
||||||
assertFalse(result);
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7.0, 5);
|
||||||
}
|
assertFalse(result);
|
||||||
|
}
|
||||||
@Test
|
|
||||||
public void testLessThanLongInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
@Test
|
||||||
Method lessThan = classToTest.getDeclaredMethod("lessThan", Long.class, Integer.class);
|
public void testLessThanFloatLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7L, 5);
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Float.class, Long.class);
|
||||||
assertFalse(result);
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7F, 5L);
|
||||||
}
|
assertFalse(result);
|
||||||
|
}
|
||||||
@Test
|
|
||||||
public void testLessThanFloatInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
@Test
|
||||||
Method lessThan = classToTest.getDeclaredMethod("lessThan", Float.class, Integer.class);
|
public void testLessThanDoubleLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7F, 5);
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Double.class, Long.class);
|
||||||
assertFalse(result);
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7.0, 5L);
|
||||||
}
|
assertFalse(result);
|
||||||
|
}
|
||||||
@Test
|
|
||||||
public void testLessThanDoubleInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
@Test
|
||||||
Method lessThan = classToTest.getDeclaredMethod("lessThan", Double.class, Integer.class);
|
public void testLessThanDoubleFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7.0, 5);
|
Method lessThan = classToTest.getDeclaredMethod("lessThan", Double.class, Float.class);
|
||||||
assertFalse(result);
|
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7.0, 5F);
|
||||||
}
|
assertFalse(result);
|
||||||
|
}
|
||||||
@Test
|
|
||||||
public void testLessThanFloatLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method lessThan = classToTest.getDeclaredMethod("lessThan", Float.class, Long.class);
|
|
||||||
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7F, 5L);
|
|
||||||
assertFalse(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testLessThanDoubleLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method lessThan = classToTest.getDeclaredMethod("lessThan", Double.class, Long.class);
|
|
||||||
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7.0, 5L);
|
|
||||||
assertFalse(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testLessThanDoubleFloat() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method lessThan = classToTest.getDeclaredMethod("lessThan", Double.class, Float.class);
|
|
||||||
Boolean result = (Boolean) lessThan.invoke(instanceOfClass, 7.0, 5F);
|
|
||||||
assertFalse(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,76 +16,76 @@ import org.junit.Test;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class MatrixOpTest {
|
public class MatrixOpTest {
|
||||||
private static String path;
|
private static String path;
|
||||||
private static File fileToTest;
|
private static File fileToTest;
|
||||||
private static JavaTXCompiler compiler;
|
private static JavaTXCompiler compiler;
|
||||||
private static ClassLoader loader;
|
private static ClassLoader loader;
|
||||||
private static Class<?> classToTest;
|
private static Class<?> classToTest;
|
||||||
private static String pathToClassFile;
|
private static String pathToClassFile;
|
||||||
private static Object instanceOfClass_m1;
|
private static Object instanceOfClass_m1;
|
||||||
private static Object instanceOfClass_m2;
|
private static Object instanceOfClass_m2;
|
||||||
private static Object instanceOfClass_m3;
|
private static Object instanceOfClass_m3;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException, IOException, InstantiationException {
|
public void test() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException, IOException, InstantiationException {
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/MatrixOP.jav";
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/MatrixOP.jav";
|
||||||
fileToTest = new File(path);
|
fileToTest = new File(path);
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
// compiler.generateBytecode(pathToClassFile);
|
compiler.generateBytecode(pathToClassFile);
|
||||||
// loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
// classToTest = loader.loadClass("MatrixOP");
|
classToTest = loader.loadClass("MatrixOP");
|
||||||
/*
|
/*
|
||||||
Vector<Vector<Integer>> vv = new Vector<Vector<Integer>>();
|
Vector<Vector<Integer>> vv = new Vector<Vector<Integer>>();
|
||||||
Vector<Integer> v1 = new Vector<Integer> ();
|
Vector<Integer> v1 = new Vector<Integer> ();
|
||||||
v1.addElement(2);
|
v1.addElement(2);
|
||||||
v1.addElement(2);
|
v1.addElement(2);
|
||||||
Vector<Integer> v2 = new Vector<Integer> ();
|
Vector<Integer> v2 = new Vector<Integer> ();
|
||||||
v2.addElement(3);
|
v2.addElement(3);
|
||||||
v2.addElement(3);
|
v2.addElement(3);
|
||||||
//Matrix m1 = new Matrix();
|
//Matrix m1 = new Matrix();
|
||||||
//m1.addElement(v1);
|
//m1.addElement(v1);
|
||||||
//m1.addElement(v2);
|
//m1.addElement(v2);
|
||||||
vv.addElement(v1);
|
vv.addElement(v1);
|
||||||
vv.addElement(v2);
|
vv.addElement(v2);
|
||||||
instanceOfClass_m1 = classToTest.getDeclaredConstructor(Vector.class).newInstance(vv); //Matrix m1 = new Matrix(vv);
|
instanceOfClass_m1 = classToTest.getDeclaredConstructor(Vector.class).newInstance(vv); //Matrix m1 = new Matrix(vv);
|
||||||
|
|
||||||
Vector<Vector<Integer>> vv1 = new Vector<Vector<Integer>>();
|
Vector<Vector<Integer>> vv1 = new Vector<Vector<Integer>>();
|
||||||
Vector<Integer> v3 = new Vector<Integer> ();
|
Vector<Integer> v3 = new Vector<Integer> ();
|
||||||
v3.addElement(2);
|
v3.addElement(2);
|
||||||
v3.addElement(2);
|
v3.addElement(2);
|
||||||
Vector<Integer> v4 = new Vector<Integer> ();
|
Vector<Integer> v4 = new Vector<Integer> ();
|
||||||
v4.addElement(3);
|
v4.addElement(3);
|
||||||
v4.addElement(3);
|
v4.addElement(3);
|
||||||
//Matrix m2 = new Matrix();
|
//Matrix m2 = new Matrix();
|
||||||
//m2.addElement(v3);
|
//m2.addElement(v3);
|
||||||
//m2.addElement(v4);
|
//m2.addElement(v4);
|
||||||
vv1.addElement(v3);
|
vv1.addElement(v3);
|
||||||
vv1.addElement(v4);
|
vv1.addElement(v4);
|
||||||
instanceOfClass_m2 = classToTest.getDeclaredConstructor(Vector.class).newInstance(vv1);//Matrix m2 = new Matrix(vv1);
|
instanceOfClass_m2 = classToTest.getDeclaredConstructor(Vector.class).newInstance(vv1);//Matrix m2 = new Matrix(vv1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Matrix m3 = m1.mul(vv1);
|
||||||
|
Method mul = classToTest.getDeclaredMethod("mul", Vector.class);
|
||||||
//Matrix m3 = m1.mul(vv1);
|
Object result = mul.invoke(instanceOfClass_m1, instanceOfClass_m2);
|
||||||
Method mul = classToTest.getDeclaredMethod("mul", Vector.class);
|
System.out.println(instanceOfClass_m1.toString() + " * " + instanceOfClass_m2.toString() + " = " + result.toString());
|
||||||
Object result = mul.invoke(instanceOfClass_m1, instanceOfClass_m2);
|
|
||||||
System.out.println(instanceOfClass_m1.toString() + " * " + instanceOfClass_m2.toString() + " = " + result.toString());
|
Vector<Vector<Integer>> res = new Vector<Vector<Integer>>();
|
||||||
|
Vector<Integer> v5 = new Vector<Integer> ();
|
||||||
Vector<Vector<Integer>> res = new Vector<Vector<Integer>>();
|
v5.addElement(10);
|
||||||
Vector<Integer> v5 = new Vector<Integer> ();
|
v5.addElement(10);
|
||||||
v5.addElement(10);
|
Vector<Integer> v6 = new Vector<Integer> ();
|
||||||
v5.addElement(10);
|
v6.addElement(15);
|
||||||
Vector<Integer> v6 = new Vector<Integer> ();
|
v6.addElement(15);
|
||||||
v6.addElement(15);
|
//Matrix m2 = new Matrix();
|
||||||
v6.addElement(15);
|
//m2.addElement(v3);
|
||||||
//Matrix m2 = new Matrix();
|
//m2.addElement(v4);
|
||||||
//m2.addElement(v3);
|
res.addElement(v5);
|
||||||
//m2.addElement(v4);
|
res.addElement(v6);
|
||||||
res.addElement(v5);
|
instanceOfClass_m3 = classToTest.getDeclaredConstructor(Vector.class).newInstance(res);
|
||||||
res.addElement(v6);
|
assertEquals(result, instanceOfClass_m3);
|
||||||
instanceOfClass_m3 = classToTest.getDeclaredConstructor(Vector.class).newInstance(res);
|
*/
|
||||||
assertEquals(result, instanceOfClass_m3);
|
}
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public class MatrixTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException, IOException, InstantiationException {
|
public void test() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException, IOException, InstantiationException {
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/Matrix.jav";
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/Matrix.jav";
|
||||||
fileToTest = new File(path);
|
fileToTest = new File(path);
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
@ -13,29 +13,29 @@ import org.junit.Test;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class MergeTest {
|
public class MergeTest {
|
||||||
private static String path;
|
private static String path;
|
||||||
private static File fileToTest;
|
private static File fileToTest;
|
||||||
private static JavaTXCompiler compiler;
|
private static JavaTXCompiler compiler;
|
||||||
private static ClassLoader loader;
|
private static ClassLoader loader;
|
||||||
private static Class<?> classToTest;
|
private static Class<?> classToTest;
|
||||||
private static String pathToClassFile;
|
private static String pathToClassFile;
|
||||||
private static Object instanceOfClass;
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
@Test
|
public void generateBC() throws Exception {
|
||||||
public void generateBC() throws Exception {
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/Merge.jav";
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/Merge.jav";
|
fileToTest = new File(path);
|
||||||
fileToTest = new File(path);
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
||||||
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
// pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||||
// pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
|
||||||
// loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
// loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
// classToTest = loader.loadClass("Merge");
|
// classToTest = loader.loadClass("Merge");
|
||||||
//instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
//instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
|
||||||
//Method m = classToTest.getDeclaredMethod("m");
|
//Method m = classToTest.getDeclaredMethod("m");
|
||||||
//Object result = m.invoke(instanceOfClass);
|
//Object result = m.invoke(instanceOfClass);
|
||||||
|
|
||||||
//assertEquals(result.getClass(), loader.loadClass("Apply"));
|
//assertEquals(result.getClass(), loader.loadClass("Apply"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,79 +14,79 @@ import org.junit.Test;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class OLTest {
|
public class OLTest {
|
||||||
private static String path;
|
private static String path;
|
||||||
private static File fileToTest;
|
private static File fileToTest;
|
||||||
private static JavaTXCompiler compiler;
|
private static JavaTXCompiler compiler;
|
||||||
private static ClassLoader loader;
|
private static ClassLoader loader;
|
||||||
private static Class<?> classToTest;
|
private static Class<?> classToTest;
|
||||||
private static Class<?> classToTest1;
|
private static Class<?> classToTest1;
|
||||||
private static String pathToClassFile;
|
private static String pathToClassFile;
|
||||||
private static Object instanceOfClass;
|
private static Object instanceOfClass;
|
||||||
private static Object instanceOfClass1;
|
private static Object instanceOfClass1;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public static void setUpBeforeClass() throws Exception {
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/OL.jav";
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/OL.jav";
|
||||||
fileToTest = new File(path);
|
fileToTest = new File(path);
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
compiler.generateBytecode(pathToClassFile);
|
compiler.generateBytecode(pathToClassFile);
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
classToTest = loader.loadClass("OL");
|
classToTest = loader.loadClass("OL");
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
classToTest1 = loader.loadClass("OLMain");
|
classToTest1 = loader.loadClass("OLMain");
|
||||||
instanceOfClass1 = classToTest1.getDeclaredConstructor().newInstance();
|
instanceOfClass1 = classToTest1.getDeclaredConstructor().newInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOLClassName() {
|
public void testOLClassName() {
|
||||||
assertEquals("OL", classToTest.getName());
|
assertEquals("OL", classToTest.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testmInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
public void testmInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Method m = classToTest.getDeclaredMethod("m", Integer.class);
|
Method m = classToTest.getDeclaredMethod("m", Integer.class);
|
||||||
Integer result = (Integer) m.invoke(instanceOfClass, 5);
|
Integer result = (Integer) m.invoke(instanceOfClass, 5);
|
||||||
assertEquals(Integer.valueOf(10), result);
|
assertEquals(10, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testmDouble() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
public void testmDouble() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Method m = classToTest.getDeclaredMethod("m", Double.class);
|
Method m = classToTest.getDeclaredMethod("m", Double.class);
|
||||||
Double result = (Double) m.invoke(instanceOfClass, 5.0);
|
Double result = (Double) m.invoke(instanceOfClass, 5.0);
|
||||||
assertEquals(Double.valueOf(10.0), result);
|
assertEquals(10.0, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testmString() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
public void testmString() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Method m = classToTest.getDeclaredMethod("m", String.class);
|
Method m = classToTest.getDeclaredMethod("m", String.class);
|
||||||
String result = (String) m.invoke(instanceOfClass, "xxx");
|
String result = (String) m.invoke(instanceOfClass, "xxx");
|
||||||
assertEquals("xxxxxx", result);
|
assertEquals("xxxxxx", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOLMainClassName() {
|
public void testOLMainClassName() {
|
||||||
assertEquals("OLMain", classToTest1.getName());
|
assertEquals("OLMain", classToTest1.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testmainInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
public void testmainInt() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Method main = classToTest1.getDeclaredMethod("main", Integer.class);
|
Method main = classToTest1.getDeclaredMethod("main", Integer.class);
|
||||||
Integer result = (Integer) main.invoke(instanceOfClass1, 5);
|
Integer result = (Integer) main.invoke(instanceOfClass1, 5);
|
||||||
assertEquals(Integer.valueOf(10), result);
|
assertEquals(10, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testmainDouble() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
public void testmainDouble() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Method main = classToTest1.getDeclaredMethod("main", Double.class);
|
Method main = classToTest1.getDeclaredMethod("main", Double.class);
|
||||||
Double result = (Double) main.invoke(instanceOfClass1, 5.0);
|
Double result = (Double) main.invoke(instanceOfClass1, 5.0);
|
||||||
assertEquals(Double.valueOf(10.0), result);
|
assertEquals(10.0, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testmainString() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
public void testmainString() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
Method main = classToTest1.getDeclaredMethod("main", String.class);
|
Method main = classToTest1.getDeclaredMethod("main", String.class);
|
||||||
String result = (String) main.invoke(instanceOfClass1, "xxx");
|
String result = (String) main.invoke(instanceOfClass1, "xxx");
|
||||||
assertEquals("xxxxxx", result);
|
assertEquals("xxxxxx", result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,47 +15,47 @@ import org.objectweb.asm.Opcodes;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class OpTest {
|
public class OpTest {
|
||||||
private static String path;
|
private static String path;
|
||||||
private static File fileToTest;
|
private static File fileToTest;
|
||||||
private static JavaTXCompiler compiler;
|
private static JavaTXCompiler compiler;
|
||||||
private static ClassLoader loader;
|
private static ClassLoader loader;
|
||||||
private static Class<?> classToTest;
|
private static Class<?> classToTest;
|
||||||
private static String pathToClassFile;
|
private static String pathToClassFile;
|
||||||
private static Object instanceOfClass;
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public static void setUpBeforeClass() throws Exception {
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/Op.jav";
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/Op.jav";
|
||||||
fileToTest = new File(path);
|
fileToTest = new File(path);
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
compiler.generateBytecode(pathToClassFile);
|
compiler.generateBytecode(pathToClassFile);
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
classToTest = loader.loadClass("Op");
|
classToTest = loader.loadClass("Op");
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testAddString() throws NoSuchMethodException, SecurityException, IllegalAccessException,
|
|
||||||
IllegalArgumentException, InvocationTargetException, InstantiationException {
|
|
||||||
|
|
||||||
Method m = classToTest.getDeclaredMethod("m", String.class,String.class);
|
|
||||||
|
|
||||||
String result = (String) m.invoke(instanceOfClass, "Byte","Code");
|
|
||||||
|
|
||||||
assertEquals("ByteCode", result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testAddInt() throws NoSuchMethodException, SecurityException, IllegalAccessException,
|
|
||||||
IllegalArgumentException, InvocationTargetException, InstantiationException {
|
|
||||||
|
|
||||||
Method m = classToTest.getDeclaredMethod("m", Integer.class,Integer.class);
|
|
||||||
|
|
||||||
Integer result = (Integer) m.invoke(instanceOfClass, 7,3);
|
|
||||||
|
|
||||||
assertEquals(Integer.valueOf(10), result);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddString() throws NoSuchMethodException, SecurityException, IllegalAccessException,
|
||||||
|
IllegalArgumentException, InvocationTargetException, InstantiationException {
|
||||||
|
|
||||||
|
Method m = classToTest.getDeclaredMethod("m", String.class,String.class);
|
||||||
|
|
||||||
|
String result = (String) m.invoke(instanceOfClass, "Byte","Code");
|
||||||
|
|
||||||
|
assertEquals("ByteCode", result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddInt() throws NoSuchMethodException, SecurityException, IllegalAccessException,
|
||||||
|
IllegalArgumentException, InvocationTargetException, InstantiationException {
|
||||||
|
|
||||||
|
Method m = classToTest.getDeclaredMethod("m", Integer.class,Integer.class);
|
||||||
|
|
||||||
|
Integer result = (Integer) m.invoke(instanceOfClass, 7,3);
|
||||||
|
|
||||||
|
assertEquals(10, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ public class OverloadingSortingTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void generateBC() throws Exception {
|
public void generateBC() throws Exception {
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/Sorting.jav";
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/Sorting.jav";
|
||||||
fileToTest = new File(path);
|
fileToTest = new File(path);
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
@ -14,44 +14,44 @@ import org.junit.Test;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class OverloadingTest {
|
public class OverloadingTest {
|
||||||
private static String path;
|
private static String path;
|
||||||
private static File fileToTest;
|
private static File fileToTest;
|
||||||
private static JavaTXCompiler compiler;
|
private static JavaTXCompiler compiler;
|
||||||
private static ClassLoader loader;
|
private static ClassLoader loader;
|
||||||
private static Class<?> classToTest;
|
private static Class<?> classToTest;
|
||||||
private static String pathToClassFile;
|
private static String pathToClassFile;
|
||||||
private static Object instanceOfClass;
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
private static Class<?> classOL2;
|
||||||
|
private static Object instanceOfClassOL2;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/Overloading.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
compiler.generateBytecode(pathToClassFile);
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("Overloading");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
|
||||||
|
classOL2 = loader.loadClass("Overloading2");
|
||||||
|
instanceOfClassOL2 = classOL2.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
private static Class<?> classOL2;
|
@Test
|
||||||
private static Object instanceOfClassOL2;
|
public void test() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
|
Method meth = classToTest.getDeclaredMethod("test", classToTest);
|
||||||
@BeforeClass
|
String res = (String) meth.invoke(instanceOfClass, instanceOfClass);
|
||||||
public static void setUpBeforeClass() throws Exception {
|
assertEquals("Overloading", res);
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/Overloading.jav";
|
}
|
||||||
fileToTest = new File(path);
|
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
@Test
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
public void test2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
compiler.generateBytecode(pathToClassFile);
|
Method meth = classToTest.getDeclaredMethod("test", classOL2);
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
String res = (String) meth.invoke(instanceOfClass, instanceOfClassOL2);
|
||||||
classToTest = loader.loadClass("Overloading");
|
assertEquals("Overloading2", res);
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
}
|
||||||
|
|
||||||
classOL2 = loader.loadClass("Overloading2");
|
|
||||||
instanceOfClassOL2 = classOL2.getDeclaredConstructor().newInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method meth = classToTest.getDeclaredMethod("test", classToTest);
|
|
||||||
String res = (String) meth.invoke(instanceOfClass, instanceOfClass);
|
|
||||||
assertEquals("Overloading", res);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method meth = classToTest.getDeclaredMethod("test", classOL2);
|
|
||||||
String res = (String) meth.invoke(instanceOfClass, instanceOfClassOL2);
|
|
||||||
assertEquals("Overloading2", res);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,40 +14,40 @@ import org.junit.Test;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class PlusTest {
|
public class PlusTest {
|
||||||
private static String path;
|
private static String path;
|
||||||
private static File fileToTest;
|
private static File fileToTest;
|
||||||
private static JavaTXCompiler compiler;
|
private static JavaTXCompiler compiler;
|
||||||
private static ClassLoader loader;
|
private static ClassLoader loader;
|
||||||
private static Class<?> classToTest;
|
private static Class<?> classToTest;
|
||||||
private static String pathToClassFile;
|
private static String pathToClassFile;
|
||||||
private static Object instanceOfClass;
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/Plus.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
compiler.generateBytecode(pathToClassFile);
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("Plus");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@Test
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public void testAddInt() throws NoSuchMethodException, SecurityException, IllegalAccessException,
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/Plus.jav";
|
IllegalArgumentException, InvocationTargetException, InstantiationException {
|
||||||
fileToTest = new File(path);
|
Method addInt = classToTest.getDeclaredMethod("m", Integer.class,Integer.class);
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
Number result = (Number) addInt.invoke(instanceOfClass, 7,3);
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
assertEquals(10, result);
|
||||||
compiler.generateBytecode(pathToClassFile);
|
}
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
|
||||||
classToTest = loader.loadClass("Plus");
|
@Test
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
public void testAddString() throws NoSuchMethodException, SecurityException, IllegalAccessException,
|
||||||
}
|
IllegalArgumentException, InvocationTargetException, InstantiationException {
|
||||||
|
Method addString = classToTest.getDeclaredMethod("m", String.class,String.class);
|
||||||
@Test
|
String result = (String) addString.invoke(instanceOfClass, "Byte","Code");
|
||||||
public void testAddInt() throws NoSuchMethodException, SecurityException, IllegalAccessException,
|
assertEquals("ByteCode", result);
|
||||||
IllegalArgumentException, InvocationTargetException, InstantiationException {
|
}
|
||||||
Method addInt = classToTest.getDeclaredMethod("m", Integer.class,Integer.class);
|
|
||||||
Number result = (Number) addInt.invoke(instanceOfClass, 7,3);
|
|
||||||
assertEquals(10, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testAddString() throws NoSuchMethodException, SecurityException, IllegalAccessException,
|
|
||||||
IllegalArgumentException, InvocationTargetException, InstantiationException {
|
|
||||||
Method addString = classToTest.getDeclaredMethod("m", String.class,String.class);
|
|
||||||
String result = (String) addString.invoke(instanceOfClass, "Byte","Code");
|
|
||||||
assertEquals("ByteCode", result);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,52 +14,52 @@ import org.junit.Test;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class PostIncTest {
|
public class PostIncTest {
|
||||||
private static String path;
|
private static String path;
|
||||||
private static File fileToTest;
|
private static File fileToTest;
|
||||||
private static JavaTXCompiler compiler;
|
private static JavaTXCompiler compiler;
|
||||||
private static ClassLoader loader;
|
private static ClassLoader loader;
|
||||||
private static Class<?> classToTest;
|
private static Class<?> classToTest;
|
||||||
private static String pathToClassFile;
|
private static String pathToClassFile;
|
||||||
private static Object instanceOfClass;
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/PostIncDec.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
compiler.generateBytecode(pathToClassFile);
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("PostIncDec");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@Test
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public void testM1() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/PostIncDec.jav";
|
Method m = classToTest.getDeclaredMethod("m");
|
||||||
fileToTest = new File(path);
|
Integer res = (Integer) m.invoke(instanceOfClass);
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
assertEquals(1, res);
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
}
|
||||||
compiler.generateBytecode(pathToClassFile);
|
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
@Test
|
||||||
classToTest = loader.loadClass("PostIncDec");
|
public void testM2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
Method m = classToTest.getDeclaredMethod("m2");
|
||||||
}
|
Integer res = (Integer) m.invoke(instanceOfClass);
|
||||||
|
assertEquals(0, res);
|
||||||
@Test
|
}
|
||||||
public void testM1() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method m = classToTest.getDeclaredMethod("m");
|
@Test
|
||||||
Integer res = (Integer) m.invoke(instanceOfClass);
|
public void testD1() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
assertEquals(Integer.valueOf(1), res);
|
Method m = classToTest.getDeclaredMethod("d");
|
||||||
}
|
Integer res = (Integer) m.invoke(instanceOfClass);
|
||||||
|
assertEquals(-1, res);
|
||||||
@Test
|
}
|
||||||
public void testM2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method m = classToTest.getDeclaredMethod("m2");
|
@Test
|
||||||
Integer res = (Integer) m.invoke(instanceOfClass);
|
public void testD2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
assertEquals(Integer.valueOf(0), res);
|
Method m = classToTest.getDeclaredMethod("d2");
|
||||||
}
|
Integer res = (Integer) m.invoke(instanceOfClass);
|
||||||
|
assertEquals(0, res);
|
||||||
@Test
|
}
|
||||||
public void testD1() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method m = classToTest.getDeclaredMethod("d");
|
|
||||||
Integer res = (Integer) m.invoke(instanceOfClass);
|
|
||||||
assertEquals(Integer.valueOf(-1), res);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testD2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method m = classToTest.getDeclaredMethod("d2");
|
|
||||||
Integer res = (Integer) m.invoke(instanceOfClass);
|
|
||||||
assertEquals(Integer.valueOf(0), res);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,52 +14,52 @@ import org.junit.Test;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class PreIncTest {
|
public class PreIncTest {
|
||||||
private static String path;
|
private static String path;
|
||||||
private static File fileToTest;
|
private static File fileToTest;
|
||||||
private static JavaTXCompiler compiler;
|
private static JavaTXCompiler compiler;
|
||||||
private static ClassLoader loader;
|
private static ClassLoader loader;
|
||||||
private static Class<?> classToTest;
|
private static Class<?> classToTest;
|
||||||
private static String pathToClassFile;
|
private static String pathToClassFile;
|
||||||
private static Object instanceOfClass;
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/PreInc.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
compiler.generateBytecode(pathToClassFile);
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://" + pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("PreInc");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@Test
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public void testM() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/PreInc.jav";
|
Method m = classToTest.getDeclaredMethod("m");
|
||||||
fileToTest = new File(path);
|
Integer res = (Integer) m.invoke(instanceOfClass);
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
assertEquals(1, res);
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
}
|
||||||
compiler.generateBytecode(pathToClassFile);
|
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://" + pathToClassFile)});
|
@Test
|
||||||
classToTest = loader.loadClass("PreInc");
|
public void testM2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
Method m = classToTest.getDeclaredMethod("m2");
|
||||||
}
|
Integer res = (Integer) m.invoke(instanceOfClass);
|
||||||
|
assertEquals(1, res);
|
||||||
@Test
|
}
|
||||||
public void testM() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method m = classToTest.getDeclaredMethod("m");
|
@Test
|
||||||
Integer res = (Integer) m.invoke(instanceOfClass);
|
public void testD() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
assertEquals(Integer.valueOf(1), res);
|
Method m = classToTest.getDeclaredMethod("d");
|
||||||
}
|
Integer res = (Integer) m.invoke(instanceOfClass);
|
||||||
|
assertEquals(-1, res);
|
||||||
@Test
|
}
|
||||||
public void testM2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method m = classToTest.getDeclaredMethod("m2");
|
@Test
|
||||||
Integer res = (Integer) m.invoke(instanceOfClass);
|
public void testD2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
assertEquals(Integer.valueOf(1), res);
|
Method m = classToTest.getDeclaredMethod("d2");
|
||||||
}
|
Integer res = (Integer) m.invoke(instanceOfClass);
|
||||||
|
assertEquals(-1, res);
|
||||||
@Test
|
}
|
||||||
public void testD() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method m = classToTest.getDeclaredMethod("d");
|
|
||||||
Integer res = (Integer) m.invoke(instanceOfClass);
|
|
||||||
assertEquals(Integer.valueOf(-1), res);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testD2() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method m = classToTest.getDeclaredMethod("d2");
|
|
||||||
Integer res = (Integer) m.invoke(instanceOfClass);
|
|
||||||
assertEquals(Integer.valueOf(-1), res);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,31 +14,31 @@ import org.junit.Test;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class RelOpsTest {
|
public class RelOpsTest {
|
||||||
private static String path;
|
private static String path;
|
||||||
private static File fileToTest;
|
private static File fileToTest;
|
||||||
private static JavaTXCompiler compiler;
|
private static JavaTXCompiler compiler;
|
||||||
private static ClassLoader loader;
|
private static ClassLoader loader;
|
||||||
private static Class<?> classToTest;
|
private static Class<?> classToTest;
|
||||||
private static String pathToClassFile;
|
private static String pathToClassFile;
|
||||||
private static Object instanceOfClass;
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/RelOps.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
compiler.generateBytecode(pathToClassFile);
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("RelOps");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@Test
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public void test() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/RelOps.jav";
|
Method m = classToTest.getDeclaredMethod("m", Integer.class,Integer.class);
|
||||||
fileToTest = new File(path);
|
Boolean result = (Boolean) m.invoke(instanceOfClass, 7,3);
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
assertFalse(result);
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
}
|
||||||
compiler.generateBytecode(pathToClassFile);
|
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
|
||||||
classToTest = loader.loadClass("RelOps");
|
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method m = classToTest.getDeclaredMethod("m", Integer.class,Integer.class);
|
|
||||||
Boolean result = (Boolean) m.invoke(instanceOfClass, 7,3);
|
|
||||||
assertFalse(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ public class SortingTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void generateBC() throws Exception {
|
public void generateBC() throws Exception {
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/Sorting.jav";
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/Sorting.jav";
|
||||||
fileToTest = new File(path);
|
fileToTest = new File(path);
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
||||||
|
@ -10,18 +10,18 @@ import org.junit.Test;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class SubMatTest {
|
public class SubMatTest {
|
||||||
private static String path;
|
private static String path;
|
||||||
private static File fileToTest;
|
private static File fileToTest;
|
||||||
private static JavaTXCompiler compiler;
|
private static JavaTXCompiler compiler;
|
||||||
private static String pathToClassFile;
|
private static String pathToClassFile;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() throws ClassNotFoundException, IOException {
|
public void test() throws ClassNotFoundException, IOException {
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/SubMatrix.jav";
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/SubMatrix.jav";
|
||||||
fileToTest = new File(path);
|
fileToTest = new File(path);
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
compiler.generateBytecode(pathToClassFile);
|
compiler.generateBytecode(pathToClassFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,57 +13,57 @@ import org.junit.Test;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class Tph2Test {
|
public class Tph2Test {
|
||||||
|
|
||||||
|
private static String path;
|
||||||
|
private static File fileToTest;
|
||||||
|
private static JavaTXCompiler compiler;
|
||||||
|
private static ClassLoader loader;
|
||||||
|
private static Class<?> classToTest;
|
||||||
|
private static String pathToClassFile;
|
||||||
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/Tph2.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
compiler.generateBytecode(pathToClassFile);
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("Tph2");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
private static String path;
|
@Test
|
||||||
private static File fileToTest;
|
public void test1() throws Exception {
|
||||||
private static JavaTXCompiler compiler;
|
Method m = classToTest.getDeclaredMethod("m", Object.class, Object.class);
|
||||||
private static ClassLoader loader;
|
Object result = m.invoke(instanceOfClass, 1,2);
|
||||||
private static Class<?> classToTest;
|
|
||||||
private static String pathToClassFile;
|
assertEquals(1,result);
|
||||||
private static Object instanceOfClass;
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@Test
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public void test2() throws Exception {
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/Tph2.jav";
|
Method m = classToTest.getDeclaredMethod("m", Object.class, Object.class);
|
||||||
fileToTest = new File(path);
|
Object result = m.invoke(instanceOfClass, "sss",2);
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
assertEquals("sss",result);
|
||||||
compiler.generateBytecode(pathToClassFile);
|
}
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
|
||||||
classToTest = loader.loadClass("Tph2");
|
@Test
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
public void test3() throws Exception {
|
||||||
}
|
Method m = classToTest.getDeclaredMethod("m2", Object.class, Object.class);
|
||||||
|
Object result = m.invoke(instanceOfClass, 1,2);
|
||||||
@Test
|
|
||||||
public void test1() throws Exception {
|
assertEquals(2,result);
|
||||||
Method m = classToTest.getDeclaredMethod("m", Object.class, Object.class);
|
}
|
||||||
Object result = m.invoke(instanceOfClass, 1,2);
|
|
||||||
|
@Test
|
||||||
assertEquals(1,result);
|
public void test4() throws Exception {
|
||||||
}
|
Method m = classToTest.getDeclaredMethod("m2", Object.class, Object.class);
|
||||||
|
Object result = m.invoke(instanceOfClass, 1,"xxx");
|
||||||
@Test
|
|
||||||
public void test2() throws Exception {
|
assertEquals("xxx",result);
|
||||||
Method m = classToTest.getDeclaredMethod("m", Object.class, Object.class);
|
}
|
||||||
Object result = m.invoke(instanceOfClass, "sss",2);
|
|
||||||
|
|
||||||
assertEquals("sss",result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test3() throws Exception {
|
|
||||||
Method m = classToTest.getDeclaredMethod("m2", Object.class, Object.class);
|
|
||||||
Object result = m.invoke(instanceOfClass, 1,2);
|
|
||||||
|
|
||||||
assertEquals(2,result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test4() throws Exception {
|
|
||||||
Method m = classToTest.getDeclaredMethod("m2", Object.class, Object.class);
|
|
||||||
Object result = m.invoke(instanceOfClass, 1,"xxx");
|
|
||||||
|
|
||||||
assertEquals("xxx",result);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,19 +13,19 @@ import org.junit.Test;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class Tph3Test {
|
public class Tph3Test {
|
||||||
|
|
||||||
private static String path;
|
private static String path;
|
||||||
private static File fileToTest;
|
private static File fileToTest;
|
||||||
private static JavaTXCompiler compiler;
|
private static JavaTXCompiler compiler;
|
||||||
private static String pathToClassFile;
|
private static String pathToClassFile;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void generateBC() throws Exception {
|
public void generateBC() throws Exception {
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/Tph3.jav";
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/Tph3.jav";
|
||||||
fileToTest = new File(path);
|
fileToTest = new File(path);
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
compiler.generateBytecode(pathToClassFile);
|
compiler.generateBytecode(pathToClassFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,33 +13,33 @@ import org.junit.Test;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class Tph5Test {
|
public class Tph5Test {
|
||||||
|
|
||||||
|
private static String path;
|
||||||
|
private static File fileToTest;
|
||||||
|
private static JavaTXCompiler compiler;
|
||||||
|
private static ClassLoader loader;
|
||||||
|
private static Class<?> classToTest;
|
||||||
|
private static String pathToClassFile;
|
||||||
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/Tph5.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
compiler.generateBytecode(pathToClassFile);
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("Tph5");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
private static String path;
|
@Test
|
||||||
private static File fileToTest;
|
public void test() throws Exception {
|
||||||
private static JavaTXCompiler compiler;
|
|
||||||
private static ClassLoader loader;
|
|
||||||
private static Class<?> classToTest;
|
|
||||||
private static String pathToClassFile;
|
|
||||||
private static Object instanceOfClass;
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
public static void setUpBeforeClass() throws Exception {
|
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/Tph5.jav";
|
|
||||||
fileToTest = new File(path);
|
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
|
||||||
compiler.generateBytecode(pathToClassFile);
|
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
|
||||||
classToTest = loader.loadClass("Tph5");
|
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test() throws Exception {
|
|
||||||
// Method m = classToTest.getDeclaredMethod("m", Object.class, Object.class, Object.class);
|
// Method m = classToTest.getDeclaredMethod("m", Object.class, Object.class, Object.class);
|
||||||
Method m = classToTest.getDeclaredMethod("m", Object.class, Object.class);
|
Method m = classToTest.getDeclaredMethod("m", Object.class, Object.class);
|
||||||
// Object result = m.invoke(instanceOfClass, "xx",2,3);
|
// Object result = m.invoke(instanceOfClass, "xx",2,3);
|
||||||
|
|
||||||
//assertEquals(2,result);
|
//assertEquals(2,result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,57 +13,57 @@ import org.junit.Test;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class TphTest {
|
public class TphTest {
|
||||||
|
|
||||||
|
private static String path;
|
||||||
|
private static File fileToTest;
|
||||||
|
private static JavaTXCompiler compiler;
|
||||||
|
private static ClassLoader loader;
|
||||||
|
private static Class<?> classToTest;
|
||||||
|
private static String pathToClassFile;
|
||||||
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/Tph.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
compiler.generateBytecode(pathToClassFile);
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("Tph");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
private static String path;
|
@Test
|
||||||
private static File fileToTest;
|
public void test1() throws Exception {
|
||||||
private static JavaTXCompiler compiler;
|
Method m = classToTest.getDeclaredMethod("m", Object.class, Object.class);
|
||||||
private static ClassLoader loader;
|
Object result = m.invoke(instanceOfClass, 1,2);
|
||||||
private static Class<?> classToTest;
|
|
||||||
private static String pathToClassFile;
|
assertEquals(2,result);
|
||||||
private static Object instanceOfClass;
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@Test
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public void test2() throws Exception {
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/Tph.jav";
|
Method m = classToTest.getDeclaredMethod("m", Object.class, Object.class);
|
||||||
fileToTest = new File(path);
|
Object result = m.invoke(instanceOfClass, 1, "sss");
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
assertEquals("sss",result);
|
||||||
compiler.generateBytecode(pathToClassFile);
|
}
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
|
||||||
classToTest = loader.loadClass("Tph");
|
@Test
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
public void test3() throws Exception {
|
||||||
}
|
Method m = classToTest.getDeclaredMethod("m2", Object.class);
|
||||||
|
Object result = m.invoke(instanceOfClass, 2);
|
||||||
@Test
|
|
||||||
public void test1() throws Exception {
|
assertEquals(2,result);
|
||||||
Method m = classToTest.getDeclaredMethod("m", Object.class, Object.class);
|
}
|
||||||
Object result = m.invoke(instanceOfClass, 1,2);
|
|
||||||
|
@Test
|
||||||
assertEquals(2,result);
|
public void test4() throws Exception {
|
||||||
}
|
Method m = classToTest.getDeclaredMethod("m2", Object.class);
|
||||||
|
Object result = m.invoke(instanceOfClass,"xxx");
|
||||||
@Test
|
|
||||||
public void test2() throws Exception {
|
assertEquals("xxx",result);
|
||||||
Method m = classToTest.getDeclaredMethod("m", Object.class, Object.class);
|
}
|
||||||
Object result = m.invoke(instanceOfClass, 1, "sss");
|
|
||||||
|
|
||||||
assertEquals("sss",result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test3() throws Exception {
|
|
||||||
Method m = classToTest.getDeclaredMethod("m2", Object.class);
|
|
||||||
Object result = m.invoke(instanceOfClass, 2);
|
|
||||||
|
|
||||||
assertEquals(2,result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void test4() throws Exception {
|
|
||||||
Method m = classToTest.getDeclaredMethod("m2", Object.class);
|
|
||||||
Object result = m.invoke(instanceOfClass,"xxx");
|
|
||||||
|
|
||||||
assertEquals("xxx",result);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,45 +14,45 @@ import org.junit.Test;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class WhileTest {
|
public class WhileTest {
|
||||||
private static String path;
|
private static String path;
|
||||||
private static File fileToTest;
|
private static File fileToTest;
|
||||||
private static JavaTXCompiler compiler;
|
private static JavaTXCompiler compiler;
|
||||||
private static ClassLoader loader;
|
private static ClassLoader loader;
|
||||||
private static Class<?> classToTest;
|
private static Class<?> classToTest;
|
||||||
private static String pathToClassFile;
|
private static String pathToClassFile;
|
||||||
private static Object instanceOfClass;
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/While.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
compiler.generateBytecode(pathToClassFile);
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("While");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
@BeforeClass
|
@Test
|
||||||
public static void setUpBeforeClass() throws Exception {
|
public void test() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/While.jav";
|
Method m = classToTest.getDeclaredMethod("m", Integer.class);
|
||||||
fileToTest = new File(path);
|
Integer result = (Integer) m.invoke(instanceOfClass, 0);
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
assertEquals(2, result);
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
}
|
||||||
compiler.generateBytecode(pathToClassFile);
|
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
@Test
|
||||||
classToTest = loader.loadClass("While");
|
public void testDouble() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
Method m = classToTest.getDeclaredMethod("m", Double.class);
|
||||||
}
|
Double result = (Double) m.invoke(instanceOfClass, 0.0);
|
||||||
|
assertEquals(2.0, result);
|
||||||
@Test
|
}
|
||||||
public void test() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method m = classToTest.getDeclaredMethod("m", Integer.class);
|
@Test
|
||||||
Integer result = (Integer) m.invoke(instanceOfClass, 0);
|
public void testLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
assertEquals(Integer.valueOf(2), result);
|
Method m = classToTest.getDeclaredMethod("m", Long.class);
|
||||||
}
|
Long result = (Long) m.invoke(instanceOfClass, 0l);
|
||||||
|
assertEquals(2l, result);
|
||||||
@Test
|
}
|
||||||
public void testDouble() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method m = classToTest.getDeclaredMethod("m", Double.class);
|
|
||||||
Double result = (Double) m.invoke(instanceOfClass, 0.0);
|
|
||||||
assertEquals(Double.valueOf(2.0), result);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testLong() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
||||||
Method m = classToTest.getDeclaredMethod("m", Long.class);
|
|
||||||
Long result = (Long) m.invoke(instanceOfClass, 0l);
|
|
||||||
assertEquals(Long.valueOf(2l), result);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,47 +8,45 @@ import java.lang.reflect.Method;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
|
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class YTest {
|
public class YTest {
|
||||||
private static String path;
|
private static String path;
|
||||||
private static File fileToTest;
|
private static File fileToTest;
|
||||||
private static JavaTXCompiler compiler;
|
private static JavaTXCompiler compiler;
|
||||||
private static ClassLoader loader;
|
private static ClassLoader loader;
|
||||||
private static Class<?> classToTest;
|
private static Class<?> classToTest;
|
||||||
private static String pathToClassFile;
|
private static String pathToClassFile;
|
||||||
private static Object instanceOfClass;
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void generateBC() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/Y.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
// compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
// compiler.generateBytecode(System.getProperty("user.dir")+"/testBytecode/generatedBC/");
|
||||||
|
// pathToClassFile = System.getProperty("user.dir")+"/testBytecode/generatedBC/";
|
||||||
|
// loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
// classToTest = loader.loadClass("Y");
|
||||||
|
/*
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
|
||||||
@Test
|
Method m = classToTest.getDeclaredMethod("m");
|
||||||
@Ignore
|
Class<?> lambda = m.invoke(instanceOfClass).getClass();
|
||||||
public void generateBC() throws Exception {
|
Method apply = lambda.getMethod("apply", Object.class);
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/Y.jav";
|
|
||||||
fileToTest = new File(path);
|
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
|
||||||
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
|
||||||
classToTest = loader.loadClass("Y");
|
|
||||||
/*
|
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
|
||||||
|
|
||||||
Method m = classToTest.getDeclaredMethod("m");
|
// Damit man auf die Methode zugreifen kann
|
||||||
Class<?> lambda = m.invoke(instanceOfClass).getClass();
|
apply.setAccessible(true);
|
||||||
Method apply = lambda.getMethod("apply", Object.class);
|
|
||||||
|
|
||||||
// Damit man auf die Methode zugreifen kann
|
Integer i = 77;
|
||||||
apply.setAccessible(true);
|
|
||||||
|
Integer result = (Integer) apply.invoke(m.invoke(instanceOfClass), i);
|
||||||
|
|
||||||
Integer i = 77;
|
assertEquals(77, result);
|
||||||
|
*/
|
||||||
Integer result = (Integer) apply.invoke(m.invoke(instanceOfClass), i);
|
}
|
||||||
|
|
||||||
assertEquals(77, result);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,28 +12,28 @@ import org.junit.Test;
|
|||||||
import de.dhbwstuttgart.core.JavaTXCompiler;
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
||||||
|
|
||||||
public class applyLambdaTest {
|
public class applyLambdaTest {
|
||||||
private static String path;
|
private static String path;
|
||||||
private static File fileToTest;
|
private static File fileToTest;
|
||||||
private static JavaTXCompiler compiler;
|
private static JavaTXCompiler compiler;
|
||||||
private static ClassLoader loader;
|
private static ClassLoader loader;
|
||||||
private static Class<?> classToTest;
|
private static Class<?> classToTest;
|
||||||
private static String pathToClassFile;
|
private static String pathToClassFile;
|
||||||
private static Object instanceOfClass;
|
private static Object instanceOfClass;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void generateBC() throws Exception {
|
||||||
|
path = System.getProperty("user.dir")+"/src/test/resources/bytecodeJavFiles/applyLambda.jav";
|
||||||
|
fileToTest = new File(path);
|
||||||
|
compiler = new JavaTXCompiler(fileToTest);
|
||||||
|
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
||||||
|
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
||||||
|
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
||||||
|
classToTest = loader.loadClass("applyLambda");
|
||||||
|
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
||||||
|
|
||||||
@Test
|
Method m = classToTest.getDeclaredMethod("m");
|
||||||
public void generateBC() throws Exception {
|
Object result = m.invoke(instanceOfClass);
|
||||||
path = System.getProperty("user.dir")+"/src/test/resources/javFiles/bytecode/applyLambda.jav";
|
|
||||||
fileToTest = new File(path);
|
assertEquals(result.getClass(), loader.loadClass("Apply"));
|
||||||
compiler = new JavaTXCompiler(fileToTest);
|
}
|
||||||
compiler.generateBytecode(System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/");
|
|
||||||
pathToClassFile = System.getProperty("user.dir")+"/src/test/resources/testBytecode/generatedBC/";
|
|
||||||
loader = new URLClassLoader(new URL[] {new URL("file://"+pathToClassFile)});
|
|
||||||
classToTest = loader.loadClass("applyLambda");
|
|
||||||
instanceOfClass = classToTest.getDeclaredConstructor().newInstance();
|
|
||||||
|
|
||||||
Method m = classToTest.getDeclaredMethod("m");
|
|
||||||
Object result = m.invoke(instanceOfClass);
|
|
||||||
|
|
||||||
assertEquals(result.getClass(), loader.loadClass("Apply"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
77
src/test/java/bytecode/simplifyalgo/CycleTest.java
Normal file
77
src/test/java/bytecode/simplifyalgo/CycleTest.java
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package bytecode.simplifyalgo;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.objectweb.asm.Type;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
||||||
|
import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint;
|
||||||
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||||
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
||||||
|
import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH;
|
||||||
|
import de.dhbwstuttgart.bytecode.utilities.Simplify;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Fayez Abu Alia
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class CycleTest {
|
||||||
|
|
||||||
|
private static TPHExtractor tphExtractor;
|
||||||
|
private static String methName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws java.lang.Exception
|
||||||
|
*/
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
tphExtractor = new TPHExtractor();
|
||||||
|
// A < B
|
||||||
|
TPHConstraint c1 = new ExtendsConstraint("A", "B", Relation.EXTENDS);
|
||||||
|
// B < C
|
||||||
|
TPHConstraint c2 = new ExtendsConstraint("B", "C", Relation.EXTENDS);
|
||||||
|
// C < D
|
||||||
|
TPHConstraint c3 = new ExtendsConstraint("C", "D", Relation.EXTENDS);
|
||||||
|
// D < A
|
||||||
|
TPHConstraint c4 = new ExtendsConstraint("D", "A", Relation.EXTENDS);
|
||||||
|
// name
|
||||||
|
methName = "m";
|
||||||
|
MethodAndTPH mtph = new MethodAndTPH("m");
|
||||||
|
mtph.getTphs().add("A");
|
||||||
|
mtph.getTphs().add("B");
|
||||||
|
mtph.getTphs().add("C");
|
||||||
|
mtph.getTphs().add("D");
|
||||||
|
tphExtractor.ListOfMethodsAndTph.add(mtph);
|
||||||
|
tphExtractor.allCons.add(c1);
|
||||||
|
tphExtractor.allCons.add(c2);
|
||||||
|
tphExtractor.allCons.add(c3);
|
||||||
|
tphExtractor.allCons.add(c4);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() {
|
||||||
|
HashMap<TPHConstraint, HashSet<String>> result = new HashMap<>();
|
||||||
|
HashSet<String> equals = new HashSet<>();
|
||||||
|
equals.add("A");
|
||||||
|
equals.add("B");
|
||||||
|
equals.add("C");
|
||||||
|
equals.add("D");
|
||||||
|
TPHConstraint k = new ExtendsConstraint("A", Type.getInternalName(Object.class), Relation.EXTENDS);
|
||||||
|
result.put(k, equals);
|
||||||
|
|
||||||
|
HashMap<TPHConstraint, HashSet<String>> sim = Simplify.simplifyConstraints(methName, tphExtractor,new ArrayList<>());
|
||||||
|
boolean areEquals = SimpleCycle.areMapsEqual(result, sim);
|
||||||
|
assertTrue(areEquals);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
102
src/test/java/bytecode/simplifyalgo/SameLeftSide.java
Normal file
102
src/test/java/bytecode/simplifyalgo/SameLeftSide.java
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
package bytecode.simplifyalgo;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.objectweb.asm.Type;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
||||||
|
import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint;
|
||||||
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||||
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
||||||
|
import de.dhbwstuttgart.bytecode.utilities.MethodAndTPH;
|
||||||
|
import de.dhbwstuttgart.bytecode.utilities.Simplify;
|
||||||
|
import de.dhbwstuttgart.typedeployment.TypeInsertPlacer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Fayez Abu Alia
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SameLeftSide {
|
||||||
|
// Typeplaceholders können nicht definiert werden, da die Konstruktor
|
||||||
|
// private ist => Test geht nicht
|
||||||
|
private static TPHExtractor tphExtractor;
|
||||||
|
private static String methName;
|
||||||
|
private static String methName2;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
tphExtractor = new TPHExtractor();
|
||||||
|
// A < B
|
||||||
|
TPHConstraint c1 = new ExtendsConstraint("A", "B", Relation.EXTENDS);
|
||||||
|
// A < C
|
||||||
|
TPHConstraint c2 = new ExtendsConstraint("A", "C", Relation.EXTENDS);
|
||||||
|
// B < D
|
||||||
|
TPHConstraint c3 = new ExtendsConstraint("B", "D", Relation.EXTENDS);
|
||||||
|
// C < E
|
||||||
|
TPHConstraint c4 = new ExtendsConstraint("C", "E", Relation.EXTENDS);
|
||||||
|
// name
|
||||||
|
methName = "m1";
|
||||||
|
MethodAndTPH m1 = new MethodAndTPH("m1");
|
||||||
|
|
||||||
|
methName2 = "m2";
|
||||||
|
MethodAndTPH m2 = new MethodAndTPH("m2");
|
||||||
|
|
||||||
|
m1.getTphs().add("A");
|
||||||
|
m1.getTphs().add("B");
|
||||||
|
m1.getTphs().add("D");
|
||||||
|
|
||||||
|
m2.getTphs().add("C");
|
||||||
|
m2.getTphs().add("E");
|
||||||
|
|
||||||
|
tphExtractor.ListOfMethodsAndTph.add(m1);
|
||||||
|
tphExtractor.ListOfMethodsAndTph.add(m2);
|
||||||
|
|
||||||
|
tphExtractor.allCons.add(c1);
|
||||||
|
tphExtractor.allCons.add(c2);
|
||||||
|
tphExtractor.allCons.add(c3);
|
||||||
|
tphExtractor.allCons.add(c4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testM1() {
|
||||||
|
HashMap<TPHConstraint, HashSet<String>> result = new HashMap<>();
|
||||||
|
|
||||||
|
TPHConstraint d = new ExtendsConstraint("D", Type.getInternalName(Object.class), Relation.EXTENDS);
|
||||||
|
TPHConstraint a = new ExtendsConstraint("A", "D", Relation.EXTENDS);
|
||||||
|
TPHConstraint b = new ExtendsConstraint("B", "D", Relation.EXTENDS);
|
||||||
|
result.put(d, new HashSet<>());
|
||||||
|
result.put(a, new HashSet<>());
|
||||||
|
HashSet<String> hs = new HashSet<>();
|
||||||
|
|
||||||
|
result.put(b, hs);
|
||||||
|
|
||||||
|
HashMap<TPHConstraint, HashSet<String>> sim = Simplify.simplifyConstraints(methName, tphExtractor,new ArrayList<>());
|
||||||
|
boolean areEquals = SimpleCycle.areMapsEqual(result, sim);
|
||||||
|
assertTrue(areEquals);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testM2() {
|
||||||
|
HashMap<TPHConstraint, HashSet<String>> result = new HashMap<>();
|
||||||
|
|
||||||
|
TPHConstraint e = new ExtendsConstraint("E", Type.getInternalName(Object.class), Relation.EXTENDS);
|
||||||
|
TPHConstraint c = new ExtendsConstraint("C", "E", Relation.EXTENDS);
|
||||||
|
|
||||||
|
result.put(e, new HashSet<>());
|
||||||
|
HashSet<String> hs = new HashSet<>();
|
||||||
|
hs.add("B");
|
||||||
|
result.put(c, hs);
|
||||||
|
|
||||||
|
HashMap<TPHConstraint, HashSet<String>> sim = Simplify.simplifyConstraints(methName2, tphExtractor,new ArrayList<>());
|
||||||
|
boolean areEquals = SimpleCycle.areMapsEqual(result, sim);
|
||||||
|
assertTrue(areEquals);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
80
src/test/java/bytecode/simplifyalgo/SimpleCycle.java
Normal file
80
src/test/java/bytecode/simplifyalgo/SimpleCycle.java
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
package bytecode.simplifyalgo;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.objectweb.asm.Type;
|
||||||
|
|
||||||
|
import de.dhbwstuttgart.bytecode.TPHExtractor;
|
||||||
|
import de.dhbwstuttgart.bytecode.constraint.ExtendsConstraint;
|
||||||
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint;
|
||||||
|
import de.dhbwstuttgart.bytecode.constraint.TPHConstraint.Relation;
|
||||||
|
import de.dhbwstuttgart.bytecode.utilities.Simplify;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Fayez Abu Alia
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SimpleCycle {
|
||||||
|
private static TPHExtractor tphExtractor;
|
||||||
|
private static String methName;
|
||||||
|
@BeforeClass
|
||||||
|
public static void setUpBeforeClass() throws Exception {
|
||||||
|
tphExtractor = new TPHExtractor();
|
||||||
|
// A < B
|
||||||
|
TPHConstraint c1 = new ExtendsConstraint("A", "B", Relation.EXTENDS);
|
||||||
|
// B < A
|
||||||
|
TPHConstraint c2 = new ExtendsConstraint("B", "A", Relation.EXTENDS);
|
||||||
|
// name
|
||||||
|
methName = "m";
|
||||||
|
tphExtractor.allCons.add(c1);
|
||||||
|
tphExtractor.allCons.add(c2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test() {
|
||||||
|
HashMap<TPHConstraint, HashSet<String>> result = new HashMap<>();
|
||||||
|
HashSet<String> equals = new HashSet<>();
|
||||||
|
equals.add("A");
|
||||||
|
equals.add("B");
|
||||||
|
TPHConstraint k = new ExtendsConstraint("B", Type.getInternalName(Object.class), Relation.EXTENDS);
|
||||||
|
result.put(k, equals);
|
||||||
|
|
||||||
|
HashMap<TPHConstraint, HashSet<String>> sim = Simplify.simplifyConstraints(methName, tphExtractor,new ArrayList<>());
|
||||||
|
boolean areEquals = areMapsEqual(result, sim);
|
||||||
|
assertTrue(areEquals);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean areMapsEqual(HashMap<TPHConstraint, HashSet<String>> m1, HashMap<TPHConstraint, HashSet<String>> m2) {
|
||||||
|
|
||||||
|
for(TPHConstraint c : m1.keySet()) {
|
||||||
|
for(TPHConstraint c2 : m2.keySet()) {
|
||||||
|
if(c.getLeft().equals(c2.getLeft()) && c.getRight().equals(c2.getRight()) && c.getRel()==c2.getRel()) {
|
||||||
|
HashSet<String> eq1 = m1.get(c);
|
||||||
|
HashSet<String> eq2 = m2.get(c2);
|
||||||
|
|
||||||
|
if((eq1 == null && eq2 != null) || (eq1 != null && eq2 == null))
|
||||||
|
return false;
|
||||||
|
if(eq1 != null) {
|
||||||
|
if(eq1.size() != eq2.size())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for(String tph:eq1) {
|
||||||
|
if(!eq2.contains(tph))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
9
src/test/java/javFiles/AddLong.jav
Normal file
9
src/test/java/javFiles/AddLong.jav
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import java.lang.Integer;
|
||||||
|
import java.lang.Long;
|
||||||
|
|
||||||
|
public class AddLong{
|
||||||
|
Long add(Integer a, Long b) {
|
||||||
|
Long c = a+b;
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
3
src/test/java/javFiles/EmptyClass.jav
Normal file
3
src/test/java/javFiles/EmptyClass.jav
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
public class EmptyClass{
|
||||||
|
|
||||||
|
}
|
37
src/test/java/javFiles/EmptyMethod.jav
Normal file
37
src/test/java/javFiles/EmptyMethod.jav
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
public class EmptyMethod{
|
||||||
|
static String s1 ="";
|
||||||
|
String s2;
|
||||||
|
public void m1(){
|
||||||
|
//String s = "";
|
||||||
|
System.out.println("test");
|
||||||
|
//Integer ab = Math.abs(1);
|
||||||
|
//Math.abs(1);
|
||||||
|
//String lV = "local";
|
||||||
|
//s1 = "1";
|
||||||
|
//s1.concat("2");
|
||||||
|
s2 = s1;
|
||||||
|
//m2();
|
||||||
|
Clazz i = new Clazz();
|
||||||
|
Integer i = new Integer(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void m2(){}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Clazz{}
|
||||||
|
/*
|
||||||
|
public class EmptyMethod2{
|
||||||
|
public static test = "5";
|
||||||
|
public void m1(Integer i, String j, Boolean b){
|
||||||
|
//String s = "";
|
||||||
|
EmptyMethod em = new EmptyMethod();
|
||||||
|
em.m1();
|
||||||
|
em.s1 = "";
|
||||||
|
//Integer ab = Math.abs(1);
|
||||||
|
//Math.abs(1);
|
||||||
|
//String lV = "local";
|
||||||
|
//s1 = "1";
|
||||||
|
//s1.concat("2");
|
||||||
|
//s2 = s1;
|
||||||
|
}
|
||||||
|
}*/
|
8
src/test/java/javFiles/Expressions.jav
Normal file
8
src/test/java/javFiles/Expressions.jav
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
class Expressions{
|
||||||
|
|
||||||
|
void test(){
|
||||||
|
var x = 2;
|
||||||
|
x = x + 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
10
src/test/java/javFiles/FC_Matrix.jav
Normal file
10
src/test/java/javFiles/FC_Matrix.jav
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
class Matrix extends Vector<Vector<Integer>> {
|
||||||
|
|
||||||
|
methode(m) {
|
||||||
|
m.add(1);
|
||||||
|
Matrix i;
|
||||||
|
methode(i);
|
||||||
|
}
|
||||||
|
}
|
15
src/test/java/javFiles/Faculty.jav
Normal file
15
src/test/java/javFiles/Faculty.jav
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import java.lang.Integer;
|
||||||
|
|
||||||
|
class Faculty {
|
||||||
|
|
||||||
|
Integer mul(Integer x, Integer y) {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
m () {
|
||||||
|
var fact = (Integer x) -> {
|
||||||
|
return mul(x, fact.apply(x));
|
||||||
|
};
|
||||||
|
return fact;
|
||||||
|
}
|
||||||
|
}
|
17
src/test/java/javFiles/FacultyIf.jav
Normal file
17
src/test/java/javFiles/FacultyIf.jav
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import java.lang.Integer;
|
||||||
|
|
||||||
|
class Faculty {
|
||||||
|
|
||||||
|
m () {
|
||||||
|
|
||||||
|
var fact = (Integer x) -> {
|
||||||
|
if (x == 1) {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return x * (fact.apply(x-1));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return fact;
|
||||||
|
}
|
||||||
|
}
|
19
src/test/java/javFiles/FacultyTyped.jav
Normal file
19
src/test/java/javFiles/FacultyTyped.jav
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import java.lang.Integer;
|
||||||
|
|
||||||
|
class Faculty {
|
||||||
|
|
||||||
|
Integer mul(Integer x, Integer y) {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
Fun1<java.lang.Integer,java.lang.Integer> m () {
|
||||||
|
var fact = (Integer x) -> {
|
||||||
|
return mul(x, fact.apply(x));
|
||||||
|
};
|
||||||
|
return fact;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Fun1<A,B>{
|
||||||
|
B apply(A a);
|
||||||
|
}
|
11
src/test/java/javFiles/Fields.jav
Normal file
11
src/test/java/javFiles/Fields.jav
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import java.lang.String;
|
||||||
|
|
||||||
|
class Fields{
|
||||||
|
test2 = "test";
|
||||||
|
test;
|
||||||
|
m(){
|
||||||
|
var test3;
|
||||||
|
return test;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
22
src/test/java/javFiles/Generics.jav
Normal file
22
src/test/java/javFiles/Generics.jav
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import java.lang.String;
|
||||||
|
|
||||||
|
class Generics<B> {
|
||||||
|
//<A extends B> A mt1(A a, B b){
|
||||||
|
B mt1(B a, B b){
|
||||||
|
return mt1(a, a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Test {
|
||||||
|
methode(String s){
|
||||||
|
return new Generics<String>().mt1(s,s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Problem:
|
||||||
|
auto test = new List<String>();
|
||||||
|
auto test2 = new List<Integer>();
|
||||||
|
... //code, welcher möglicherweise test und test2 vertauscht
|
||||||
|
test.add("hallo");
|
||||||
|
*/
|
14
src/test/java/javFiles/IfTest.jav
Normal file
14
src/test/java/javFiles/IfTest.jav
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import java.lang.Integer;
|
||||||
|
import java.lang.Boolean;
|
||||||
|
import java.lang.Object;
|
||||||
|
|
||||||
|
public class IfTest{
|
||||||
|
Object m1(b) {
|
||||||
|
Integer i;
|
||||||
|
if(b) {
|
||||||
|
return i;
|
||||||
|
}else{
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
8
src/test/java/javFiles/Import.jav
Normal file
8
src/test/java/javFiles/Import.jav
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
class Import {
|
||||||
|
void methode(){
|
||||||
|
Vector v;
|
||||||
|
v.add(v);
|
||||||
|
}
|
||||||
|
}
|
13
src/test/java/javFiles/Lambda.jav
Normal file
13
src/test/java/javFiles/Lambda.jav
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
class Apply { }
|
||||||
|
|
||||||
|
public class Lambda {
|
||||||
|
|
||||||
|
m () {
|
||||||
|
var lam1 = (x) -> {
|
||||||
|
return x;
|
||||||
|
};
|
||||||
|
return lam1.apply(new Apply());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
33
src/test/java/javFiles/Lambda2.jav
Normal file
33
src/test/java/javFiles/Lambda2.jav
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import java.lang.String;
|
||||||
|
|
||||||
|
public class Lambda2
|
||||||
|
{
|
||||||
|
public static void main(List<String> args){
|
||||||
|
var listOfStrings = new List<String>();
|
||||||
|
var listOfObjects;
|
||||||
|
listOfObjects = map(listOfStrings, (a) -> a);
|
||||||
|
}
|
||||||
|
|
||||||
|
public map(a , b){
|
||||||
|
b.apply(a);
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
public static <I,O> List<O> map(List<I> input, Function<I,O> func) {
|
||||||
|
List<O> output;
|
||||||
|
output = new List<O>();
|
||||||
|
output.add(func.apply(input.get()));
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
class List<A>{
|
||||||
|
A get();
|
||||||
|
void add(A);
|
||||||
|
}
|
||||||
|
|
||||||
|
class Function<A,B>{
|
||||||
|
B apply(A a);
|
||||||
|
}
|
24
src/test/java/javFiles/Lambda3.jav
Normal file
24
src/test/java/javFiles/Lambda3.jav
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import java.lang.String;
|
||||||
|
|
||||||
|
public class Lambda2
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
public static <A> List<A> map(List<? extends A> input,
|
||||||
|
Function<? super A, ? extends A> func){
|
||||||
|
input.add(func.apply(input.get()));
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
public map(input,func){
|
||||||
|
input.add(func.apply(input.get()));
|
||||||
|
return map(new List<String>(), func);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class List<A>{
|
||||||
|
A get();
|
||||||
|
void add(A);
|
||||||
|
}
|
||||||
|
|
||||||
|
class Function<A,B>{
|
||||||
|
B apply(A a);
|
||||||
|
}
|
6
src/test/java/javFiles/LambdaField.jav
Normal file
6
src/test/java/javFiles/LambdaField.jav
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
public class LambdaField {
|
||||||
|
|
||||||
|
f = x -> x;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
14
src/test/java/javFiles/LambdaRunnable.jav
Normal file
14
src/test/java/javFiles/LambdaRunnable.jav
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import java.lang.Runnable;
|
||||||
|
import java.lang.String;
|
||||||
|
import java.lang.System;
|
||||||
|
|
||||||
|
public class LamRunnable{
|
||||||
|
|
||||||
|
public LamRunnable(){
|
||||||
|
|
||||||
|
|
||||||
|
Runnable lam = () -> {System.out.println("lambda");};
|
||||||
|
lam.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
20
src/test/java/javFiles/ListenerOverload.jav
Normal file
20
src/test/java/javFiles/ListenerOverload.jav
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import java.lang.Integer;
|
||||||
|
import java.lang.String;
|
||||||
|
|
||||||
|
class ListenerOverload{
|
||||||
|
|
||||||
|
call(p){
|
||||||
|
call(p.left);
|
||||||
|
call(p.right);
|
||||||
|
}
|
||||||
|
|
||||||
|
call(Integer i){}
|
||||||
|
|
||||||
|
call(String s){}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class Pair<A,B>{
|
||||||
|
A left;
|
||||||
|
B right;
|
||||||
|
}
|
28
src/test/java/javFiles/Matrix.jav
Normal file
28
src/test/java/javFiles/Matrix.jav
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import java.util.Vector;
|
||||||
|
import java.lang.Integer;
|
||||||
|
|
||||||
|
class Matrix extends Vector<Vector<Integer>> {
|
||||||
|
Integer mul1(Integer x, Integer y) { return x;}
|
||||||
|
Integer add1(Integer x, Integer y) { return x;}
|
||||||
|
mul(m) {
|
||||||
|
var ret = new Matrix();
|
||||||
|
var i = 0;
|
||||||
|
while(i < size()) {
|
||||||
|
var v1 = this.elementAt(i);
|
||||||
|
var v2 = new Vector<Integer>();
|
||||||
|
var j = 0;
|
||||||
|
while(j < v1.size()) {
|
||||||
|
var erg = 0;
|
||||||
|
var k = 0;
|
||||||
|
while(k < v1.size()) {
|
||||||
|
erg = erg + v1.elementAt(k) * m.elementAt(k).elementAt(j);
|
||||||
|
//erg = add1(erg, mul1(v1.elementAt(k),
|
||||||
|
// m.elementAt(k).elementAt(j)));
|
||||||
|
k++; }
|
||||||
|
v2.addElement(new Integer(erg));
|
||||||
|
j++; }
|
||||||
|
ret.addElement(v2);
|
||||||
|
i++; }
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
11
src/test/java/javFiles/Meth_Gen.jav
Normal file
11
src/test/java/javFiles/Meth_Gen.jav
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
class Meth_Gen {
|
||||||
|
|
||||||
|
m1(x, y) {
|
||||||
|
m2(x);
|
||||||
|
x = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
m2(y) {
|
||||||
|
m1(y, y);
|
||||||
|
}
|
||||||
|
}
|
14
src/test/java/javFiles/MethodCallGenerics.jav
Normal file
14
src/test/java/javFiles/MethodCallGenerics.jav
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import java.lang.String;
|
||||||
|
|
||||||
|
class Generics<B> {
|
||||||
|
//<A extends B> A mt1(A a, B b){
|
||||||
|
B mt1(B a, B b){
|
||||||
|
return mt1(a, a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Test {
|
||||||
|
methode(String s){
|
||||||
|
return new Generics<String>().mt1(s,s);
|
||||||
|
}
|
||||||
|
}
|
17
src/test/java/javFiles/Methods.jav
Normal file
17
src/test/java/javFiles/Methods.jav
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
class Methods {
|
||||||
|
mt4(a,b,c) { return a.add(b).sub(c) ; }
|
||||||
|
|
||||||
|
mt1(a) {return a;}
|
||||||
|
|
||||||
|
mt2(a) {return a.f; }
|
||||||
|
|
||||||
|
mt3(a) {return a.add(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
class Test {
|
||||||
|
java.lang.Object f;
|
||||||
|
add(){}
|
||||||
|
add(b){return b;}
|
||||||
|
sub(b){}
|
||||||
|
}
|
7
src/test/java/javFiles/MethodsEasy.jav
Normal file
7
src/test/java/javFiles/MethodsEasy.jav
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
class Methods {
|
||||||
|
mt4(a,b,c) { return a.mt3(b).mt3(c) ; }
|
||||||
|
|
||||||
|
mt3(a) {return a.mt3(a); }
|
||||||
|
}
|
||||||
|
|
11
src/test/java/javFiles/Op1.jav
Normal file
11
src/test/java/javFiles/Op1.jav
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
public class Op1{
|
||||||
|
public Op1() {
|
||||||
|
|
||||||
|
Runnable lam = () -> {
|
||||||
|
String test = "";
|
||||||
|
String b = "b";
|
||||||
|
test = b;
|
||||||
|
System.out.println(test);};
|
||||||
|
//lam.run();
|
||||||
|
}
|
||||||
|
}
|
5
src/test/java/javFiles/Package.jav
Normal file
5
src/test/java/javFiles/Package.jav
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package strucType.input;
|
||||||
|
|
||||||
|
class Neu
|
||||||
|
{
|
||||||
|
}
|
8
src/test/java/javFiles/Sorting.jav
Normal file
8
src/test/java/javFiles/Sorting.jav
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import java.util.List;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
class Sorting{
|
||||||
|
void merge(a, b){
|
||||||
|
a.addAll(b);
|
||||||
|
}
|
||||||
|
}
|
6
src/test/java/javFiles/Subclass.jav
Normal file
6
src/test/java/javFiles/Subclass.jav
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
public class Subclass extends Superclass {
|
||||||
|
|
||||||
|
public void printMethod() {
|
||||||
|
super.printMethod();
|
||||||
|
}
|
||||||
|
}
|
6
src/test/java/javFiles/Superclass.jav
Normal file
6
src/test/java/javFiles/Superclass.jav
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
public class Superclass {
|
||||||
|
|
||||||
|
public void printMethod() {
|
||||||
|
System.out.println("Printed in Superclass.");
|
||||||
|
}
|
||||||
|
}
|
23
src/test/java/javFiles/Vector.jav
Normal file
23
src/test/java/javFiles/Vector.jav
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Vector;
|
||||||
|
import java.lang.Object;
|
||||||
|
|
||||||
|
class MyVector{
|
||||||
|
|
||||||
|
id(x){
|
||||||
|
Object i;
|
||||||
|
x.add(i);
|
||||||
|
x.add(i);
|
||||||
|
x.add(i);
|
||||||
|
x.add(i);
|
||||||
|
x.add(i);
|
||||||
|
x.add(i);
|
||||||
|
x.add(i);
|
||||||
|
x.add(i);
|
||||||
|
x.add(i);
|
||||||
|
x.add(i);
|
||||||
|
x.add(i);
|
||||||
|
x.add(i);
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
}
|
18
src/test/java/javFiles/fc.jav
Normal file
18
src/test/java/javFiles/fc.jav
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
class Test{
|
||||||
|
methode(param1, param2, param3) {
|
||||||
|
param2.add(param3);
|
||||||
|
return param1.meth(param2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Klasse1{
|
||||||
|
Klasse1 meth(List p);
|
||||||
|
Klasse1 meth(Klasse2 p);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Klasse2{
|
||||||
|
Klasse1 meth(Klasse1 p);
|
||||||
|
Klasse2 meth(Klasse2 p);
|
||||||
|
}
|
13
src/test/java/javFiles/mathStruc.jav
Normal file
13
src/test/java/javFiles/mathStruc.jav
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
class mathStruc<A> {
|
||||||
|
|
||||||
|
mathStruc(A a) { }
|
||||||
|
|
||||||
|
A model(){ A a; return a; }
|
||||||
|
|
||||||
|
methode(){
|
||||||
|
var innerOp = o -> ms ->
|
||||||
|
new mathStruc<A>(o.apply(this.model(),ms.model()));
|
||||||
|
return innerOp;
|
||||||
|
}
|
||||||
|
}
|
15
src/test/java/javFiles/test.jav
Normal file
15
src/test/java/javFiles/test.jav
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
class Test{
|
||||||
|
methode(param1, param2, param3) {
|
||||||
|
return param1.meth(param2.meth(param3));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Klasse1{
|
||||||
|
Klasse1 meth(Klasse1 p);
|
||||||
|
Klasse1 meth(Klasse2 p);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Klasse2{
|
||||||
|
Klasse1 meth(Klasse1 p);
|
||||||
|
Klasse2 meth(Klasse2 p);
|
||||||
|
}
|
7
src/test/java/javFiles/test1.jav
Normal file
7
src/test/java/javFiles/test1.jav
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
class Faculty {
|
||||||
|
|
||||||
|
int a;
|
||||||
|
m (int x) {
|
||||||
|
return a+x;
|
||||||
|
}
|
||||||
|
}
|
24
src/test/java/log4jTesting.xml
Executable file
24
src/test/java/log4jTesting.xml
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||||
|
|
||||||
|
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
|
||||||
|
|
||||||
|
<appender name="CONSOLE" class="de.dhbwstuttgart.logger.ConsoleAppender">
|
||||||
|
<param name="Target" value="System.out"/>
|
||||||
|
|
||||||
|
<layout class="de.dhbwstuttgart.logger.PatternLayout">
|
||||||
|
<param name="ConversionPattern" value="%-15C{1} %-5p [%-9c] %m%n"/>
|
||||||
|
</layout>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<logger name="trtest">
|
||||||
|
<level value="DEBUG"/>
|
||||||
|
<appender-ref ref="CONSOLE"/>
|
||||||
|
</logger>
|
||||||
|
|
||||||
|
<logger name="funcTest">
|
||||||
|
<level value="DEBUG"/>
|
||||||
|
<appender-ref ref="CONSOLE"/>
|
||||||
|
</logger>
|
||||||
|
|
||||||
|
</log4j:configuration>
|
6
src/test/java/parser/AntlrTest.jav
Normal file
6
src/test/java/parser/AntlrTest.jav
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
class Test{
|
||||||
|
method(){
|
||||||
|
if(true)i++;
|
||||||
|
if(true)i--;
|
||||||
|
else i++;
|
||||||
|
}}
|
3
src/test/java/parser/BoundedParameter.jav
Normal file
3
src/test/java/parser/BoundedParameter.jav
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
class Matrix{
|
||||||
|
<A extends B, C extends B> String op = "String";
|
||||||
|
}
|
8
src/test/java/parser/CastTest.jav
Normal file
8
src/test/java/parser/CastTest.jav
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
class CastTest{
|
||||||
|
void methode(){
|
||||||
|
Object a;
|
||||||
|
String b;
|
||||||
|
a = (Object) b;
|
||||||
|
}
|
||||||
|
}
|
4
src/test/java/parser/ExtendsTest.jav
Normal file
4
src/test/java/parser/ExtendsTest.jav
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
class C1 extends Object
|
||||||
|
{
|
||||||
|
m(para) { return para; }
|
||||||
|
}
|
11
src/test/java/parser/FeatherWeightJava.jav
Normal file
11
src/test/java/parser/FeatherWeightJava.jav
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
class FeatherWeightJava {
|
||||||
|
mt4(a,b,c) { return a.add(b).sub(c) ; }
|
||||||
|
|
||||||
|
mt1(a) {return a; }
|
||||||
|
|
||||||
|
mt2(a) {return a.f; }
|
||||||
|
|
||||||
|
mt3(a) {return a.add(); }
|
||||||
|
}
|
||||||
|
|
3
src/test/java/parser/FieldInitializationTest.jav
Normal file
3
src/test/java/parser/FieldInitializationTest.jav
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
class FieldInitializationTest{
|
||||||
|
var var = "hallo";
|
||||||
|
}
|
5
src/test/java/parser/FieldVarTest.jav
Normal file
5
src/test/java/parser/FieldVarTest.jav
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package test;
|
||||||
|
|
||||||
|
class Test<Typ>{
|
||||||
|
Typ a;
|
||||||
|
}
|
@ -20,36 +20,36 @@ import org.junit.Test;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class GeneralParserTest{
|
public class GeneralParserTest{
|
||||||
private static final String rootDirectory = System.getProperty("user.dir")+"/src/test/resources/javFiles/parser/";
|
private static final String rootDirectory = System.getProperty("user.dir")+"/test/parser/";
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void run(){
|
||||||
|
|
||||||
@Test
|
|
||||||
public void run(){
|
List<String> filenames = new ArrayList<String>();
|
||||||
|
/*
|
||||||
|
filenames.add("NewTest.jav");
|
||||||
List<String> filenames = new ArrayList<String>();
|
filenames.add("FieldInitializationTest.jav");
|
||||||
/*
|
filenames.add("ImportTest.jav");
|
||||||
filenames.add("NewTest.jav");
|
filenames.add("CastTest.jav");
|
||||||
filenames.add("FieldInitializationTest.jav");
|
filenames.add("StatementsTest.jav");
|
||||||
filenames.add("ImportTest.jav");
|
//filenames.add("Methods.jav");
|
||||||
filenames.add("CastTest.jav");
|
filenames.add("ImportTestGeneric.jav");
|
||||||
filenames.add("StatementsTest.jav");
|
filenames.add("CastTest.jav");
|
||||||
//filenames.add("Methods.jav");
|
//filenames.add("BoundedParameter.jav");
|
||||||
filenames.add("ImportTestGeneric.jav");
|
//filenames.add("GenericFieldVarTest.jav");
|
||||||
filenames.add("CastTest.jav");
|
filenames.add("FieldVarTest.jav");
|
||||||
//filenames.add("BoundedParameter.jav");
|
filenames.add("StructuralTypes.jav");
|
||||||
//filenames.add("GenericFieldVarTest.jav");
|
*/
|
||||||
filenames.add("FieldVarTest.jav");
|
|
||||||
filenames.add("StructuralTypes.jav");
|
|
||||||
*/
|
|
||||||
// filenames.add("ExtendsTest.jav");
|
// filenames.add("ExtendsTest.jav");
|
||||||
filenames.add("PackageNameTest.jav");
|
filenames.add("PackageNameTest.jav");
|
||||||
try{
|
try{
|
||||||
new JavaTXCompiler(filenames.stream().map(s -> new File(rootDirectory + s)).collect(Collectors.toList()));
|
new JavaTXCompiler(filenames.stream().map(s -> new File(rootDirectory + s)).collect(Collectors.toList()));
|
||||||
}catch(Exception exc){
|
}catch(Exception exc){
|
||||||
exc.printStackTrace();
|
exc.printStackTrace();
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
assertTrue("Tests durchlaufen",filenames.size()>0);
|
assertTrue("Tests durchlaufen",filenames.size()>0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
3
src/test/java/parser/GenericFieldVarTest.jav
Normal file
3
src/test/java/parser/GenericFieldVarTest.jav
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
class Test{
|
||||||
|
<A> A var;
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user