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{
|
||||
public Op1() {
|
||||
import java.lang.Boolean;
|
||||
|
||||
Runnable lam = () -> {
|
||||
String test = "";
|
||||
String b = "b";
|
||||
test = b;
|
||||
System.out.println(test);};
|
||||
//lam.run();
|
||||
public class Op1 {
|
||||
public m() {
|
||||
var b = false;
|
||||
var c = !b;
|
||||
return c;
|
||||
}
|
||||
}
|
@ -996,6 +996,9 @@ public class StatementGenerator {
|
||||
ret = new UnaryExpr(UnaryExpr.Operation.PREDECREMENT, expr, TypePlaceholder.fresh(op), op);
|
||||
ret.setStatement();
|
||||
return ret;
|
||||
} else if (op.getText().equals("!")) {
|
||||
ret = new UnaryExpr(UnaryExpr.Operation.NOT, expr, TypePlaceholder.fresh(op), op);
|
||||
return ret;
|
||||
} else {
|
||||
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())));
|
||||
// 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())));
|
||||
} 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 {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -837,6 +837,14 @@ public class TestComplete {
|
||||
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")
|
||||
@Test
|
||||
public void testStringConcat() throws Exception {
|
||||
|
Loading…
Reference in New Issue
Block a user