Skip to content

Commit

Permalink
SONARJAVA-1488 Fix bugs and simplify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DidierBesset authored and benzonico committed Jan 29, 2016
1 parent 07eb081 commit 830d17c
Show file tree
Hide file tree
Showing 6 changed files with 347 additions and 408 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
package org.sonar.java.se.symbolicvalues;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import org.sonar.java.se.symbolicvalues.RelationalSymbolicValue.Kind;

Expand Down Expand Up @@ -73,10 +74,6 @@ private boolean equalsRelation(BinaryRelation rel) {
return false;
}

public boolean isKind(Kind kind) {
return this.kind.equals(kind);
}

@Override
public String toString() {
StringBuilder buffer = new StringBuilder();
Expand Down Expand Up @@ -158,8 +155,9 @@ private Collection<BinaryRelation> combinedRelations(Collection<BinaryRelation>
* @param relation another SymbolicValueRelation
* @return a SymbolicValueRelation or null if the receiver and the supplied relation cannot be combined
*/
@VisibleForTesting
@CheckForNull
private BinaryRelation combineUnordered(BinaryRelation relation) {
BinaryRelation combineUnordered(BinaryRelation relation) {
BinaryRelation combined = null;
if (rightOp.equals(relation.leftOp)) {
combined = relation.combineOrdered(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected BinaryRelation combinedWithNotEqual(NotEqualRelation relation) {
@Override
@CheckForNull
protected BinaryRelation combinedWithMethodEquals(MethodEqualsRelation relation) {
return null;
return new GreaterThanOrEqualRelation(leftOp, relation.rightOp);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected BinaryRelation combinedWithNotEqual(NotEqualRelation relation) {
@Override
@CheckForNull
protected BinaryRelation combinedWithMethodEquals(MethodEqualsRelation relation) {
return null;
return new GreaterThanRelation(leftOp, relation.rightOp);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ protected BinaryRelation combinedWithGreaterThan(GreaterThanRelation relation) {
@Override
@CheckForNull
protected BinaryRelation combinedWithGreaterThanOrEqual(GreaterThanOrEqualRelation relation) {
return null;
return new GreaterThanOrEqualRelation(leftOp, relation.rightOp);
}

@Override
Expand All @@ -140,6 +140,6 @@ protected BinaryRelation combinedWithLessThan(LessThanRelation relation) {
@Override
@CheckForNull
protected BinaryRelation combinedWithLessThanOrEqual(LessThanOrEqualRelation relation) {
return null;
return new LessThanOrEqualRelation(leftOp, relation.rightOp);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@
public class RelationalSymbolicValue extends BinarySymbolicValue {

public enum Kind {
EQUAL("=="), NOT_EQUAL("!="), GREATER_THAN(">="), GREATER_THAN_OR_EQUAL(">="), LESS_THAN("<"), LESS_THAN_OR_EQUAL("<="), METHOD_EQUALS(".EQ."), NOT_METHOD_EQUALS(".NE.");
EQUAL("=="),
NOT_EQUAL("!="),
GREATER_THAN(">="),
GREATER_THAN_OR_EQUAL(">="),
LESS_THAN("<"),
LESS_THAN_OR_EQUAL("<="),
METHOD_EQUALS(".EQ."),
NOT_METHOD_EQUALS(".NE.");

final String operand;

Kind(String operand) {
Expand Down
Loading

0 comments on commit 830d17c

Please sign in to comment.