More Abgabe Tests working

This commit is contained in:
i22035 2024-07-04 19:44:59 +02:00
parent 8eba420d48
commit c2c4974c76
8 changed files with 69 additions and 13 deletions

View File

@ -135,12 +135,12 @@ public class MethodCodeGen implements bytecode.visitor.MethodVisitor {
@Override @Override
public void visit(CalculationNode calculationNode) { public void visit(CalculationNode calculationNode) {
if (calculationNode.dotExpression != null) {
calculationNode.dotExpression.accept(this);
}
if (calculationNode.calculationExpression != null) { if (calculationNode.calculationExpression != null) {
calculationNode.calculationExpression.accept(this); calculationNode.calculationExpression.accept(this);
} }
if (calculationNode.dotExpression != null) {
calculationNode.dotExpression.accept(this);
}
if (calculationNode.operator != null) { if (calculationNode.operator != null) {
switch (calculationNode.operator) { switch (calculationNode.operator) {
case PLUS: case PLUS:

View File

@ -40,6 +40,14 @@ public class Main {
System.err.println("Error reading the file: " + e.getMessage()); System.err.println("Error reading the file: " + e.getMessage());
} }
} }
else {
try {
CharStream codeCharStream = CharStreams.fromPath(Paths.get("src/test/resources/input/endabgabeTests/Person.java"));
compileFile(codeCharStream, "src/test/resources/input/endabgabeTests");
} catch (IOException e) {
System.err.println("Error reading the file: " + e.getMessage());
}
}
} }
/** /**

View File

@ -66,13 +66,13 @@ public class MiniCompilerLogger {
logger.addHandler(consoleHandler); logger.addHandler(consoleHandler);
// Configure file handler // Configure file handler
Handler fileHandler = new FileHandler("src/main/resources/logs/miniCompiler.log"); //Handler fileHandler = new FileHandler("src/main/resources/logs/miniCompiler.log");
// Toggle file logging on/off // Toggle file logging on/off
fileHandler.setLevel(Level.ALL); //fileHandler.setLevel(Level.ALL);
fileHandler.setFormatter(new CustomFormatter()); //fileHandler.setFormatter(new CustomFormatter());
logger.addHandler(fileHandler); //logger.addHandler(fileHandler);
} catch (SecurityException | IOException e) { } catch (SecurityException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }

View File

@ -0,0 +1,25 @@
public class Calculation {
public int add(int a, int b) {
return a + b;
}
public int sub(int a, int b) {
return a - b;
}
public int mul(int a, int b) {
return a * b;
}
public int div(int a, int b) {
return a / b;
}
public int mod(int a, int b) {
return a % b;
}
public int complexCalculation() {
return 3 - 2 * 2 + 5;
}
}

View File

@ -4,13 +4,13 @@ public class ControlStructures {
return a + b; return a + b;
} }
public cahr checkNumber(int num) { public char checkNumber(int num) {
if (num > 0) { if (num > 0) {
return "p"; return 'p';
} else if (num < 0) { } else if (num < 0) {
return "n"; return 'n';
} else { } else {
return "z"; return 'z';
} }
} }
@ -19,7 +19,7 @@ public class ControlStructures {
int uneven = 0; int uneven = 0;
int i = 0; int i = 0;
while (i < limit) { while (i < limit) {
if (i % 2 == 0) { if ((i % 2) == 0) {
even++; even++;
} else { } else {
uneven = uneven + 1; uneven = uneven + 1;

View File

@ -0,0 +1 @@
public class EmptyClass {}

View File

@ -0,0 +1,17 @@
public class Loops {
public boolean If(int a, int b) {
if(a == b) {
return true;
} else {
return false;
}
}
public int While(int a) {
int count = 0;
while(count < a) {
count++;
}
return count;
}
}

View File

@ -0,0 +1,5 @@
public class Main {
public static void main(String[] args) {
Person testPerson = new Person(5);
}
}