Commit e17a12be authored by Nils Kaminski's avatar Nils Kaminski
Browse files

New tests for free and is_connected

parent 7ac710ca
Pipeline #85798 failed with stage
in 27 seconds
package de.monticore.lang.monticar.generator.dynamics;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.monticar.generator.AbstractSymtabTest;
import de.monticore.lang.monticar.generator.cpp.GeneratorCPP;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.se_rwth.commons.logging.Log;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import java.io.File;
import java.io.IOException;
import java.util.List;
import static org.junit.Assert.assertNotNull;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class DynamicIsConnectedInMath extends AbstractSymtabTest {
@BeforeClass
public static void setUp() {
// ensure an empty log
Log.getFindings().clear();
Log.enableFailQuick(false);
}
@Test
public void test_00_IsConnected() throws IOException {
TaggingResolver symtab = createSymTabAndTaggingResolver("src/test/resources/dynamics");
EMAComponentInstanceSymbol componentSymbol = symtab.<EMAComponentInstanceSymbol>resolve("connected.main", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentSymbol);
GeneratorCPP generatorCPP = new GeneratorCPP();
generatorCPP.useArmadilloBackend();
generatorCPP.setGenerationTargetPath("./target/generated-sources-cpp/dynamics-isconnected/test00");
// generatorCPP.setUseThreadingOptimization(true);
List<File> files = generatorCPP.generateFiles(symtab, componentSymbol, symtab);
}
@Test
public void test_01_IsConnected() throws IOException {
TaggingResolver symtab = createSymTabAndTaggingResolver("src/test/resources/dynamics");
EMAComponentInstanceSymbol componentSymbol = symtab.<EMAComponentInstanceSymbol>resolve("connected.test", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentSymbol);
GeneratorCPP generatorCPP = new GeneratorCPP();
generatorCPP.useArmadilloBackend();
generatorCPP.setGenerationTargetPath("./target/generated-sources-cpp/dynamics-isconnected/test01");
// generatorCPP.setUseThreadingOptimization(true);
List<File> files = generatorCPP.generateFiles(symtab, componentSymbol, symtab);
}
@Test
public void test_02_IsConnectedScatter() throws IOException {
TaggingResolver symtab = createSymTabAndTaggingResolver("src/test/resources/dynamics");
EMAComponentInstanceSymbol componentSymbol = symtab.<EMAComponentInstanceSymbol>resolve("connected.scatterTest", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentSymbol);
GeneratorCPP generatorCPP = new GeneratorCPP();
generatorCPP.useArmadilloBackend();
generatorCPP.setGenerationTargetPath("./target/generated-sources-cpp/dynamics-isconnected/test02");
// generatorCPP.setUseThreadingOptimization(true);
List<File> files = generatorCPP.generateFiles(symtab, componentSymbol, symtab);
}
}
......@@ -40,6 +40,7 @@ public class DynamicTestEvent extends AbstractSymtabTest {
EMAComponentInstanceSymbol componentSymbol = symtab.<EMAComponentInstanceSymbol>resolve(instName, EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentSymbol);
GeneratorCPP generatorCPP = new GeneratorCPP();
generatorCPP.useArmadilloBackend();
generatorCPP.setGenerationTargetPath(target);
......
package connected;
dynamic component DynamicMean<T, N1 n = 2> {
ports
dynamic in T inValues [0:n],
out T outMean;
@ inValues::connect{ /* Interface for dynamic ports */ }
implementation Math {
T val=0;
T m=0;
for i=1:n
if is_connected(inValues, abs(i))
val=val+inValues(i);
m=m+1;
end
end
outMean=0;
if (m != 0)
outMean=(val / m);
end
}
}
\ No newline at end of file
package connected;
dynamic component Main {
ports
dynamic in Q inValues[0:32],
dynamic out Q outMeans[0:32];
instance DynamicMean<Q, 32> ds;
@ inValues::connect && outMeans::connect {
connect inValues[?] -> ds.inValues[?];
connect ds.outMean -> outMeans[?];
}
}
\ No newline at end of file
package connected;
dynamic component ScatterTest {
ports
in Q inValue,
dynamic out Q scatterOutValue [0:9];
@ scatterOutValue::connect { /* Dynamic event interface for scatterOutValue */ }
implementation Math {
for i=1:9
if is_connected(scatterOutValue, i)
scatterOutValue(i) = inValue;
end
end
}
}
package connected;
component Test {
component Delay<T> {
ports
out T oB;
implementation Math {
T v=5;
ob=v;
}
}
instance Delay<Q> d;
}
\ No newline at end of file
Supports Markdown
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