Die Migration der Bereiche "Docker Registry" und "Artifiacts" ist fast abgeschlossen. Die letzten Daten werden im Laufe des heutigen Abend (05.08.2021) noch vollständig hochgeladen. Das Anlegen neuer Images und Artifacts funktioniert bereits wieder.

Commit 0e8f44e2 authored by Alexander David Hellwig's avatar Alexander David Hellwig
Browse files

Fix matrix stream tests

parent 0158ff31
Pipeline #178397 passed with stages
in 29 minutes and 21 seconds
......@@ -10,7 +10,7 @@
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-math-generator</artifactId>
<version>0.1.14-SNAPSHOT</version>
<version>0.1.15-SNAPSHOT</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
......
......@@ -439,8 +439,7 @@ public final class TestsGeneratorCPP {
}
}
} else if (node.getValuePairOpt().isPresent()) {
//TODO valuepair conversion
builder.append("NOT HANDLED VALUEPAIROPT!!!");
convertValuePair(builder, converter, node.getValuePair());
}
Log.debug("Result: " + builder.toString(), "TestGeneratorCPP");
result = RangeOutputPortCheck.from(builder.toString(), builder.toString(), true);
......@@ -452,7 +451,7 @@ public final class TestsGeneratorCPP {
private static final class ASTStreamValue2InputPortValue implements StreamUnitsVisitor {
private String result = null;
private String result = "";
boolean handled = false;
public String getResult() {
......@@ -506,8 +505,7 @@ public final class TestsGeneratorCPP {
}
}
} else if (node.getValuePairOpt().isPresent()) {
//TODO valuepair conversion
result += "NOT HANDLED VALUEPAIROPT!!!";
convertValuePair(builder, converter, node.getValuePair());
}
Log.debug("Result: " + builder.toString(), "TestGeneratorCPP.vists(ASTStreamArrayValues)");
result += builder.toString();
......@@ -516,6 +514,23 @@ public final class TestsGeneratorCPP {
}
}
private static void convertValuePair(StringBuilder builder, StreamValueConverter converter, ASTValuePair valuePair) {
builder.append(" <<");
for (int i = 0; i < valuePair.getStreamValueList().size(); ++i) {
ASTStreamValue value = valuePair.getStreamValueList().get(i);
//TODO Name, PrecisionNumber, SignedLiteral, valueAtTick
if (value.getNameOpt().isPresent()) {
builder.append(value.getName());
} else {
builder.append(converter.convert(value));
}
if (i + 1 < valuePair.getStreamValueList().size()) {
builder.append(" << ");
}
}
builder.append("<< arma::endr ");
}
private static class StreamValueConverter implements StreamUnitsVisitor {
String result = "";
......
......@@ -96,4 +96,31 @@ public class TestsGenTest extends AbstractSymtabTest {
assertTrue(content.stream().anyMatch(line -> line.contains("component.in1.simpleField = 2.0;")));
assertTrue(content.stream().anyMatch(line -> line.contains("component.in1.structField.field = 4.0;")));
}
@Test
public void testMatrixComp() throws IOException {
TaggingResolver symTab = createSymTabAndTaggingResolver("src/test/resources/matrixStreamBase/");
EMAComponentInstanceSymbol componentSymbol = symTab.<EMAComponentInstanceSymbol>resolve(
"basic.matrixComp",
EMAComponentInstanceSymbol.KIND
).orElse(null);
assertNotNull(componentSymbol);
GeneratorCPP generatorCPP = new GeneratorCPP();
generatorCPP.setModelsDirPath(Paths.get("src/test/resources/matrixStreamBase/"));
generatorCPP.setGenerateTests(true);
generatorCPP.setGenerateCMake(true);
generatorCPP.setGenerationTargetPath("./target/generated-sources-cpp/streamTest/matrix/");
generatorCPP.setCheckModelDir(true);
Set<File> files = new HashSet<>(generatorCPP.generateFiles(symTab, componentSymbol, symTab));
Optional<File> testFileOpt = files.stream().filter(file -> file.getName().endsWith("basic_matrixComp_test.hpp")).findFirst();
assertTrue(testFileOpt.isPresent());
List<String> content = FileUtils.readLines(testFileOpt.get(), "UTF-8");
assertFalse(content.stream().anyMatch(line -> line.contains("NOT HANDLED VALUEPAIROPT!!!")));
assertTrue(content.stream().anyMatch(line -> line.matches(".*component.colVecIn\\s*<<\\s*1.0\\s*<<\\s*2.0\\s*<<\\s*3.0\\s*<<\\s*arma::endr\\s*;.*")));
assertTrue(content.stream().anyMatch(line -> line.matches(".*component.matIn\\s*<<\\s*1.0\\s*<<\\s*2.0\\s*<<\\s*3.0\\s*<<\\s*arma::endr\\s*<<\\s*4.0\\s*<<\\s*5.0\\s*<<\\s*6.0\\s*<<\\s*arma::endr\\s*<<\\s*7.0\\s*<<\\s*8.0\\s*<<\\s*9.0\\s*<<\\s*arma::endr\\s*;.*")));
assertTrue(content.stream().anyMatch(line -> line.matches(".*component.rowVecIn\\s*<<\\s*1.0\\s*<<\\s*arma::endr\\s*<<\\s*2.0\\s*<<\\s*arma::endr\\s*<<\\s*3.0\\s*<<\\s*arma::endr\\s*;.*")));
}
}
package basic;
component MatrixComp{
ports in Q^{1,3} rowVecIn,
in Q^{3,1} colVecIn,
in Q^{3,3} matIn,
out Q^{1,3} rowVecOut,
out Q^{3,1} colVecOut,
out Q^{3,3} matOut;
implementation Math{
rowVecOut = rowVecIn;
colVecOut = colVecIn;
matOut = matIn;
}
}
\ No newline at end of file
package basic;
stream MatrixCompTest for MatrixComp{
rowVecIn: [1;2;3];
colVecIn: [1,2,3];
matIn: [1,2,3;4,5,6;7,8,9];
rowVecOut: [1;2;3];
colVecOut: [1,2,3];
matOut: [1,2,3;4,5,6;7,8,9];
}
\ 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