Add Negation operator (fixes #304)
All checks were successful
Build and Test with Maven / Build-and-test-with-Maven (push) Successful in 2m41s
All checks were successful
Build and Test with Maven / Build-and-test-with-Maven (push) Successful in 2m41s
This commit is contained in:
parent
7f3c1686ec
commit
c84befae51
@ -1,11 +1,9 @@
|
|||||||
public class Op1{
|
import java.lang.Boolean;
|
||||||
public Op1() {
|
|
||||||
|
public class Op1 {
|
||||||
Runnable lam = () -> {
|
public m() {
|
||||||
String test = "";
|
var b = false;
|
||||||
String b = "b";
|
var c = !b;
|
||||||
test = b;
|
return c;
|
||||||
System.out.println(test);};
|
|
||||||
//lam.run();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -996,6 +996,9 @@ public class StatementGenerator {
|
|||||||
ret = new UnaryExpr(UnaryExpr.Operation.PREDECREMENT, expr, TypePlaceholder.fresh(op), op);
|
ret = new UnaryExpr(UnaryExpr.Operation.PREDECREMENT, expr, TypePlaceholder.fresh(op), op);
|
||||||
ret.setStatement();
|
ret.setStatement();
|
||||||
return ret;
|
return ret;
|
||||||
|
} else if (op.getText().equals("!")) {
|
||||||
|
ret = new UnaryExpr(UnaryExpr.Operation.NOT, expr, TypePlaceholder.fresh(op), op);
|
||||||
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
@ -245,6 +245,9 @@ public class TYPEStmt implements StatementVisitor {
|
|||||||
constraintsSet.addUndConstraint(new Pair(unaryExpr.expr.getType(), number, PairOperator.SMALLERNEQDOT, loc(unaryExpr.getOffset())));
|
constraintsSet.addUndConstraint(new Pair(unaryExpr.expr.getType(), number, PairOperator.SMALLERNEQDOT, loc(unaryExpr.getOffset())));
|
||||||
// The type of the postfix increment expression is the type of the variable
|
// The type of the postfix increment expression is the type of the variable
|
||||||
constraintsSet.addUndConstraint(new Pair(unaryExpr.expr.getType(), unaryExpr.getType(), PairOperator.EQUALSDOT, loc(unaryExpr.getOffset())));
|
constraintsSet.addUndConstraint(new Pair(unaryExpr.expr.getType(), unaryExpr.getType(), PairOperator.EQUALSDOT, loc(unaryExpr.getOffset())));
|
||||||
|
} else if (unaryExpr.operation == UnaryExpr.Operation.NOT) {
|
||||||
|
constraintsSet.addUndConstraint(new Pair(unaryExpr.expr.getType(), unaryExpr.getType(), PairOperator.EQUALSDOT, loc(unaryExpr.getOffset())));
|
||||||
|
constraintsSet.addUndConstraint(new Pair(unaryExpr.expr.getType(), new RefType(ASTFactory.createClass(java.lang.Boolean.class).getClassName(), new NullToken()), PairOperator.EQUALSDOT, loc(unaryExpr.getOffset())));
|
||||||
} else {
|
} else {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
@ -837,6 +837,14 @@ public class TestComplete {
|
|||||||
assertEquals(clazz.getSuperclass().getDeclaredField("x").get(instance), 3);
|
assertEquals(clazz.getSuperclass().getDeclaredField("x").get(instance), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testOperators() throws Exception {
|
||||||
|
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Op1.jav");
|
||||||
|
var clazz = classFiles.get("Op1");
|
||||||
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||||
|
assertEquals(clazz.getDeclaredMethod("m").invoke(instance), true);
|
||||||
|
}
|
||||||
|
|
||||||
@Ignore("Not implemented")
|
@Ignore("Not implemented")
|
||||||
@Test
|
@Test
|
||||||
public void testStringConcat() throws Exception {
|
public void testStringConcat() throws Exception {
|
||||||
|
Loading…
Reference in New Issue
Block a user