2014-09-02 10:33:54 +02:00

53 lines
1.8 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 non static access of a method or a member
*
*/
public class TestNonStaticAccess extends AbstractInferenceTest {
private final static String TESTEDCLASSNAME="TestNonStaticAccess";
private final static String JAVPATH="test/mycompiler/test/javaConcepts/staticAccess/";
public TestNonStaticAccess(String name) {
super(name,TestNonStaticAccess.JAVPATH+TestNonStaticAccess.TESTEDCLASSNAME + ".jav");
}
@Override
protected Expectation getExpectations() {
ClassExpect access = new ClassExpect("Access");
ClassExpect testNonStaticAccess = new ClassExpect(TestNonStaticAccess.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("nonStaticMethod",new RefType("java.lang.String",-1));
//add methods to classes
testNonStaticAccess.addMethod(method);
access.addMethod(nonStaticMethod);
//Member
access.addMember(new VarExpect("nonStaticMember",new RefType("java.lang.String",-1)));
Expectation ret = new Expectation(testNonStaticAccess);
ret.addClass(access);
return ret;
}
}