53 lines
1.7 KiB
Java
Executable File
53 lines
1.7 KiB
Java
Executable File
package mycompiler.test.javaConcepts.staticAccess;
|
|
import java.util.Vector;
|
|
|
|
import de.dhbwstuttgart.syntaxtree.type.RefType;
|
|
import de.dhbwstuttgart.syntaxtree.type.Type;
|
|
import mycompiler.test.AbstractInferenceTest;
|
|
import mycompiler.test.expectationTypes.ClassExpect;
|
|
import mycompiler.test.expectationTypes.Expectation;
|
|
import mycompiler.test.expectationTypes.MethodExpect;
|
|
import mycompiler.test.expectationTypes.VarExpect;
|
|
|
|
/**
|
|
* 22-04-08
|
|
* @author
|
|
*
|
|
* Tests static access of a member or methods
|
|
*/
|
|
public class TestStaticAccess extends AbstractInferenceTest {
|
|
|
|
private final static String TESTEDCLASSNAME="TestStaticAccess";
|
|
private final static String JAVPATH="test/mycompiler/test/javaConcepts/staticAccess/";
|
|
|
|
public TestStaticAccess(String name) {
|
|
super(name,TestStaticAccess.JAVPATH+TestStaticAccess.TESTEDCLASSNAME + ".jav");
|
|
|
|
}
|
|
|
|
@Override
|
|
protected Expectation getExpectations() {
|
|
ClassExpect access = new ClassExpect("Access");
|
|
ClassExpect testStaticAccess = new ClassExpect(TestStaticAccess.TESTEDCLASSNAME);
|
|
|
|
//Methods
|
|
MethodExpect method = new MethodExpect("method1",new RefType("void",-1));
|
|
method.addParameter(new VarExpect("a",new RefType("java.lang.String",-1)));
|
|
method.addParameter(new VarExpect("b",new RefType("java.lang.String",-1)));
|
|
method.getBlock().addLocalVar(new VarExpect("x",new RefType("Access",-1)));
|
|
|
|
MethodExpect nonStaticMethod = new MethodExpect("staticMethod",new RefType("java.lang.String",-1));
|
|
|
|
//add methods to classes
|
|
testStaticAccess.addMethod(method);
|
|
|
|
access.addMethod(nonStaticMethod);
|
|
//Member
|
|
access.addMember(new VarExpect("staticMember",new RefType("java.lang.String",-1)));
|
|
|
|
Expectation ret = new Expectation(testStaticAccess);
|
|
ret.addClass(access);
|
|
|
|
return ret;
|
|
}
|
|
} |