use of org.sonar.java.se.xproc.MethodBehavior in project sonar-java by SonarSource.
the class BytecodeEGWalkerTest method test_starting_states.
@Test
public void test_starting_states() throws Exception {
BytecodeEGWalker walker = new BytecodeEGWalker(null, semanticModel);
String signature = "type#foo()V";
walker.methodBehavior = new MethodBehavior(signature);
ProgramState startingState = Iterables.getOnlyElement(walker.startingStates(signature, ProgramState.EMPTY_STATE, false));
SymbolicValue thisSv = startingState.getValue(0);
assertThat(thisSv).isNotNull();
assertThat(startingState.getConstraints(thisSv).get(ObjectConstraint.class)).isEqualTo(ObjectConstraint.NOT_NULL);
startingState = Iterables.getOnlyElement(walker.startingStates(signature, ProgramState.EMPTY_STATE, true));
assertThat(startingState).isEqualTo(ProgramState.EMPTY_STATE);
signature = "type#foo(DIJ)V";
walker.methodBehavior = new MethodBehavior(signature);
startingState = Iterables.getOnlyElement(walker.startingStates(signature, ProgramState.EMPTY_STATE, true));
assertThat(startingState.getValue(0)).isNotNull();
SymbolicValue doubleArg = startingState.getValue(0);
assertThat(startingState.getConstraint(doubleArg, BytecodeEGWalker.StackValueCategoryConstraint.class)).isEqualTo(BytecodeEGWalker.StackValueCategoryConstraint.LONG_OR_DOUBLE);
assertThat(startingState.getValue(1)).isNull();
assertThat(startingState.getValue(2)).isNotNull();
SymbolicValue longArg = startingState.getValue(3);
assertThat(longArg).isNotNull();
assertThat(startingState.getConstraint(longArg, BytecodeEGWalker.StackValueCategoryConstraint.class)).isEqualTo(BytecodeEGWalker.StackValueCategoryConstraint.LONG_OR_DOUBLE);
}
use of org.sonar.java.se.xproc.MethodBehavior in project sonar-java by SonarSource.
the class BytecodeEGWalkerTest method goto_terminator.
@Test
public void goto_terminator() throws Exception {
MethodBehavior methodBehavior = getMethodBehavior("gotoTerminator(Ljava/lang/Object;)Z");
assertThat(methodBehavior.yields()).hasSize(2);
}
use of org.sonar.java.se.xproc.MethodBehavior in project sonar-java by SonarSource.
the class BytecodeEGWalkerTest method propagation_of_bytecode_analysis_exception.
@Test
public void propagation_of_bytecode_analysis_exception() throws Exception {
MethodBehavior methodBehavior = getMethodBehavior(MaxRelationBytecode.class, "isXMLLetter(C)Z");
assertThat(methodBehavior.isComplete()).isFalse();
}
use of org.sonar.java.se.xproc.MethodBehavior in project sonar-java by SonarSource.
the class BytecodeEGWalkerTest method test_method_is_complete.
@Test
public void test_method_is_complete() {
String desc = "(Ljava/lang/String;)Z";
MethodBehavior nativeMethod = getMethodBehavior("nativeMethod" + desc);
assertThat(nativeMethod.isComplete()).isFalse();
MethodBehavior abstractMethod = getMethodBehavior("abstractMethod" + desc);
assertThat(abstractMethod.isComplete()).isFalse();
MethodBehavior finalMethod = getMethodBehavior("finalMethod" + desc);
assertThat(finalMethod.isComplete()).isFalse();
MethodBehavior staticMethod = getMethodBehavior("staticMethod" + desc);
assertThat(staticMethod.isComplete()).isTrue();
MethodBehavior privateMethod = getMethodBehavior("privateMethod" + desc);
assertThat(privateMethod.isComplete()).isFalse();
MethodBehavior publicMethodInFinalClass = getMethodBehavior(FinalBytecodeTestClass.class, "publicMethod" + desc);
assertThat(publicMethodInFinalClass.isComplete()).isFalse();
}
use of org.sonar.java.se.xproc.MethodBehavior in project sonar-java by SonarSource.
the class BytecodeEGWalkerTest method test_method_throwing_exception.
@Test
public void test_method_throwing_exception() throws Exception {
MethodBehavior methodBehavior = getMethodBehavior("throw_exception()V");
assertThat(methodBehavior.yields()).hasSize(1);
MethodYield methodYield = methodBehavior.yields().get(0);
assertThat(methodYield).isInstanceOf(ExceptionalYield.class);
}
Aggregations