Commit e690cd97 authored by Bram Kohlen's avatar Bram Kohlen
Browse files

Added some tests

parent bcda6b2c
Pipeline #60857 passed with stages
in 1 minute and 30 seconds
......@@ -68,10 +68,8 @@ public class MathPrettyPrinter implements AstPrettyPrinter<ASTMathCompilationUni
if (lines.length > 0) lines[0] = lines[0].trim();
for (String line : lines) {
this.printer.print(line);
this.printer.println(line);
}
this.printer.println();
}
/*========================================================
......
......@@ -17,7 +17,6 @@ public class ArithmeticTest extends AbstractModelTest {
}
@Test
@Ignore
public void testModel() throws IOException
{
String actual = printVanillaModel("Arithmetic.m");
......
package de.monticore.lang.monticar.mpp.models;
import org.junit.Ignore;
import org.junit.Test;
import java.io.IOException;
import static junit.framework.TestCase.assertEquals;
public class CommentsTest extends AbstractModelTest {
@Test
@Ignore
public void printTest() throws IOException
{
System.out.println(printVanillaModel("Comments.m"));
}
@Test
@Ignore
//TODO somehow this test does not work even though the results are identical
public void testModel() throws IOException
{
String actual = printVanillaModel("Comments.m");
String expected = "/*\n" +
" * (C) SE RWTH 2018\n" +
" */\n" +
"package montimath.vanilla;\n" +
"\n" +
"/*\n" +
" * A Dummy Script to show that comments can be shown.\n" +
" */\n" +
"script Comments\n" +
" /* Vector of the form [1,3,5,7,9] */\n" +
" Q(0 : 10)^{1, 5} c = 1:2:10;\n" +
" Q x = 0;\n" +
" Q y = 0;\n" +
" // Iterate over all i in c\n" +
" for i = c\n" +
" // Iterate over all j in c\n" +
" for j = c\n" +
" // y might become very small when the\n" +
" // entries in c are very large.\n" +
" y += 1 / (c(x) * j^i);\n" +
" end\n" +
" x += 1;\n" +
" end\n" +
"end";
assertEquals(expected, actual);
}
}
package de.monticore.lang.monticar.mpp.models;
import org.junit.Ignore;
import org.junit.Test;
import java.io.IOException;
import static junit.framework.TestCase.assertEquals;
public class ForLoopTest extends AbstractModelTest {
@Test
@Ignore
public void printTest1() throws IOException
{
System.out.println(printVanillaModel("ForLoop.m"));
}
@Test
public void testModel1() throws IOException
{
String actual = printVanillaModel("ForLoop.m");
String expected =
"package montimath.vanilla;\n" +
"\n" +
"script ForLoop\n" +
" Q sum = 1;\n" +
" for i = 1:2:9\n" +
" sum += sum * i;\n" +
" end\n" +
"end";
assertEquals(expected, actual);
}
@Test
@Ignore
public void printTest2() throws IOException
{
System.out.println(printVanillaModel("ForLoop2.m"));
}
@Test
public void testModel2() throws IOException
{
String actual = printVanillaModel("ForLoop2.m");
String expected =
"package montimath.vanilla;\n" +
"\n" +
"script ForLoop2\n" +
" Q(0 m : 1000 m)^{5} c = [1 m, 3 m, 5 m, 7 m, 9 m];\n" +
" Q x = 0;\n" +
" Q(0 m^2 : 1000 m^2) y = 0 m * m;\n" +
" Q(0 m : 1000 m) z = 0 m;\n" +
" //TODO fix this to work with variable vectors, and not only vectors that are equivalent to range vectors\n" +
" for i = c\n" +
" for j = c\n" +
" y += j * i;\n" +
" z += c(x + 0);\n" +
" end\n" +
" x += 1;\n" +
" end\n" +
"end";
assertEquals(expected, actual);
}
@Test
@Ignore
public void printTest3() throws IOException
{
System.out.println(printVanillaModel("ForLoop3.m"));
}
@Test
public void testModel3() throws IOException
{
String actual = printVanillaModel("ForLoop3.m");
String expected =
"package montimath.vanilla;\n" +
"\n" +
"script ForLoop3\n" +
" Q^{3, 3} A = [1, 2, 3; 4, 5, 6; 7, 8, 9];\n" +
" Q Cmat = 0;\n" +
" for i = 0:2\n" +
" for j = 0:2\n" +
" Cmat += A(i, j);\n" +
" end\n" +
" end\n" +
"end";
assertEquals(expected, actual);
}
}
......@@ -3,12 +3,10 @@
*/
package montimath.vanilla;
/*
* A Dummy Script to show that comments can be shown.
*/
script Comments
/* Vector of the form [1,3,5,7,9] */
Q(0:10)^{1,5} c = 1:2:10;
Q x = 0;
Q y = 0;
......
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