Commit 7f41f2e7 authored by Malte Heithoff's avatar Malte Heithoff
Browse files

Bug with test

parent 7bfc64ed
Pipeline #117631 failed with stages
in 9 minutes and 44 seconds
package de.monticore.lang.monticar.generator.heithoff;
import de.monticore.lang.monticar.generator.cpp.GeneratorCppCli;
import org.junit.Test;
public class SListBug {
@Test
public void testSListBug() {
String[] args = {
"--models-dir=src/test/resources",
"--root-model=de.rwth.pacman.pacManWrapper",
"--output-dir=./target/generated-sources-cpp/de/rwth/pacman/PacManWrapper"
};
GeneratorCppCli.main(args);
}
}
package de.rwth.pacman;
import de.rwth.pacman.basicLibrary.Fallback;
// UP = 0
// DOWN = 1
// LEFT = 2
// RIGHT = 3
component PacManControllerSimple {
ports
in Q(0m: 18m) ghostX[4],
in Q(0m: 21m) ghostY[4],
in Z(0 : 1 : 3) ghostDirection[4],
in B ghostEatable[4],
in B ghostEaten[4],
in Q(0m: 18m) pacManX,
in Q(0m: 21m) pacManY,
in B pacManEaten,
in Z(1:oo) pacManLives,
in Z(0:oo) pacManScore,
in Z^{22,19} map,
out Z(0 : 1 : 3) newPacManDirection;
instance Fallback fallback;
connect fallback.out1 -> newPacManDirection;
}
\ No newline at end of file
package de.rwth.pacman;
import de.rwth.pacman.heithoff2.Controller;
import de.rwth.pacman.structs.Ghost;
// UP = 0
// DOWN = 1
// LEFT = 2
// RIGHT = 3
// Pacman.WALL = 0;
// Pacman.BISCUIT = 1;
// Pacman.EMPTY = 2;
// Pacman.BLOCK = 3;
// Pacman.PILL = 4;
component PacManWrapper {
ports
in Q(-1m: 19m) ghostX[4], // x-position of all ghosts, can be -1 and 19 when exiting and reentering the map
in Q(0m: 21m) ghostY[4], // y-position of all ghosts
in Z(0 : 1 : 3) ghostDirection[4], // the directions of all ghosts encoded in the pattern above
in B ghostEatable[4], // ghosts are eatable when pacman collects a coin
in B ghostEaten[4], // ghosts enter a non-eatable state after this one
in Q(-1m: 19m) pacManX, // x-position of pacman, can be -1 and 19 when exiting and reenting the map
in Q(0m: 21m) pacManY, // y-position of pacman
in B pacManEaten,
in Z(0:oo) pacManLives,
in Z(0:oo) pacManScore,
in Z^{22,19} map, // the map encoded in the pattern above. x raises to the right, y raises to the bottom
out Z(0 : 1 : 3) newPacManDirection;
//Replace this with your own custom controller
instance Controller controller;
connect ghostX[:] -> controller.ghostX[:];
connect ghostY[:] -> controller.ghostY[:];
connect ghostDirection[:] -> controller.ghostDirection[:];
connect ghostEatable[:] -> controller.ghostEatable[:];
connect ghostEaten[:] -> controller.ghostEaten[:];
connect pacManX -> controller.pacManX;
connect pacManY -> controller.pacManY;
connect pacManEaten -> controller.pacManEaten;
connect pacManLives -> controller.pacManLives;
connect pacManScore -> controller.pacManScore;
connect map -> controller.map;
connect controller.newPacManDirection -> newPacManDirection;
}
\ No newline at end of file
package de.rwth.pacman.basicLibrary;
// UP = 0
// DOWN = 1
// LEFT = 2
// RIGHT = 3
component Fallback{
port
out Z out1;
implementation Math{
out1=3;
}
}
package de.rwth.pacman.common;
component Abs {
ports
in Q in1,
out Q out1;
implementation Math {
out1 = abs(in1);
}
}
\ No newline at end of file
package de.rwth.pacman.common;
component And<N1 n=2> {
port
in B in1[n],
out B out1;
implementation Math{
out1 = and(in1);
/*B val=true;
for i = 1:n
val=and(val,in1[n]);
out1=val;*/
}
}
package de.rwth.pacman.common;
component BoolToNumber {
ports
in B in1,
out N1 out1;
implementation Math {
if in1==0
out1 = 0;
else
out1 = 1;
end
}
}
\ No newline at end of file
package de.rwth.pacman.common;
component Constant<Q n = 0> {
port out Q out1;
implementation Math {
out1 = n;
}
}
\ No newline at end of file
package de.rwth.pacman.common;
component ConstantBoolean<N1 n> {
ports
out B out1;
implementation Math {
if n==0
out1 = 0;
else
out1 = 1;
end
}
}
\ No newline at end of file
package de.rwth.pacman.common;
component Delay<Q val = 0> {
port
in Q in1,
out Q out1;
implementation Math {
static Q prev = val;
out1 = prev;
prev = in1;
}
}
\ No newline at end of file
package de.rwth.pacman.common;
component Difference<N1 n=2> {
port
in Q in1[n],
out Q out1;
implementation Math{
Q outVal=in1(1);
for i=2:n
outVal=outVal-in1(i);
end
out1=outVal;
}
}
package de.rwth.pacman.common;
component Division {
port
in Q in1,
in Q in2,
out Q out1;
implementation Math{
out1=in1/in2;
}
}
package de.rwth.pacman.common;
component Equals {
port
in Q in1,
in Q in2,
out B out1;
implementation Math{
out1=equal(in1,in2);
}
}
package de.rwth.pacman.common;
component EqualsBoolean {
port
in B in1,
in B in2,
out B out1;
implementation Math{
out1=equal(in1,in2);
}
}
package de.rwth.pacman.common;
component Greater {
port
in Q in1,
in Q in2,
out B out1;
implementation Math{
out1=in1>in2;
}
}
package de.rwth.pacman.common;
component GreaterEquals {
port
in Q in1,
in Q in2,
out B out1;
implementation Math{
out1=in1>=in2;
}
}
package de.rwth.pacman.common;
component Indexes<N1 n = 1> {
ports
out N1 out1[n];
implementation Math {
for i = 1:n
out1(i) = i;
end
}
}
\ No newline at end of file
package de.rwth.pacman.common;
component JoinArray<N1 n = 1> {
ports
in Q in1[n],
out Q^{1, n} out1;
implementation Math {
for i = 1:n
out1(1,i) = in1(i);
end
}
}
\ No newline at end of file
package de.rwth.pacman.common;
component Less {
port
in Q in1,
in Q in2,
out B out1;
implementation Math{
out1=in1<in2;
}
}
package de.rwth.pacman.common;
component Max<N1 n=2> {
port
in Q in1[n],
out Q out1;
implementation Math{
Q maxVal = in1(1);
for i=2:n
maxVal=max(maxVal,in1(i));
end
out1=maxVal;
}
}
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