Skip to content
Snippets Groups Projects
Commit 2f06ddeb authored by Ludovic Apvrille's avatar Ludovic Apvrille
Browse files

Resolving bug on expressiontest

parent 12b8a7ba
No related branches found
No related tags found
No related merge requests found
......@@ -793,10 +793,12 @@ public class AvatarBlock extends AvatarElement implements AvatarStateMachineOwne
public void removeConstantAttributes() {
AvatarTransition at;
if (constants == null) {
List<AvatarAttribute> newAttributes = new LinkedList<AvatarAttribute>();
constants = new LinkedList<AvatarAttribute>();
if ((constants == null) || (constants.size() == 0)) {
List<AvatarAttribute> newAttributes = new LinkedList<>();
constants = new LinkedList<>();
for (AvatarAttribute attr : attributes) {
boolean toKeep = false;
......@@ -804,13 +806,12 @@ public class AvatarBlock extends AvatarElement implements AvatarStateMachineOwne
if (attr.isTimer()) {
toKeep = true;
}
for (AvatarStateMachineElement elt : asm.getListOfElements()) {
if (elt instanceof AvatarTransition) {
at = (AvatarTransition) elt;
for (AvatarAction aa : at.getActions()) {
if (aa instanceof AvatarActionAssignment) {
if (((AvatarActionAssignment) aa).leftHand.getName().compareTo(attr.name) == 0) {
......@@ -833,6 +834,10 @@ public class AvatarBlock extends AvatarElement implements AvatarStateMachineOwne
if (((AvatarRandom) elt).getVariable().compareTo(attr.name) == 0) {
toKeep = true;
}
} else if (elt instanceof AvatarQueryOnSignal) {
if (((AvatarQueryOnSignal) elt).getAttribute().getName().compareTo(attr.name) == 0) {
toKeep = true;
}
}
......
......@@ -286,16 +286,16 @@ public class AvatarExpressionTest {
e1 = new AvatarExpressionSolver("block1.x + block2.y");
assertTrue(e1.buildExpression(as));
e2 = new AvatarExpressionSolver("-block1.x / block1.y - 15 * block2.z + 1 == -46");
assertFalse(e2.buildExpression(as));
assertTrue(e2.buildExpression(as));
e3 = new AvatarExpressionSolver("not(-block2.x / block2.z - not(block1.x + block2.y) * -2 + -(1) <= -(-4 + 7))");
assertFalse(e3.buildExpression(as));
e4 = new AvatarExpressionSolver("block1.x + block2.w");
assertTrue(e4.buildExpression(as));
assertTrue(e1.getResult(ss) == 17);
//assertTrue(e2.getResult(ss) == 1);
assertTrue(e2.getResult(ss) == 1);
assertTrue(e3.getResult(ss) == 0);
//assertTrue(e4.getResult(ss) == -2);
assertTrue(e4.getResult(ss) == -2);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment