Compare commits

..
1 Commits
Author SHA1 Message Date
dholle 08d57b0da4 Add test case
Build and Test with Maven / Build-and-test-with-Maven (push) Failing after 1m21s
2026-11-18 11:45:43 +01:00
5 changed files with 21 additions and 104 deletions

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
import java.lang.Integer;
import java.lang.Object;
import java.lang.System;
import java.io.PrintStream;
public class Bug466 {
public void p(Object o) { System.out.println(o.toString()); }
public run() {
var a = 3;
p(-(a + 10)); // Java: -13
}
public static main(args) { new Bug466().run(); }
}
-88
View File
@@ -1,88 +0,0 @@
import java.lang.Integer;
import java.lang.String;
sealed interface Token permits /*SEMICOLON, COMMA, DOT, ASSIGN, LESSTHEN, GREATERTHAN, LESSEQUALS, GREATEREQUALS, EQUALS, NOTEQUALS, NOT,
ADD, SUB, MUL, DIV, */LBRACE,/* RBRACE, LBRACKET , RBRACKET, SBOPEN, SBCLOSE, ABSTRACT, STATIC, PUBLIC, CLASS, INTERFACE,
FOR, WHILE, */IF/*, ELSE, BREAK, SWITCH, CASE, RETURN, VOID, BOOLEAN, JNULL, INT, CHAR, STRING, LONG, BOOLEANLITERALTRUE, BOOLEANLITERALFALSE,
INTLITERAL, LONGLITERAL, FLOATLITERAL, CHARLITERAL, STRINGLITERAL, MEMORYADRESSLITERAL, NAME, WHITESPACE*/ { }
/*record SEMICOLON() implements Token {}
record COMMA () implements Token {}
record DOT() implements Token {}
record ASSIGN() implements Token {}
record LESSTHEN() implements Token {}
record GREATERTHAN() implements Token {}
record LESSEQUALS() implements Token {}
record GREATEREQUALS() implements Token {}
record EQUALS() implements Token {}
record NOTEQUALS() implements Token {}
record NOT() implements Token {}
record ADD () implements Token {}
record SUB() implements Token {}
record MUL() implements Token {}
record DIV() implements Token {}*/
record LBRACE() implements Token {}
/*record RBRACE() implements Token {}
record LBRACKET () implements Token {}
record RBRACKET() implements Token {}
record SBOPEN() implements Token {}
record SBCLOSE() implements Token {}
record ABSTRACT() implements Token {}
record STATIC() implements Token {}
record PUBLIC() implements Token {}
record CLASS() implements Token {}
record INTERFACE() implements Token {}
record FOR () implements Token {}
record WHILE() implements Token {}*/
record IF() implements Token {}
/*record ELSE() implements Token {}
record BREAK() implements Token {}
record SWITCH() implements Token {}
record CASE() implements Token {}
record RETURN() implements Token {}
record VOID() implements Token {}
record BOOLEAN() implements Token {}
record JNULL() implements Token {}
record INT() implements Token {}
record CHAR() implements Token {}
record STRING() implements Token {}
record LONG() implements Token {}
record BOOLEANLITERALTRUE () implements Token {}
record BOOLEANLITERALFALSE() implements Token {}
record INTLITERAL (Integer i) implements Token {}
record LONGLITERAL (String Str) implements Token {}
record FLOATLITERAL (String Str) implements Token {}
record CHARLITERAL (String Str) implements Token {}
record STRINGLITERAL (String Str) implements Token {}
record MEMORYADRESSLITERAL (String Str) implements Token {}
record NAME (String Str) implements Token {}
record WHITESPACE() implements Token {}*/
public sealed interface List<T> permits Cons, Empty {}
public record Cons<T>(T a, List<T> l) implements List<T> {}
public record Empty<T>() implements List<T> {}
public class LLParser {
public stmt (Cons(fst, List<Token> rest)) {
return switch (fst) {
case IF a -> ifThenElsestatement(rest);
};
}
/*public stmt(IF()) { return new IF(); }
statement (Cons(IF(), rest)) {
return ifThenElsestatement(rest);
}*/
ifThenElsestatement (Empty()) {
return new Empty();
}
ifThenElsestatement (Cons(fst, List<Token> rest)) {
return switch(fst) {
case LBRACE() -> rest;
};
}
}
@@ -57,9 +57,4 @@ public record TargetFunNType(String name, List<TargetType> funNParams, List<Targ
} }
return Objects.equals(name, otfn.name); return Objects.equals(name, otfn.name);
} }
@Override
public String toString() {
return toSignature();
}
} }
@@ -50,9 +50,7 @@ public class Logger {
public static void resetLogs() { public static void resetLogs() {
defaultWriter = null; defaultWriter = null;
try { try {
FileUtils.cleanDirectory(logFolder); FileUtils.cleanDirectory(logFolder);
} catch (FileNotFoundException e) {
// Ignore
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
+7 -8
View File
@@ -1365,14 +1365,6 @@ public class TestComplete {
main.invoke(null, List.of()); main.invoke(null, List.of());
} }
@Test
public void testLLParser() throws Exception {
ConsoleInterface.logLevel = LogLevel.INFO;
var classFiles = generateClassFiles(createClassLoader(), "LLParser.jav");
var clazz = classFiles.get("LLParser");
var instance = clazz.getDeclaredConstructor().newInstance();
}
@Test @Test
public void testBug122() throws Exception { public void testBug122() throws Exception {
var classFiles = generateClassFiles(createClassLoader(), "Bug122.jav"); var classFiles = generateClassFiles(createClassLoader(), "Bug122.jav");
@@ -1814,4 +1806,11 @@ public class TestComplete {
var bnot = clazz.getDeclaredMethod("not", Integer.class); var bnot = clazz.getDeclaredMethod("not", Integer.class);
assertEquals(-11, bnot.invoke(instance, 10)); assertEquals(-11, bnot.invoke(instance, 10));
} }
@Test
public void testBug466() throws Exception {
var classFiles = generateClassFiles(createClassLoader(), "Bug466.jav");
var clazz = classFiles.get("Bug466");
clazz.getDeclaredMethod("main", List.class).invoke(null, List.of());
}
} }