Commit caf1dc3a authored by Christoph Richter's avatar Christoph Richter
Browse files

Extended tests

parent 763d759d
Pipeline #56901 passed with stage
in 21 minutes and 6 seconds
......@@ -66,6 +66,7 @@ public class EmbeddedMontiArcMathOptSymbolTableCreator extends EmbeddedMontiArcM
visitorOpt.setMatrixExpressionsVisitor(mathOptSTC);
visitorOpt.setMatrixVisitor(mathOptSTC);
visitorOpt.setMathVisitor(mathOptSTC);
visitorOpt.setMathOptVisitor(mathOptSTC);
// set existing stc's
visitorOpt.setCommon2Visitor(getEmamSTC());
visitorOpt.setEmbeddedMontiArcMathVisitor(getEmamSTC());
......
package de.monticore.lang.embeddedmontiarcmathopt._symboltable;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ComponentSymbol;
import de.monticore.lang.math._symboltable.MathStatementsSymbol;
import de.monticore.lang.math._symboltable.expression.MathAssignmentExpressionSymbol;
import de.monticore.lang.mathopt._symboltable.MathOptimizationStatementSymbol;
import de.monticore.lang.mathopt._symboltable.MathOptimizationType;
import de.monticore.symboltable.Scope;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class EmbeddedMontiArcMathOptSymbolTableCreatorTest extends EMAMOptAbstractSymtabTest {
@Test
public void testEMAMMathStatementsSymbol() {
Scope symTab = createSymTab("src/test/resources/");
ComponentSymbol component = symTab.<ComponentSymbol>resolve("test.Add", ComponentSymbol.KIND).orElse(null);
MathStatementsSymbol statements = (MathStatementsSymbol) component.getSpannedScope().resolve("MathStatements", MathStatementsSymbol.KIND).orElse(null);
assertNotNull(statements);
assertEquals(1, statements.getMathExpressionSymbols().size());
assertEquals(MathAssignmentExpressionSymbol.class, statements.getMathExpressionSymbols().get(0).getClass());
}
@Test
public void testEMAMOptMathStatementsSymbol() {
Scope symTab = createSymTab("src/test/resources/");
ComponentSymbol component = symTab.<ComponentSymbol>resolve("test.math.optimization.ScalarMaximizationTest", ComponentSymbol.KIND).orElse(null);
MathStatementsSymbol statements = (MathStatementsSymbol) component.getSpannedScope().resolve("MathStatements", MathStatementsSymbol.KIND).orElse(null);
assertNotNull(statements);
assertEquals(1, statements.getMathExpressionSymbols().size());
assertEquals(MathOptimizationStatementSymbol.class, statements.getMathExpressionSymbols().get(0).getClass());
}
@Test
public void testScalarMinimizationModel() {
Scope symTab = createSymTab("src/test/resources");
ComponentSymbol symbol = symTab.<ComponentSymbol>resolve("test.math.optimization.ScalarMinimizationTest", ComponentSymbol.KIND).orElse(null);
assertNotNull(symbol);
ComponentSymbol component = symTab.<ComponentSymbol>resolve("test.math.optimization.ScalarMinimizationTest", ComponentSymbol.KIND).orElse(null);
MathStatementsSymbol statements = (MathStatementsSymbol) component.getSpannedScope().resolve("MathStatements", MathStatementsSymbol.KIND).orElse(null);
MathOptimizationStatementSymbol optSymbol = (MathOptimizationStatementSymbol) statements.getMathExpressionSymbols().get(0);
assertEquals(MathOptimizationType.MINIMIZATION, optSymbol.getOptimizationType());
}
@Test
public void testScalarMaximizationModel() {
Scope symTab = createSymTab("src/test/resources");
ComponentSymbol symbol = symTab.<ComponentSymbol>resolve("test.math.optimization.ScalarMaximizationTest", ComponentSymbol.KIND).orElse(null);
assertNotNull(symbol);
ComponentSymbol component = symTab.<ComponentSymbol>resolve("test.math.optimization.ScalarMaximizationTest", ComponentSymbol.KIND).orElse(null);
MathStatementsSymbol statements = (MathStatementsSymbol) component.getSpannedScope().resolve("MathStatements", MathStatementsSymbol.KIND).orElse(null);
MathOptimizationStatementSymbol optSymbol = (MathOptimizationStatementSymbol) statements.getMathExpressionSymbols().get(0);
assertEquals(MathOptimizationType.MAXIMIZATION, optSymbol.getOptimizationType());
}
}
\ No newline at end of file
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