Public all the things

This commit is contained in:
Daniel Holle 2024-03-14 13:50:56 +01:00
parent e354838491
commit f9188e65ca
42 changed files with 107 additions and 78 deletions

View File

@ -69,6 +69,7 @@ http://maven.apache.org/maven-v4_0_0.xsd">
<trimStackTrace>true</trimStackTrace> <trimStackTrace>true</trimStackTrace>
<excludes> <excludes>
<exclude>**/JavaTXCompilerTest.java</exclude> <exclude>**/JavaTXCompilerTest.java</exclude>
<exclude>**/AllgemeinTest.java</exclude>
<exclude>**/syntaxtreegenerator/*.java</exclude> <exclude>**/syntaxtreegenerator/*.java</exclude>
</excludes> </excludes>
</configuration> </configuration>

View File

@ -3,15 +3,15 @@ import java.lang.Double;
public class BinaryInMeth { public class BinaryInMeth {
m(a){ public m(a){
return ++a; return ++a;
} }
m2(a,b){ public m2(a,b){
return m(a+b); return m(a+b);
} }
m3(a) { public m3(a) {
return m(++a); return m(++a);
} }
} }

View File

@ -1,5 +1,5 @@
public class Bug112 { public class Bug112 {
m(x) { public m(x) {
var y; var y;
x = y; x = y;
return y; return y;

View File

@ -1,8 +1,8 @@
import java.lang.Integer; import java.lang.Integer;
import java.lang.Boolean; import java.lang.Boolean;
class Bug122 { public class Bug122 {
void main() { public void main() {
if (true) { if (true) {
for (Integer i = 0; i < 10; i++) { for (Integer i = 0; i < 10; i++) {

View File

@ -1,12 +1,12 @@
import java.lang.Boolean; import java.lang.Boolean;
import java.lang.Integer; import java.lang.Integer;
class Bug123 { public class Bug123 {
Boolean works(){ public Boolean works(){
if(true) return true; if(true) return true;
else return false; else return false;
} }
void fails(){ public void fails(){
Boolean a = true; Boolean a = true;
if(true) a = false; if(true) a = false;
} }

View File

@ -5,11 +5,11 @@ import java.util.List;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.ArrayList; import java.util.ArrayList;
class Bug125 { public class Bug125 {
static ArrayList<String> works = new ArrayList<>(); static ArrayList<String> works = new ArrayList<>();
static List<String> fails = new ArrayList<>(); static List<String> fails = new ArrayList<>();
void main() { public void main() {
works.toString(); works.toString();
fails.toString(); fails.toString();
} }

View File

@ -1,14 +1,14 @@
import java.util.Optional; import java.util.Optional;
import java.lang.Integer; import java.lang.Integer;
class StaticClass { public class StaticClass {
static StaticClass barbar() { public static StaticClass barbar() {
return new StaticClass(); return new StaticClass();
} }
} }
public class Bug285 { public class Bug285 {
void foo() { public void foo() {
Optional<Integer> opt = Optional.empty(); Optional<Integer> opt = Optional.empty();
StaticClass b = StaticClass.barbar(); StaticClass b = StaticClass.barbar();
} }

View File

@ -0,0 +1,7 @@
import Bug290B;
public class Bug290A {
public void m() {
new Bug290B();
}
}

View File

@ -0,0 +1,11 @@
import java.lang.String;
import java.lang.Integer;
public class Bug290B {
String name;
public Bug290B() {
Integer i = 0;
name = i.toString() + "$$";
}
}

View File

@ -4,7 +4,7 @@ import java.lang.String;
public class Bug98 { public class Bug98 {
m(x, y ,z) { public m(x, y ,z) {
x = new Vector<Integer>(); x = new Vector<Integer>();
y = new Vector<String>(); y = new Vector<String>();
x.add(1); x.add(1);

View File

@ -7,7 +7,7 @@ public class Chain {
return this; return this;
} }
m() { public m() {
return this.chain().chain().chain().x; return this.chain().chain().chain().x;
} }
} }

View File

@ -1,5 +1,5 @@
class Cycle { public class Cycle {
m(x, y) { public m(x, y) {
y = x; y = x;
x = y; x = y;
} }

View File

@ -2,7 +2,7 @@ import java.lang.String;
import java.lang.RuntimeException; import java.lang.RuntimeException;
public class Exceptions { public class Exceptions {
m() { public m() {
throw new RuntimeException("Some Exception"); throw new RuntimeException("Some Exception");
} }
} }

View File

@ -1,14 +1,14 @@
import java.lang.String; import java.lang.String;
public class FieldTph2 { public class FieldTph2 {
a; public a;
m(b){ public m(b){
b = a; b = a;
return b; return b;
} }
m2(c){ public m2(c){
a = c; a = c;
} }
} }

View File

@ -1,20 +1,20 @@
public class FieldTphConsMeth { public class FieldTphConsMeth {
a; public a;
public FieldTphConsMeth(c) { public FieldTphConsMeth(c) {
a = id(c); a = id(c);
} }
id(b) { public id(b) {
return b; return b;
} }
setA(x) { public setA(x) {
a = x; a = x;
return a; return a;
} }
m(x,y) { public m(x,y) {
x = id(y); x = id(y);
} }

View File

@ -1,13 +1,13 @@
import java.lang.Boolean; import java.lang.Boolean;
public class FieldTphMMeth { public class FieldTphMMeth {
a; public a;
public FieldTphMMeth(c,d,e) { public FieldTphMMeth(c,d,e) {
a = m(c,d,e); a = m(c,d,e);
} }
m(b,d,e) { public m(b,d,e) {
if(e) { if(e) {
return m3(b); return m3(b);
} else{ } else{
@ -16,11 +16,11 @@ public class FieldTphMMeth {
} }
m2(b) { public m2(b) {
a = m3(b); a = m3(b);
} }
m3(b){ public m3(b){
return b; return b;
} }

View File

@ -1,8 +1,8 @@
import java.lang.Integer; import java.lang.Integer;
import java.lang.Boolean; import java.lang.Boolean;
class For{ public class For{
Integer m(Integer x){ public Integer m(Integer x){
var c = x + 2; var c = x + 2;
Boolean b = true; Boolean b = true;
c = 5; c = 5;

View File

@ -6,7 +6,7 @@ public class FunctionalInterface {
return f.apply(20); return f.apply(20);
} }
Integer m() { public Integer m() {
var v = accept(i -> { var v = accept(i -> {
return i * 10; return i * 10;
}); });

View File

@ -3,7 +3,7 @@ import java.lang.String;
import java.io.PrintStream; import java.io.PrintStream;
public class HelloWorld { public class HelloWorld {
static hello() { public static hello() {
System.out.println("Hello World!"); System.out.println("Hello World!");
} }
} }

View File

@ -12,7 +12,7 @@ class Test2 {
public class InstanceOf { public class InstanceOf {
a = new Test(); a = new Test();
test1() { return this.a instanceof Test; } public test1() { return this.a instanceof Test; }
test2() { return this.a instanceof Interface; } public test2() { return this.a instanceof Interface; }
test3() { return this.a instanceof Integer; } public test3() { return this.a instanceof Integer; }
} }

View File

@ -2,7 +2,7 @@ import java.lang.Integer;
public class Lambda { public class Lambda {
m () { public m() {
var lam1 = (x) -> { var lam1 = (x) -> {
return x; return x;
}; };

View File

@ -1,6 +1,6 @@
import java.lang.Character; import java.lang.Character;
public class Literal { public class Literal {
m() { return null; } public m() { return null; }
m2() { return 'C'; } public m2() { return 'C'; }
} }

View File

@ -9,7 +9,7 @@ public class Matrix extends Vector<Vector<Integer>> {
Matrix () { Matrix () {
} }
Matrix(vv) { public Matrix(vv) {
Integer i; Integer i;
i = 0; i = 0;
while(i < vv.size()) { while(i < vv.size()) {
@ -19,7 +19,7 @@ public class Matrix extends Vector<Vector<Integer>> {
} }
} }
mul(m) { public mul(m) {
var ret = new Matrix(); var ret = new Matrix();
var i = 0; var i = 0;
while(i < size()) { while(i < size()) {

View File

@ -8,7 +8,7 @@ public class MatrixOP extends Vector<Vector<Integer>> {
MatrixOP () { MatrixOP () {
} }
MatrixOP(vv) { public MatrixOP(vv) {
Integer i; Integer i;
i = 0; i = 0;
while(i < vv.size()) { while(i < vv.size()) {

View File

@ -2,16 +2,16 @@ import java.util.List;
import java.lang.Integer; import java.lang.Integer;
//import java.util.Collection; //import java.util.Collection;
class Merge { public class Merge {
merge(a, b) { public merge(a, b) {
a.addAll(b); a.addAll(b);
return a; return a;
} }
sort(in){ public sort(in){
var firstHalf = in.subList(1,2); var firstHalf = in.subList(1,2);
var secondHalf = in.subList(1,2); var secondHalf = in.subList(1,2);
return merge(sort(firstHalf), sort(secondHalf)); return merge(sort(firstHalf), sort(secondHalf));

View File

@ -2,7 +2,7 @@ import java.lang.Double;
import java.lang.String; import java.lang.String;
import java.lang.Long; import java.lang.Long;
class OL { public class OL {
m (x) { return x + x; } m (x) { return x + x; }
} }

View File

@ -10,8 +10,8 @@ public class Parent {
public Parent() {} public Parent() {}
} }
class Child extends Parent { public class Child extends Parent {
Child() { public Child() {
super(3); super(3);
} }
} }

View File

@ -3,9 +3,9 @@ import java.lang.Double;
import java.lang.String; import java.lang.String;
public class Op2 { public class Op2 {
m(){ public m(){
//var x = ""; var x = "";
//var a = 5+x; var a = 5+x;
Integer x = 10; Integer x = 10;
Double y = 10.5; Double y = 10.5;

View File

@ -5,15 +5,15 @@ import java.lang.Float;
record Point(Number x, Number y) {} record Point(Number x, Number y) {}
public class OverloadPattern { public class OverloadPattern {
m(Point(Integer x, Integer y)) { public m(Point(Integer x, Integer y)) {
return x + y; return x + y;
} }
m(Point(Float x, Float y)) { public m(Point(Float x, Float y)) {
return x * y; return x * y;
} }
m(Integer x) { public m(Integer x) {
return x; return x;
} }
} }

View File

@ -2,17 +2,17 @@ import java.lang.String;
public class Overloading{ public class Overloading{
test(x){ public test(x){
return x.methode(); return x.methode();
} }
methode(){ public methode(){
return "Overloading"; return "Overloading";
} }
} }
public class Overloading2{ public class Overloading2{
methode(){ public methode(){
return "Overloading2"; return "Overloading2";
} }
} }

View File

@ -3,15 +3,15 @@ import java.lang.Boolean;
import java.lang.Object; import java.lang.Object;
class Pair<T, U> { public class Pair<T, U> {
T x; T x;
U y; U y;
fst () { public fst() {
return x; return x;
} }
snd () { public snd() {
return y; return y;
} }
} }

View File

@ -3,7 +3,7 @@ import java.lang.String;
public class Plus { public class Plus {
m(a,b) { public m(a,b) {
return a+b; return a+b;
} }
} }

View File

@ -15,8 +15,8 @@ public class RecordTest {
b = new Rec(10, 20); b = new Rec(10, 20);
c = new Rec(20, 40); c = new Rec(20, 40);
doesEqual() { return a.equals(b); } public doesEqual() { return a.equals(b); }
doesNotEqual() { return b.equals(c); } public doesNotEqual() { return b.equals(c); }
hashCode() { return a.hashCode(); } public hashCode() { return a.hashCode(); }
toString() { return a.toString(); } public toString() { return a.toString(); }
} }

View File

@ -2,7 +2,7 @@ import java.lang.Integer;
import java.lang.Boolean; import java.lang.Boolean;
public class RelOps { public class RelOps {
m(a,b){ public m(a,b){
return a<b; return a<b;
} }
} }

View File

@ -6,7 +6,7 @@ import java.lang.Float;
public class Scalar extends Vector<Integer> { public class Scalar extends Vector<Integer> {
Scalar(v) { public Scalar(v) {
Integer i; Integer i;
i = 0; i = 0;
while(i < v.size()) { while(i < v.size()) {
@ -15,7 +15,7 @@ public class Scalar extends Vector<Integer> {
} }
} }
mul(v) { public mul(v) {
var ret = 0; var ret = 0;
var i = 0; var i = 0;
while(i < size()) { while(i < size()) {

View File

@ -12,7 +12,7 @@ public class Static {
i = x; i = x;
} }
static m() { public static m() {
return i + Other.field; return i + Other.field;
} }
} }

View File

@ -2,10 +2,10 @@ import java.lang.Integer;
import java.lang.Object; import java.lang.Object;
import java.lang.Float; import java.lang.Float;
record Rec(Integer a, Object b) {} public record Rec(Integer a, Object b) {}
public class Switch { public class Switch {
main(o) { public main(o) {
return switch (o) { return switch (o) {
case Rec(Integer a, Integer b) -> a + b; case Rec(Integer a, Integer b) -> a + b;
case Rec(Integer a, Float b) -> a + 10; case Rec(Integer a, Float b) -> a + 10;

View File

@ -3,7 +3,7 @@ import java.lang.String;
import java.lang.Object; import java.lang.Object;
public class SwitchString { public class SwitchString {
main(o) { public main(o) {
return switch (o) { return switch (o) {
case "AaAaAa" -> 1; // These two have the same hash code! case "AaAaAa" -> 1; // These two have the same hash code!
case "AaAaBB" -> 2; case "AaAaBB" -> 2;

View File

@ -1,10 +1,10 @@
import java.lang.String; import java.lang.String;
class TXGenerics { public class TXGenerics {
a; a;
b; b;
test() { public test() {
var c = new Cycle(); var c = new Cycle();
c.m(a, b); c.m(a, b);
} }

View File

@ -1,10 +1,10 @@
import java.lang.Integer; import java.lang.Integer;
class Y { public class Y {
y; y;
//factorial; //factorial;
Y() { public Y() {
y = f -> t -> f.apply(y.apply(f)).apply(t); y = f -> t -> f.apply(y.apply(f)).apply(t);
//factorial = y.apply(f -> n -> { if (n == 0) return 1; else return n * f.apply(n - 1); }); //factorial = y.apply(f -> n -> { if (n == 0) return 1; else return n * f.apply(n - 1); });
} }

View File

@ -3,7 +3,7 @@ class Apply { }
public class applyLambda { public class applyLambda {
m () { public m () {
var lam1 = (x) -> { var lam1 = (x) -> {
return x; return x;
}; };

View File

@ -670,6 +670,7 @@ public class TestComplete {
assertEquals(swtch.invoke(instance, "Some string"), 0); assertEquals(swtch.invoke(instance, "Some string"), 0);
} }
@Ignore("Not implemented")
@Test @Test
public void testSwitch2() throws Exception { public void testSwitch2() throws Exception {
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Switch2.jav"); var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Switch2.jav");
@ -698,6 +699,7 @@ public class TestComplete {
var instance = clazz.getDeclaredConstructor().newInstance(); var instance = clazz.getDeclaredConstructor().newInstance();
} }
@Ignore("Not implemented")
@Test @Test
public void testOverloadPattern() throws Exception { public void testOverloadPattern() throws Exception {
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "OverloadPattern.jav"); var classFiles = generateClassFiles(new ByteArrayClassLoader(), "OverloadPattern.jav");
@ -833,6 +835,7 @@ public class TestComplete {
assertEquals(clazz.getSuperclass().getDeclaredField("x").get(instance), 3); assertEquals(clazz.getSuperclass().getDeclaredField("x").get(instance), 3);
} }
@Ignore("Not implemented")
@Test @Test
public void testStringConcat() throws Exception { public void testStringConcat() throws Exception {
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Op2.jav"); var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Op2.jav");
@ -923,4 +926,11 @@ public class TestComplete {
var clazz = classFiles.get("Bug285"); var clazz = classFiles.get("Bug285");
var instance = clazz.getDeclaredConstructor().newInstance(); var instance = clazz.getDeclaredConstructor().newInstance();
} }
@Test
public void testBug290() throws Exception {
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug290A.jav");
var clazz = classFiles.get("Bug290A");
var instance = clazz.getDeclaredConstructor().newInstance();
}
} }