Commit e90bad79 authored by Ievgen Strepkov's avatar Ievgen Strepkov

Fixed the tests errors

parent a66ef23f
Pipeline #57540 passed with stage
in 2 minutes and 39 seconds
......@@ -42,7 +42,13 @@ public class RangePortCheckAssignmentCoCo implements MathASTMathAssignmentExpres
Log.debug("symbol table has not yet been built; cannot check assignment", LOG_NAME);
return;
}
if(!(node.getSymbol().get() instanceof MathAssignmentExpressionSymbol)){
return;
}
MathAssignmentExpressionSymbol assignment = (MathAssignmentExpressionSymbol) node.getSymbol().get();
if (!(assignment.getExpressionSymbol() instanceof MathNumberExpressionSymbol)){
return;
}
MathNumberExpressionSymbol mves = (MathNumberExpressionSymbol) assignment.getExpressionSymbol();
double[] range = getRange(assignment.getEnclosingScope(), assignment.getNameOfMathValue());
......
/**
*
* ******************************************************************************
* MontiCAR Modeling Family, www.se-rwth.de
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
*
* This project is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************
*/
package de.monticore.lang.embeddedmontiarc.embeddedmontiarcmath.cocos;
import de.monticore.lang.math.math._ast.ASTMathAssignmentExpression;
......@@ -19,7 +39,13 @@ public class RangeValueCheckAssignmentCoCo implements MathASTMathAssignmentExpre
Log.debug("symbol table has not yet been built; cannot check assignment", LOG_NAME);
return;
}
if(!(node.getSymbol().get() instanceof MathAssignmentExpressionSymbol)){
return;
}
MathAssignmentExpressionSymbol assignment = (MathAssignmentExpressionSymbol) node.getSymbol().get();
if (!(assignment.getExpressionSymbol() instanceof MathNumberExpressionSymbol)){
return;
}
MathNumberExpressionSymbol mves = (MathNumberExpressionSymbol) assignment.getExpressionSymbol();
double[] range = getRange(assignment.getEnclosingScope(), assignment.getNameOfMathValue());
......
......@@ -69,14 +69,17 @@ public class UnitsMustBeEqualAssignmentCoCo implements MathASTMathAssignmentExpr
private static Unit getLhsUnit(Scope scope, String name) {
PortSymbol port = (PortSymbol) scope.resolve(name, PortSymbol.KIND).orElse(null);
if (port != null) {
return ((ASTElementType) ((ASTPort) port.getAstNode().get()).getType()).getRange().get().getStartUnit();
}
if (port != null)
if(port.getAstNode().get() instanceof ASTPort){
ASTPort astPort = (ASTPort) port.getAstNode().get();
if(astPort.getType() instanceof ASTElementType)
return ((ASTElementType) astPort.getType()).getRange().get().getStartUnit();
}
MathValueSymbol declaration = (MathValueSymbol) scope.resolve(name, MathValueSymbol.KIND).orElse(null);
if (declaration != null) {
declaration.getAstNode();
return declaration.getType().getType().getRange().get().getStartUnit();
}
if (declaration != null)
if(declaration.getType().getType().getRange().isPresent())
return declaration.getType().getType().getRange().get().getStartUnit();
Log.debug("cannot resolve name " + name, LOG_NAME);
return null;
}
......
......@@ -38,6 +38,10 @@ public class CoCoComparisonHelper {
return;
}
if (!(node.getSymbol().get() instanceof MathCompareExpressionSymbol)){
return;
}
MathCompareExpressionSymbol comparison = (MathCompareExpressionSymbol) node.getSymbol().get();
// LHS
Unit lhsUnit;
......@@ -45,10 +49,9 @@ public class CoCoComparisonHelper {
if(comparison.getLeftExpression() instanceof MathNumberExpressionSymbol){
lhsUnit = ((MathNumberExpressionSymbol) comparison.getLeftExpression()).getValue().getUnit();
} else if
// Units for Variable
(comparison.getLeftExpression() instanceof MathNameExpressionSymbol){
} else if (comparison.getLeftExpression() instanceof MathNameExpressionSymbol){
// Units for Variable
MathValueSymbol lhsSymbol = (MathValueSymbol)comparison.getEnclosingScope()
.resolve(comparison.getLeftExpression().getTextualRepresentation(), MathValueSymbol.KIND).orElse(null);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment