Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b0c419a1a | ||
|
|
67d9be8878 | ||
|
|
e1b9766a53 | ||
|
|
35e8dda6bd | ||
|
|
bf22cf246e | ||
|
|
034cdf2e0b | ||
|
|
95ee84cb99 | ||
|
|
3fc098b155 | ||
|
|
32ddb1132f | ||
|
|
174c999543 | ||
|
|
4b576da19d | ||
|
|
942b8ca488 | ||
|
|
de96cda327 | ||
|
|
2710685db3 | ||
|
|
272d9fa586 | ||
|
|
32a01c500a |
No files matched your search
@@ -0,0 +1,7 @@
|
|||||||
|
import java.lang.Integer;
|
||||||
|
|
||||||
|
public interface Bug411 {
|
||||||
|
default f() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import java.lang.Integer;
|
||||||
|
|
||||||
|
public class Bug412 {
|
||||||
|
public m(Integer i) {
|
||||||
|
var r = 0;
|
||||||
|
switch (i) {
|
||||||
|
case 1: r = 10; break;
|
||||||
|
default: r = 20;
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import java.lang.Integer;
|
||||||
|
sealed interface L<T> permits Cons, Nil {}
|
||||||
|
public record Cons<T>(T head, L<T> tail) implements L<T> {}
|
||||||
|
public record Nil<T>() implements L<T> {}
|
||||||
|
|
||||||
|
public class Bug416 {
|
||||||
|
public static <T> len(Cons(h, t)) { return 1 + len(t); }
|
||||||
|
public static <T> len(Nil()) { return 0; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import java.lang.Integer;
|
||||||
|
import java.lang.String;
|
||||||
|
|
||||||
|
public class Bug417 {
|
||||||
|
public name(Integer i) {
|
||||||
|
return switch (i) {
|
||||||
|
case 1 -> "one";
|
||||||
|
default -> "many";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,15 +13,15 @@ public sealed interface LazyList permits Empty, Cons {
|
|||||||
public Integer fst();
|
public Integer fst();
|
||||||
public LazyList rest();
|
public LazyList rest();
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
public class Filter {
|
public class Filter {
|
||||||
/*public LazyList filter(Fun1$$<Integer, Boolean> p, LazyList l) {
|
public LazyList filter(Fun1$$<Integer, Boolean> p, LazyList l) {
|
||||||
return switch(l) {
|
return switch(l) {
|
||||||
case Empty e -> e;
|
case Empty e -> e;
|
||||||
case Cons(Integer x, Supplier<LazyList> l1) ->
|
case Cons(Integer x, Supplier<LazyList> l1) ->
|
||||||
p.apply(x) ? new Cons(x, () -> filter(p, l1.get())) : filter(p, l1.get());
|
p.apply(x) ? new Cons(x, () -> filter(p, l1.get())) : filter(p, l1.get());
|
||||||
};
|
};
|
||||||
}*/
|
}
|
||||||
public LazyList filter(Fun1$$<Integer, Boolean> p, Empty()@l) {
|
public LazyList filter(Fun1$$<Integer, Boolean> p, Empty()@l) {
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
@@ -31,6 +31,8 @@ public class Filter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
//Der Konstruktor Cons muss lazy sein, deshalb hier Supplier<...>
|
//Der Konstruktor Cons muss lazy sein, deshalb hier Supplier<...>
|
||||||
record Cons(Integer x, Fun0$$<LazyList> l) implements LazyList {
|
record Cons(Integer x, Fun0$$<LazyList> l) implements LazyList {
|
||||||
public Integer fst() { return this.x; }
|
public Integer fst() { return this.x; }
|
||||||
@@ -45,7 +47,7 @@ record Empty() implements LazyList {
|
|||||||
public LazyList rest() { return null; }
|
public LazyList rest() { return null; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
class Main {
|
class Main {
|
||||||
static LazyList Count(int i) { return new Cons(i, () -> Count(i+1)); }
|
static LazyList Count(int i) { return new Cons(i, () -> Count(i+1)); }
|
||||||
|
|
||||||
@@ -54,3 +56,4 @@ class Main {
|
|||||||
System.out.println(Count(1).rest().fst());
|
System.out.println(Count(1).rest().fst());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
@@ -5,4 +5,8 @@ public class Literal {
|
|||||||
public m2() { return 'C'; }
|
public m2() { return 'C'; }
|
||||||
public m3() { return 10L; }
|
public m3() { return 10L; }
|
||||||
public m4() { return 10.5F; }
|
public m4() { return 10.5F; }
|
||||||
|
public m5() { return 10.5D; }
|
||||||
|
public m6() { return 0xFF; }
|
||||||
|
public m7() { return 0b101010; }
|
||||||
|
public m8() { return 010; }
|
||||||
}
|
}
|
||||||
@@ -7,9 +7,10 @@ import java.io.PrintStream;
|
|||||||
import LazyList;
|
import LazyList;
|
||||||
import Cons;
|
import Cons;
|
||||||
import Empty;
|
import Empty;
|
||||||
import Filter;
|
//import Filter;
|
||||||
|
|
||||||
public class Primzahlen {
|
public class Primzahlen {
|
||||||
|
/*
|
||||||
static LazyList from(Integer i) { return new Cons(i, () -> from(i+1)); }
|
static LazyList from(Integer i) { return new Cons(i, () -> from(i+1)); }
|
||||||
|
|
||||||
/*LazyList filter(Fun1$$<Integer, Boolean> p, LazyList l) {
|
/*LazyList filter(Fun1$$<Integer, Boolean> p, LazyList l) {
|
||||||
@@ -18,7 +19,7 @@ public class Primzahlen {
|
|||||||
case Cons(Integer x, Fun0$$<LazyList> l1) ->
|
case Cons(Integer x, Fun0$$<LazyList> l1) ->
|
||||||
p.apply(x) ? new Cons(x, () -> filter(p, l1.apply())) : filter(p, l1.apply());
|
p.apply(x) ? new Cons(x, () -> filter(p, l1.apply())) : filter(p, l1.apply());
|
||||||
};
|
};
|
||||||
}*/
|
}
|
||||||
|
|
||||||
LazyList dropMul(Integer x, LazyList xs) {
|
LazyList dropMul(Integer x, LazyList xs) {
|
||||||
return new Filter().filter(y -> (y % x != 0), xs);
|
return new Filter().filter(y -> (y % x != 0), xs);
|
||||||
@@ -40,13 +41,13 @@ public class Primzahlen {
|
|||||||
new Cons(x, () -> take(n-1, l1.apply()));
|
new Cons(x, () -> take(n-1, l1.apply()));
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
public static void main(args) {
|
public static void main(args) {
|
||||||
System.out.println(new Cons(1, () -> new Cons(2, () -> new Empty())).fst());
|
//System.out.println(new Cons(1, () -> new Cons(2, () -> new Empty())).fst());
|
||||||
var l = new Cons(1, () -> new Cons(2, () -> new Cons(2, () -> new Empty())));
|
var l = new Cons(1, () -> new Cons(2, () -> new Cons(2, () -> new Empty())));
|
||||||
System.out.println(l);
|
//System.out.println(l);
|
||||||
var filtered = new Filter().filter(x -> x == 2, l);
|
//var filtered = new Filter().filter(x -> x == 2, l);
|
||||||
System.out.println(filtered);
|
//ystem.out.println(filtered);
|
||||||
//System.out.println(from(1).rest().fst());
|
//System.out.println(from(1).rest().fst());
|
||||||
//Primzahlen pz = new Primzahlen();
|
//Primzahlen pz = new Primzahlen();
|
||||||
//System.out.println(pz.take(10, pz.from(2)));
|
//System.out.println(pz.take(10, pz.from(2)));
|
||||||
|
|||||||
@@ -1437,13 +1437,16 @@ public class Codegen {
|
|||||||
if (label instanceof TargetTypePattern || label instanceof TargetComplexPattern) {
|
if (label instanceof TargetTypePattern || label instanceof TargetComplexPattern) {
|
||||||
if (label.type() instanceof TargetGenericType) types.add(Type.getType(Object.class));
|
if (label.type() instanceof TargetGenericType) types.add(Type.getType(Object.class));
|
||||||
else types.add(Type.getObjectType(label.type().getInternalName()));
|
else types.add(Type.getObjectType(label.type().getInternalName()));
|
||||||
} else if (label instanceof TargetLiteral lit) {
|
} else if (label instanceof TargetExpressionPattern expr) {
|
||||||
types.add(lit.value());
|
if (expr.expression() instanceof TargetLiteral literal) {
|
||||||
|
types.add(Type.getObjectType(TargetType.toWrapper(literal.type()).getInternalName()));
|
||||||
|
} else {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
} else if (label instanceof TargetGuard guard) {
|
} else if (label instanceof TargetGuard guard) {
|
||||||
types.add(Type.getObjectType(guard.inner().type().getInternalName()));
|
types.add(Type.getObjectType(guard.inner().type().getInternalName()));
|
||||||
// TODO Same here we need to evaluate constant;
|
// TODO Same here we need to evaluate constant;
|
||||||
} else {
|
} else {
|
||||||
logger.info(label);
|
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1777,7 +1780,7 @@ public class Codegen {
|
|||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
state.scope.parent = parent.scope;
|
state.scope.parent = parent.scope;
|
||||||
}
|
}
|
||||||
var offset = 1;
|
var offset = method.isStatic() ? 0 : 1;
|
||||||
for (var param : method.signature().parameters()) {
|
for (var param : method.signature().parameters()) {
|
||||||
state.createVariable(param.pattern().name(), param.pattern().type());
|
state.createVariable(param.pattern().name(), param.pattern().type());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import de.dhbwstuttgart.typeinference.constraints.Pair;
|
|||||||
import de.dhbwstuttgart.typeinference.unify.PlaceholderRegistry;
|
import de.dhbwstuttgart.typeinference.unify.PlaceholderRegistry;
|
||||||
import de.dhbwstuttgart.typeinference.unify.model.*;
|
import de.dhbwstuttgart.typeinference.unify.model.*;
|
||||||
|
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@@ -54,7 +55,8 @@ public class FCGenerator {
|
|||||||
|
|
||||||
|
|
||||||
private static Boolean isFunctionalInterface(ClassOrInterface cly) {
|
private static Boolean isFunctionalInterface(ClassOrInterface cly) {
|
||||||
return (cly.isInterface() && (cly.isFunctionalInterface() || cly.getMethods().size() == 1));
|
// TODO isFunctionalInterface should be set properly, we shouldn't need to check it again
|
||||||
|
return (cly.isInterface() && (cly.isFunctionalInterface() || cly.getMethods().size() == 1 && Modifier.isAbstract(cly.getMethods().getFirst().modifier)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Pair genImplFunType(ClassOrInterface cly, RefTypeOrTPHOrWildcardOrGeneric fIType, HashMap<String, RefTypeOrTPHOrWildcardOrGeneric> gtvs) {
|
private static Pair genImplFunType(ClassOrInterface cly, RefTypeOrTPHOrWildcardOrGeneric fIType, HashMap<String, RefTypeOrTPHOrWildcardOrGeneric> gtvs) {
|
||||||
|
|||||||
@@ -405,14 +405,16 @@ public class StatementGenerator {
|
|||||||
|
|
||||||
private SwitchBlock convert(Java17Parser.SwitchBlockStatementGroupContext stmt) {
|
private SwitchBlock convert(Java17Parser.SwitchBlockStatementGroupContext stmt) {
|
||||||
List<SwitchLabel> labels = new ArrayList<>();
|
List<SwitchLabel> labels = new ArrayList<>();
|
||||||
stmt.switchLabel().forEach((label) -> {
|
var isDefault = false;
|
||||||
|
for (var label : stmt.switchLabel()) {
|
||||||
|
if (label instanceof SwitchLabelDefaultContext) isDefault = true;
|
||||||
labels.add(convert(label));
|
labels.add(convert(label));
|
||||||
});
|
}
|
||||||
List<Statement> block = new ArrayList<>();
|
List<Statement> block = new ArrayList<>();
|
||||||
stmt.blockStatement().stream().forEach((blockStmt) -> {
|
stmt.blockStatement().stream().forEach((blockStmt) -> {
|
||||||
block.addAll(convert(blockStmt));
|
block.addAll(convert(blockStmt));
|
||||||
});
|
});
|
||||||
return new SwitchBlock(labels, new Block(block, stmt.blockStatement(0).getStart()), false, stmt.getStart());
|
return new SwitchBlock(labels, new Block(block, stmt.blockStatement(0).getStart()), isDefault,false, stmt.getStart());
|
||||||
}
|
}
|
||||||
|
|
||||||
private SwitchLabel convert(SwitchLabelContext switchLabel) {
|
private SwitchLabel convert(SwitchLabelContext switchLabel) {
|
||||||
@@ -1033,10 +1035,22 @@ public class StatementGenerator {
|
|||||||
private Expression convert(Java17Parser.LiteralContext literal) {
|
private Expression convert(Java17Parser.LiteralContext literal) {
|
||||||
switch (literal) {
|
switch (literal) {
|
||||||
case IntLiteralContext intliteral:
|
case IntLiteralContext intliteral:
|
||||||
|
var text = intliteral.getText();
|
||||||
|
var radix = 10;
|
||||||
|
if (text.startsWith("0x") || text.startsWith("0X")) {
|
||||||
|
radix = 16;
|
||||||
|
text = text.substring(2);
|
||||||
|
} else if (text.startsWith("0b") || text.startsWith("0B")) {
|
||||||
|
radix = 2;
|
||||||
|
text = text.substring(2);
|
||||||
|
} else if (text.startsWith("0") && text.length() > 1) {
|
||||||
|
radix = 8;
|
||||||
|
text = text.substring(1);
|
||||||
|
}
|
||||||
Number value;
|
Number value;
|
||||||
if (intliteral.getText().endsWith("l") || intliteral.getText().endsWith("L"))
|
if (text.endsWith("l") || text.endsWith("L"))
|
||||||
value = Long.parseLong(intliteral.getText().substring(0, intliteral.getText().length() - 1));
|
value = Long.parseLong(text.substring(0, text.length() - 1), radix);
|
||||||
else value = Integer.parseInt(intliteral.getText());
|
else value = Integer.parseInt(text, radix);
|
||||||
return new Literal(TypePlaceholder.fresh(literal.getStart()), value, intliteral.getStart());
|
return new Literal(TypePlaceholder.fresh(literal.getStart()), value, intliteral.getStart());
|
||||||
case FltLiteralContext floatliteral:
|
case FltLiteralContext floatliteral:
|
||||||
if (floatliteral.getText().endsWith("f") || floatliteral.getText().endsWith("F"))
|
if (floatliteral.getText().endsWith("f") || floatliteral.getText().endsWith("F"))
|
||||||
@@ -1097,7 +1111,7 @@ public class StatementGenerator {
|
|||||||
if (expression.lambdaBody().expression() != null) {
|
if (expression.lambdaBody().expression() != null) {
|
||||||
List<Statement> statements = new ArrayList<>();
|
List<Statement> statements = new ArrayList<>();
|
||||||
statements.add(new Return(lambdaGenerator.convert(expression.lambdaBody().expression()), expression.lambdaBody().expression().getStart()));
|
statements.add(new Return(lambdaGenerator.convert(expression.lambdaBody().expression()), expression.lambdaBody().expression().getStart()));
|
||||||
block = new Block(statements, expression.lambdaBody().getStart());
|
block = new Block(statements, expression.lambdaBody().getStart(), -1);
|
||||||
} else {
|
} else {
|
||||||
block = lambdaGenerator.convert(expression.lambdaBody().block(), true);
|
block = lambdaGenerator.convert(expression.lambdaBody().block(), true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -409,8 +409,9 @@ public class SyntaxTreeGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isFunctonalInterfce = methods.size() == 1 && Modifier.isAbstract(methods.getFirst().modifier);
|
||||||
var staticCtor = Optional.of(this.generateStaticConstructor(ctx.identifier().getText(), staticFieldInitializations, genericParams, ctx.getStart()));
|
var staticCtor = Optional.of(this.generateStaticConstructor(ctx.identifier().getText(), staticFieldInitializations, genericParams, ctx.getStart()));
|
||||||
return new ClassOrInterface(modifiers, name, fields, Optional.empty(), staticCtor, methods, new ArrayList<>(), genericParams, superClass, true, methods.size() == 1 ? true : false, extendedInterfaces, permittedSubtypes, ctx.getStart(), fileName);
|
return new ClassOrInterface(modifiers, name, fields, Optional.empty(), staticCtor, methods, new ArrayList<>(), genericParams, superClass, true, isFunctonalInterfce, extendedInterfaces, permittedSubtypes, ctx.getStart(), fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private GenericDeclarationList createEmptyGenericDeclarationList(Token classNameIdentifier) {
|
private GenericDeclarationList createEmptyGenericDeclarationList(Token classNameIdentifier) {
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ public class Block extends Statement {
|
|||||||
this.statements = statements;
|
this.statements = statements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Block(List<Statement> statements, Token offset, int variance) {
|
||||||
|
super(TypePlaceholder.fresh(offset, variance, true), offset);
|
||||||
|
this.statements = statements;
|
||||||
|
}
|
||||||
|
|
||||||
public List<Statement> statements = new ArrayList<>();
|
public List<Statement> statements = new ArrayList<>();
|
||||||
|
|
||||||
public List<Statement> getStatements() {
|
public List<Statement> getStatements() {
|
||||||
|
|||||||
@@ -188,8 +188,10 @@ public class OutputGenerator implements ASTVisitor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(LambdaExpression lambdaExpression) {
|
public void visit(LambdaExpression lambdaExpression) {
|
||||||
lambdaExpression.params.accept(this);
|
out.append("(");
|
||||||
|
lambdaExpression.params.accept(this);
|
||||||
out.append(" -> ");
|
out.append(" -> ");
|
||||||
|
out.append("(");
|
||||||
lambdaExpression.methodBody.accept(this);
|
lambdaExpression.methodBody.accept(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import org.objectweb.asm.Opcodes;
|
|||||||
|
|
||||||
import java.lang.classfile.Opcode;
|
import java.lang.classfile.Opcode;
|
||||||
import java.lang.reflect.AccessFlag;
|
import java.lang.reflect.AccessFlag;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@@ -630,7 +631,7 @@ public class ASTToTargetAST {
|
|||||||
mParams,
|
mParams,
|
||||||
classType,
|
classType,
|
||||||
method.name(),
|
method.name(),
|
||||||
false, false, method.isPrivate()
|
method.isStatic(), false, method.isPrivate()
|
||||||
);
|
);
|
||||||
if (method.signature().returnType() != null) {
|
if (method.signature().returnType() != null) {
|
||||||
caseBody = new TargetReturn(caseBody);
|
caseBody = new TargetReturn(caseBody);
|
||||||
|
|||||||
@@ -476,7 +476,7 @@ public class StatementToTargetExpression implements ASTVisitor {
|
|||||||
.map(this::extractAllPatterns)
|
.map(this::extractAllPatterns)
|
||||||
.flatMap(List::stream).toList();
|
.flatMap(List::stream).toList();
|
||||||
case FormalParameter param -> List.of(new TypeVariants(param.getType(), converter.findAllVariants(param.getType())));
|
case FormalParameter param -> List.of(new TypeVariants(param.getType(), converter.findAllVariants(param.getType())));
|
||||||
default -> List.of();
|
case null, default -> List.of();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -875,8 +875,8 @@ public class TYPEStmt implements StatementVisitor {
|
|||||||
if (caseExpressionType == null) {
|
if (caseExpressionType == null) {
|
||||||
for (var child : switchStmt.getBlocks()) {
|
for (var child : switchStmt.getBlocks()) {
|
||||||
for (var label : child.getLabels()) {
|
for (var label : child.getLabels()) {
|
||||||
if (label.getPattern() == null) {
|
if (label.getPattern() == null && switchStmt.getSwitch().getType() instanceof TypePlaceholder) {
|
||||||
constraintsSet.addUndConstraint(new Pair(new RefType(new JavaClassName("java.lang.Object"), new NullToken()), switchStmt.getSwitch().getType(), PairOperator.SMALLERDOT, loc(label.getOffset())));
|
constraintsSet.addUndConstraint(new Pair(new RefType(new JavaClassName("java.lang.Object"), new NullToken()), switchStmt.getSwitch().getType(), PairOperator.EQUALSDOT, loc(label.getOffset())));
|
||||||
}
|
}
|
||||||
if (label.getPattern() instanceof RecordPattern) {
|
if (label.getPattern() instanceof RecordPattern) {
|
||||||
RecordPattern recordPattern = (RecordPattern) label.getPattern();
|
RecordPattern recordPattern = (RecordPattern) label.getPattern();
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public class distributeVariance extends visitUnifyTypeVisitor<Integer> {
|
|||||||
List<UnifyType> param = new ArrayList<>(funnty.getTypeParams().get().length);
|
List<UnifyType> param = new ArrayList<>(funnty.getTypeParams().get().length);
|
||||||
param.addAll(Arrays.asList(funnty.getTypeParams().get()));
|
param.addAll(Arrays.asList(funnty.getTypeParams().get()));
|
||||||
UnifyType resultType = param.remove(param.size()-1);
|
UnifyType resultType = param.remove(param.size()-1);
|
||||||
|
ht = (ht == 0)? 1 : 0; //bei ht = 0 wird ht auf die Standardwerte für Functionstypes gesetzt
|
||||||
int htInverse = inverseVariance(ht);
|
int htInverse = inverseVariance(ht);
|
||||||
param = param.stream()
|
param = param.stream()
|
||||||
.map(x -> x.accept(this, htInverse))
|
.map(x -> x.accept(this, htInverse))
|
||||||
|
|||||||
@@ -257,6 +257,7 @@ public class TestComplete {
|
|||||||
@Test
|
@Test
|
||||||
//@Disabled("This is too complex")
|
//@Disabled("This is too complex")
|
||||||
public void matrixTest() throws Exception {
|
public void matrixTest() throws Exception {
|
||||||
|
//ConsoleInterface.logLevel = LogLevel.DEBUG;
|
||||||
var classFiles = generateClassFiles(createClassLoader(), "Matrix.jav");
|
var classFiles = generateClassFiles(createClassLoader(), "Matrix.jav");
|
||||||
var matrix = classFiles.get("Matrix");
|
var matrix = classFiles.get("Matrix");
|
||||||
|
|
||||||
@@ -1230,6 +1231,10 @@ public class TestComplete {
|
|||||||
assertEquals('C', clazz.getDeclaredMethod("m2").invoke(instance));
|
assertEquals('C', clazz.getDeclaredMethod("m2").invoke(instance));
|
||||||
assertEquals(10L, clazz.getDeclaredMethod("m3").invoke(instance));
|
assertEquals(10L, clazz.getDeclaredMethod("m3").invoke(instance));
|
||||||
assertEquals(10.5F, clazz.getDeclaredMethod("m4").invoke(instance));
|
assertEquals(10.5F, clazz.getDeclaredMethod("m4").invoke(instance));
|
||||||
|
assertEquals(10.5D, clazz.getDeclaredMethod("m5").invoke(instance));
|
||||||
|
assertEquals(0xFF, clazz.getDeclaredMethod("m6").invoke(instance));
|
||||||
|
assertEquals(0b101010, clazz.getDeclaredMethod("m7").invoke(instance));
|
||||||
|
assertEquals(010, clazz.getDeclaredMethod("m8").invoke(instance));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -1355,6 +1360,7 @@ public class TestComplete {
|
|||||||
@Disabled("See #405")
|
@Disabled("See #405")
|
||||||
@Test
|
@Test
|
||||||
public void testLazy() throws Exception {
|
public void testLazy() throws Exception {
|
||||||
|
ConsoleInterface.logLevel = LogLevel.DEBUG;
|
||||||
var classFiles = generateClassFiles(createClassLoader(), false, "LazyList.jav", "Primzahlen.jav");
|
var classFiles = generateClassFiles(createClassLoader(), false, "LazyList.jav", "Primzahlen.jav");
|
||||||
var clazz = classFiles.get("Primzahlen");
|
var clazz = classFiles.get("Primzahlen");
|
||||||
var main = clazz.getDeclaredMethod("main", List.class);
|
var main = clazz.getDeclaredMethod("main", List.class);
|
||||||
@@ -1745,4 +1751,47 @@ public class TestComplete {
|
|||||||
var m = clazz.getDeclaredMethod("m");
|
var m = clazz.getDeclaredMethod("m");
|
||||||
assertEquals(5, m.invoke(instance));
|
assertEquals(5, m.invoke(instance));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBug417() throws Exception {
|
||||||
|
var classFiles = generateClassFiles(createClassLoader(), "Bug417.jav");
|
||||||
|
var clazz = classFiles.get("Bug417");
|
||||||
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||||
|
var name = clazz.getDeclaredMethod("name", Integer.class);
|
||||||
|
assertEquals("one", name.invoke(instance, 1));
|
||||||
|
assertEquals("many", name.invoke(instance, 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBug411() throws Exception {
|
||||||
|
var classFiles = generateClassFiles(createClassLoader(), "Bug411.jav");
|
||||||
|
var clazz = classFiles.get("Bug411");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBug412() throws Exception {
|
||||||
|
var classFiles = generateClassFiles(createClassLoader(), "Bug412.jav");
|
||||||
|
var clazz = classFiles.get("Bug412");
|
||||||
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||||
|
var m = clazz.getDeclaredMethod("m", Integer.class);
|
||||||
|
assertEquals(10, m.invoke(instance, 1));
|
||||||
|
assertEquals(20, m.invoke(instance, 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBug416() throws Exception {
|
||||||
|
var classFiles = generateClassFiles(createClassLoader(), "Bug416.jav");
|
||||||
|
var clazz = classFiles.get("Bug416");
|
||||||
|
var L = classFiles.get("L");
|
||||||
|
var Cons = classFiles.get("Cons");
|
||||||
|
var Nil = classFiles.get("Nil");
|
||||||
|
|
||||||
|
var consCtor = Cons.getDeclaredConstructor(Object.class, L);
|
||||||
|
var nilCtor = Nil.getDeclaredConstructor();
|
||||||
|
|
||||||
|
var list = consCtor.newInstance(1, consCtor.newInstance(2, consCtor.newInstance(3, nilCtor.newInstance())));
|
||||||
|
|
||||||
|
var len = clazz.getDeclaredMethod("len", L);
|
||||||
|
assertEquals(3, len.invoke(null, list));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user