Created test suite for syntaxtreegenerator including resources

This commit is contained in:
luca9913 2023-06-06 21:21:26 +02:00
parent 63c5cb8390
commit 48199b5d2e
45 changed files with 1089 additions and 0 deletions

View File

@ -0,0 +1,60 @@
package syntaxtreegenerator;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.fail;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileReader;
import java.util.HashMap;
import org.junit.BeforeClass;
import org.junit.Test;
import de.dhbwstuttgart.core.JavaTXCompiler;
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
public class ValidSourcesTest {
private final String expectedASTDirectory = "src/test/resources/syntaxtreegenerator/";
private static HashMap<String, File> javFiles = new HashMap<>();
@BeforeClass
public static void setUpFiles() {
final String testFileDirectory = "src/test/resources/bytecode/javFiles/";
File dir = new File(testFileDirectory);
for (File f : dir.listFiles(new JavFilter())) {
javFiles.put(f.getName().replace(".jav", ""), f);
}
}
@Test
public void applyLambdaTest() {
try {
FileInputStream expInStream = new FileInputStream(new File(expectedASTDirectory + "applyLambda.ast"));
byte[] expectedAST = expInStream.readAllBytes();
expectedAST = new String(expectedAST).replaceAll("TPH [A-Z]+", "TPH").getBytes();
File sf = javFiles.get("applyLambda");
JavaTXCompiler compiler = new JavaTXCompiler(sf);
byte[] resultingAST = new String(ASTPrinter.print(compiler.sourceFiles.get(sf)).getBytes()).replaceAll("TPH [A-Z]+", "TPH").getBytes();
System.out.println("Expected:\n" + new String(expectedAST));
System.out.println("Result:\n" + new String(resultingAST));
assertArrayEquals("Comparing expected and resulting AST for applyLambda.jav", expectedAST, resultingAST);
} catch (Exception exc) {
exc.printStackTrace();
fail("An error occured while generating the AST for applyLambda.jav");
}
}
}
class JavFilter implements FileFilter {
@Override
public boolean accept(File pathname) {
if (pathname.getName().contains(".jav"))
return true;
return false;
}
}

View File

@ -0,0 +1,22 @@
class BinaryInMeth {
BinaryInMeth(){
super(());
}
TPH CMNB m(TPH CMNC a){
return ++a;
}
TPH CMNF m2(TPH CMNG a, TPH CMNH b){
return this.m Signature: [TPH CMNK, TPH CMNL](a op b);
}
TPH CMNP m3(TPH CMNQ a){
return this.m Signature: [TPH CMNT, TPH CMNU](++a);
}
BinaryInMeth(){
super(());
}
}

View File

@ -0,0 +1,14 @@
class ClassGenLam {
TPH HWDB lam;
ClassGenLam(){
super(());
this.lam = (TPH HWDC x) -> {
return x;
};
}
ClassGenLam(){
super(());
}
}

View File

@ -0,0 +1,16 @@
class Cycle {
Cycle(){
super(());
}
TPH GGXG m(TPH GGXH x, TPH GGXI y){
y = x;
x = y;
return;
}
Cycle(){
super(());
}
}

View File

@ -0,0 +1,22 @@
class Fac {
Fac(){
super(());
}
TPH BSTE getFac(TPH BSTF n){
TPH BSTG res;
res = 1;
TPH BSTI i;
i = 1;
while(i op n){
res = res op i;
i++;
};
return res;
}
Fac(){
super(());
}
}

View File

@ -0,0 +1,25 @@
class Faculty {
TPH DDAL fact;
Faculty(){
super(());
}
TPH DDBK getFact(java.lang.Integer x){
return this.fact.apply Signature: [TPH DDBM, TPH DDBN](x);
}
Faculty(){
super(());
this.fact = (TPH DDAO x) -> {
if(x op 1)
{
return 1;
}
else
{
return x op this.fact.apply Signature: [TPH DDAW, TPH DDAX](x op 1);
};
};
}
}

View File

@ -0,0 +1,16 @@
class Field {
TPH JBCG x;
Field(){
super(());
this.x = 5;
}
TPH JBCJ m(){
return this.x;
}
Field(){
super(());
}
}

View File

@ -0,0 +1,21 @@
class FieldTph2 {
TPH DJBG a;
FieldTph2(){
super(());
}
TPH DJBH m(TPH DJBI b){
b = this.a;
return b;
}
TPH DJBL m2(TPH DJBM c){
this.a = c;
return;
}
FieldTph2(){
super(());
}
}

View File

@ -0,0 +1,27 @@
class FieldTphConsMeth {
TPH AINS a;
FieldTphConsMeth(){
super(());
}
TPH AIOE id(TPH AIOF b){
return b;
}
TPH AIOH setA(TPH AIOI x){
this.a = x;
return this.a;
}
TPH AIOM m(TPH AION x, TPH AIOO y){
x = this.id Signature: [TPH AIOQ, TPH AIOR](y);
return;
}
FieldTphConsMeth(TPH AINU c){
super(());
this.a = this.id Signature: [TPH AINX, TPH AINY](c);
return;
}
}

View File

@ -0,0 +1,33 @@
class FieldTphMMeth {
TPH HBWQ a;
FieldTphMMeth(){
super(());
}
TPH HBXG m(TPH HBXH b, TPH HBXI d, TPH HBXJ e){
if(e)
{
return this.m3 Signature: [TPH HBXL, TPH HBXM](b);
}
else
{
return this.m3 Signature: [TPH HBXR, TPH HBXS](d);
};
}
TPH HBXY m2(TPH HBXZ b){
this.a = this.m3 Signature: [TPH HBYC, TPH HBYD](b);
return;
}
TPH HBYH m3(TPH HBYI b){
return b;
}
FieldTphMMeth(TPH HBWS c, TPH HBWT d, TPH HBWU e){
super(());
this.a = this.m Signature: [TPH HBWX, TPH HBWY, TPH HBWZ, TPH HBXA](c, d, e);
return;
}
}

View File

@ -0,0 +1,14 @@
class Gen {
Gen(){
super(());
}
java.util.Vector<java.lang.Integer> m(java.util.Vector<java.lang.Integer> v){
return v;
}
Gen(){
super(());
}
}

View File

@ -0,0 +1,18 @@
class Id<FAU> {
TPH BDGF id2;
Id(){
super(());
this.id2 = (TPH BDGG x) -> {
return x;
};
}
TPH BDGM id3(TPH BDGN x){
return this.id2.apply Signature: [TPH BDGP, TPH BDGQ](x);
}
Id(){
super(());
}
}

View File

@ -0,0 +1,28 @@
class Inf {
Inf(){
super(());
}
TPH KYAM m(TPH KYAN x, TPH KYAO y, TPH KYAP a){
TPH KYAQ z;
TPH KYAR v;
TPH KYAS w;
TPH KYAT b;
y = x;
z = x;
v = y;
w = y;
y = a;
b = a;
TPH KYAU c;
TPH KYAV d;
c = v;
d = v;
return;
}
Inf(){
super(());
}
}

View File

@ -0,0 +1,26 @@
class KompTph {
KompTph(){
super(());
}
TPH EOGX m(TPH EOGY a, TPH EOGZ b, TPH EOHA c){
TPH EOHB d;
d = a;
TPH EOHC e;
e = a;
a = b;
c = b;
this.m2 Signature: [TPH EOHE, TPH EOHF, TPH EOHG](a, c);
return;
}
TPH EOHK m2(TPH EOHL a, TPH EOHM b){
this.m Signature: [TPH EOHO, TPH EOHP, TPH EOHQ, TPH EOHR](a, a, b);
return;
}
KompTph(){
super(());
}
}

View File

@ -0,0 +1,18 @@
class Lambda {
Lambda(){
super(());
}
TPH KIZQ m(){
TPH KIZR lam1;
lam1 = (TPH KIZS x) -> {
return x;
};
return lam1;
}
Lambda(){
super(());
}
}

View File

@ -0,0 +1,18 @@
class LambdaCapture {
java.lang.Integer i;
TPH BIMD f;
LambdaCapture(){
super(());
this.i = 8;
}
LambdaCapture(){
super(());
java.lang.Integer w;
w = 7;
this.f = (TPH BIMH j) -> {
return w op this.i;
};
}
}

View File

@ -0,0 +1,52 @@
class Matrix {
Matrix(){
super(());
}
TPH SBB mul(TPH SBC m){
TPH SBD ret;
ret = new Matrix();
TPH SBF i;
i = 0;
while(i op this.size Signature: [TPH SBJ]()){
TPH SBM v1;
v1 = this.elementAt Signature: [TPH SBO, TPH SBP](i);
TPH SBS v2;
v2 = new java.util.Vector();
TPH SBU j;
j = 0;
while(j op v1.size Signature: [TPH SBX]()){
TPH SCA erg;
erg = 0;
TPH SCC k;
k = 0;
while(k op v1.size Signature: [TPH SCF]()){
erg = erg op v1.elementAt Signature: [TPH SCI, TPH SCJ](k) op m.elementAt Signature: [TPH SCM, TPH SCN](k).elementAt Signature: [TPH SCQ, TPH SCR](j);
k++;
};
v2.addElement Signature: [TPH SCZ, TPH SDA](erg);
j++;
};
ret.addElement Signature: [TPH SDG, TPH SDH](v2);
i++;
};
return ret;
}
Matrix(){
super(());
return;
}
Matrix(TPH SAF vv){
super(());
java.lang.Integer i;
i = 0;
while(i op vv.size Signature: [TPH SAI]()){
this.add Signature: [TPH SAQ, TPH SAR](vv.elementAt Signature: [TPH SAM, TPH SAN](i));
i = i op 1;
};
return;
}
}

View File

@ -0,0 +1,52 @@
class MatrixOP {
TPH JGDT mul;
MatrixOP(){
super(());
this.mul = (TPH JGDU m1, TPH JGDV m2) -> {
TPH JGDW ret;
ret = new MatrixOP();
TPH JGDY i;
i = 0;
while(i op m1.size Signature: [TPH JGEB]()){
TPH JGEE v1;
v1 = m1.elementAt Signature: [TPH JGEF, TPH JGEG](i);
TPH JGEJ v2;
v2 = new java.util.Vector();
TPH JGEL j;
j = 0;
while(j op v1.size Signature: [TPH JGEO]()){
TPH JGER erg;
erg = 0;
TPH JGET k;
k = 0;
while(k op v1.size Signature: [TPH JGEW]()){
erg = erg op v1.elementAt Signature: [TPH JGEZ, TPH JGFA](k) op m2.elementAt Signature: [TPH JGFD, TPH JGFE](k).elementAt Signature: [TPH JGFH, TPH JGFI](j);
k++;
};
v2.addElement Signature: [TPH JGFQ, TPH JGFR](erg);
j++;
};
ret.addElement Signature: [TPH JGFX, TPH JGFY](v2);
i++;
};
return ret;
};
}
MatrixOP(){
super(());
return;
}
MatrixOP(TPH JGGP vv){
super(());
java.lang.Integer i;
i = 0;
while(i op vv.size Signature: [TPH JGGS]()){
this.add Signature: [TPH JGHA, TPH JGHB](vv.elementAt Signature: [TPH JGGW, TPH JGGX](i));
i = i op 1;
};
return;
}
}

View File

@ -0,0 +1,23 @@
class Merge {
Merge(){
super(());
}
TPH JQYM merge(TPH JQYN a, TPH JQYO b){
a.addAll Signature: [TPH JQYP, TPH JQYQ](b);
return a;
}
TPH JQYU sort(TPH JQYV in){
TPH JQYW firstHalf;
firstHalf = in.subList Signature: [TPH JQYZ, TPH JQZA, TPH JQZB](1, 2);
TPH JQZE secondHalf;
secondHalf = in.subList Signature: [TPH JQZH, TPH JQZI, TPH JQZJ](1, 2);
return this.merge Signature: [TPH JQZX, TPH JQZY, TPH JQZZ](this.sort Signature: [TPH JQZO, TPH JQZP](firstHalf), this.sort Signature: [TPH JQZT, TPH JQZU](secondHalf));
}
Merge(){
super(());
}
}

View File

@ -0,0 +1,41 @@
class OL {
OL(){
super(());
}
java.lang.Double m(java.lang.Double x){
return x op x;
}
java.lang.Integer m(java.lang.Integer x){
return x op x;
}
java.lang.String m(java.lang.String x){
return x op x;
}
java.lang.Boolean m(java.lang.Boolean x){
return x;
}
OL(){
super(());
}
}class OLMain {
OLMain(){
super(());
}
TPH BYOF main(TPH BYOG x){
TPH BYOH ol;
ol = new OL();
return ol.m Signature: [TPH BYOJ, TPH BYOK](x);
}
OLMain(){
super(());
}
}

View File

@ -0,0 +1,22 @@
class OLFun {
OLFun(){
super(());
}
TPH JXJR m(TPH JXJS f, TPH JXJT x){
x = f.apply Signature: [TPH JXJV, TPH JXJW](x op x);
return x;
}
TPH JXKA m2(TPH JXKB y){
this.m Signature: [TPH JXKK, TPH JXKL, TPH JXKM]((TPH JXKD x) -> {
return x op 2;
}, y);
return;
}
OLFun(){
super(());
}
}

View File

@ -0,0 +1,16 @@
class OLFun2 {
TPH CTXA x;
OLFun2(){
super(());
}
TPH CTXB m(TPH CTXC f){
this.x = f.apply Signature: [TPH CTXH, TPH CTXI](this.x op this.x);
return;
}
OLFun2(){
super(());
}
}

View File

@ -0,0 +1,31 @@
class Overloading {
Overloading(){
super(());
}
TPH N test(TPH O x){
return x.methode Signature: [TPH P]();
}
TPH T methode(){
return Overloading;
}
Overloading(){
super(());
}
}class Overloading2 {
Overloading2(){
super(());
}
TPH AO methode(){
return Overloading2;
}
Overloading2(){
super(());
}
}

View File

@ -0,0 +1,20 @@
class Pair<U, T> {
U a;
T b;
Pair(){
super(());
}
TPH IURS make(TPH IURT x){
TPH IURU ret;
ret = new Pair();
ret.a = x.elementAt Signature: [TPH IUSA, TPH IUSB](0);
ret.b = x.elementAt Signature: [TPH IUSG, TPH IUSH](1);
return ret;
}
Pair(){
super(());
}
}

View File

@ -0,0 +1,14 @@
class Plus {
Plus(){
super(());
}
TPH ACHZ m(TPH ACIA a, TPH ACIB b){
return a op b;
}
Plus(){
super(());
}
}

View File

@ -0,0 +1,14 @@
class RelOps {
RelOps(){
super(());
}
TPH IPBY m(TPH IPBZ a, TPH IPCA b){
return a op b;
}
RelOps(){
super(());
}
}

View File

@ -0,0 +1,29 @@
class Scalar {
Scalar(){
super(());
}
TPH KOXT mul(TPH KOXU v){
TPH KOXV ret;
ret = 0;
TPH KOXX i;
i = 0;
while(i op this.size Signature: [TPH KOYB]()){
ret = ret op this.elementAt Signature: [TPH KOYF, TPH KOYG](i) op v.elementAt Signature: [TPH KOYJ, TPH KOYK](i);
i = i op 1;
};
return ret;
}
Scalar(TPH KOWX v){
super(());
java.lang.Integer i;
i = 0;
while(i op v.size Signature: [TPH KOXA]()){
this.add Signature: [TPH KOXI, TPH KOXJ](v.elementAt Signature: [TPH KOXE, TPH KOXF](i));
i = i op 1;
};
return;
}
}

View File

@ -0,0 +1,18 @@
class SimpleCycle {
SimpleCycle(){
super(());
}
TPH ETMJ m(){
TPH ETMK g;
TPH ETML h;
g = h;
h = g;
return;
}
SimpleCycle(){
super(());
}
}

View File

@ -0,0 +1,23 @@
class Sorting {
Sorting(){
super(());
}
TPH JNN merge(TPH JNO a, TPH JNP b){
a.addAll Signature: [TPH JNQ, TPH JNR](b);
return a;
}
TPH JNV sort(TPH JNW in){
TPH JNX firstHalf;
firstHalf = in;
TPH JNY secondHalf;
secondHalf = in;
return this.merge Signature: [TPH JOK, TPH JOL, TPH JOM](this.sort Signature: [TPH JOB, TPH JOC](firstHalf), this.sort Signature: [TPH JOG, TPH JOH](secondHalf));
}
Sorting(){
super(());
}
}

View File

@ -0,0 +1,26 @@
class Matrix2 {
Matrix2(){
super(());
}
Matrix2(){
super(());
}
}class SubMatrix {
SubMatrix(){
super(());
}
TPH DOFK m(){
java.util.Vector<java.lang.Integer> v;
v = new java.util.Vector();
v.add Signature: [TPH DOFN, TPH DOFO](1);
return;
}
SubMatrix(){
super(());
}
}

View File

@ -0,0 +1,19 @@
class TXGenerics {
TPH GLEG a;
TPH GLEH b;
TXGenerics(){
super(());
}
TPH GLEI test(){
TPH GLEJ c;
c = new Cycle();
c.m Signature: [TPH GLEN, TPH GLEO, TPH GLEP](this.a, this.b);
return;
}
TXGenerics(){
super(());
}
}

View File

@ -0,0 +1,20 @@
class Tph {
Tph(){
super(());
}
TPH BNOP m(TPH BNOQ a, TPH BNOR b){
TPH BNOS c;
c = this.m2 Signature: [TPH BNOU, TPH BNOV](b);
return a;
}
TPH BNOZ m2(TPH BNPA b){
return b;
}
Tph(){
super(());
}
}

View File

@ -0,0 +1,18 @@
class Tph2 {
TPH FGYW id;
Tph2(){
super(());
this.id = (TPH FGYX x) -> {
return x;
};
}
TPH FGZD id3(TPH FGZE x){
return this.id.apply Signature: [TPH FGZG, TPH FGZH](x);
}
Tph2(){
super(());
}
}

View File

@ -0,0 +1,21 @@
class Tph3 {
Tph3(){
super(());
}
TPH FMEJ m1(TPH FMEK x, TPH FMEL y){
this.m2 Signature: [TPH FMEN, TPH FMEO](x);
x = y;
return;
}
TPH FMES m2(TPH FMET y){
this.m1 Signature: [TPH FMEV, TPH FMEW, TPH FMEX](y, y);
return;
}
Tph3(){
super(());
}
}

View File

@ -0,0 +1,22 @@
class Tph4 {
Tph4(){
super(());
}
TPH FRJD m(TPH FRJE a, TPH FRJF b){
TPH FRJG c;
c = this.m2 Signature: [TPH FRJI, TPH FRJJ](b);
TPH FRJM d;
d = this.m2 Signature: [TPH FRJO, TPH FRJP](c);
return d;
}
TPH FRJT m2(TPH FRJU b){
return b;
}
Tph4(){
super(());
}
}

View File

@ -0,0 +1,19 @@
class Tph5 {
Tph5(){
super(());
}
TPH FWNY m(TPH FWNZ x, TPH FWOA y){
x = this.m2 Signature: [TPH FWOC, TPH FWOD](y);
return;
}
TPH FWOH m2(TPH FWOI y){
return y;
}
Tph5(){
super(());
}
}

View File

@ -0,0 +1,21 @@
class Tph6 {
Tph6(){
super(());
}
TPH GBSM m(TPH GBSN x, TPH GBSO y){
TPH GBSP c;
c = this.m2 Signature: [TPH GBSR, TPH GBSS](y);
c = this.m2 Signature: [TPH GBSW, TPH GBSX](x);
return;
}
TPH GBTB m2(TPH GBTC y){
return y;
}
Tph6(){
super(());
}
}

View File

@ -0,0 +1,20 @@
class Tph7 {
Tph7(){
super(());
}
TPH GQRI m(TPH GQRJ a, TPH GQRK b){
TPH GQRL c;
c = this.m2 Signature: [TPH GQRN, TPH GQRO](b);
return this.m2 Signature: [TPH GQRS, TPH GQRT](b);
}
TPH GQRX m2(TPH GQRY b){
return b;
}
Tph7(){
super(());
}
}

View File

@ -0,0 +1,22 @@
class TypedID {
TPH GVWK lam;
TypedID(){
super(());
this.lam = (TPH GVWL x) -> {
return x;
};
}
TPH GVWR id(TPH GVWS b){
return b;
}
TPH GVWU m(){
return this.lam;
}
TypedID(){
super(());
}
}

View File

@ -0,0 +1,31 @@
class VectorAdd {
VectorAdd(){
super(());
}
TPH EXVJ vectorAdd(TPH EXVK v1, TPH EXVL v2){
TPH EXVM i;
i = 0;
v1 = new java.util.Vector();
TPH EXVP erg;
erg = new java.util.Vector();
while(i op v1.size Signature: [TPH EXVT]()){
erg.addElement Signature: [TPH EXWF, TPH EXWG](v1.elementAt Signature: [TPH EXVW, TPH EXVX](i) op v2.elementAt Signature: [TPH EXWA, TPH EXWB](i));
i++;
};
return erg;
}
TPH EXWN m(TPH EXWO x, TPH EXWP y, TPH EXWQ z){
x = new java.util.Vector();
y = new java.util.Vector();
x.add Signature: [TPH EXWU, TPH EXWV](1);
y.add Signature: [TPH EXWY, TPH EXWZ](2);
return z.addAll Signature: [TPH EXXC, TPH EXXD](x);
}
VectorAdd(){
super(());
}
}

View File

@ -0,0 +1,17 @@
class VectorSuper {
VectorSuper(){
super(());
}
TPH HPGR m(TPH HPGS x){
java.lang.Integer y;
y = 1;
x.addElement Signature: [TPH HPGU, TPH HPGV](y);
return;
}
VectorSuper(){
super(());
}
}

View File

@ -0,0 +1,16 @@
class Y {
TPH IBFH y;
Y(){
super(());
}
Y(){
super(());
this.y = (TPH IBFK f) -> {
return (TPH IBFL t) -> {
return f.apply Signature: [TPH IBFR, TPH IBFS](this.y.apply Signature: [TPH IBFN, TPH IBFO](f)).apply Signature: [TPH IBFV, TPH IBFW](t);
};
};
}
}

View File

@ -0,0 +1,27 @@
class Apply {
Apply(){
super(());
}
Apply(){
super(());
}
}class applyLambda {
applyLambda(){
super(());
}
TPH ASWH m(){
TPH ASWI lam1;
lam1 = (TPH ASWJ x) -> {
return x;
};
return lam1.apply Signature: [TPH ASWP, TPH ASWQ](new Apply());
}
applyLambda(){
super(());
}
}

View File

@ -0,0 +1,19 @@
class mathStruc {
TPH IHHZ model;
TPH IHIA innerOp;
mathStruc(){
super(());
this.innerOp = (TPH IHIB o) -> {
return (TPH IHIC ms) -> {
return new mathStruc(o.apply Signature: [TPH IHIF, TPH IHIG, TPH IHIH](this.model, ms.model));
};
};
}
mathStruc(TPH IHIW m){
super(());
this.model = m;
return;
}
}

View File

@ -0,0 +1,38 @@
class mathStrucInteger {
TPH EBJW model;
TPH EBJX innerOp;
mathStrucInteger(){
super(());
this.innerOp = (TPH EBJY o) -> {
return (TPH EBJZ ms) -> {
return new mathStrucInteger(o.apply Signature: [TPH EBKC, TPH EBKD, TPH EBKE](this.model, ms.model));
};
};
}
mathStrucInteger(TPH EBKT m){
super(());
this.model = m;
return;
}
}class mathStrucIntegerUse {
mathStrucIntegerUse(){
super(());
}
TPH EBLO main(){
TPH EBLP ms;
ms = new mathStrucInteger(2);
TPH EBLT ms2;
ms2 = ms.innerOp.apply Signature: [TPH EBMD, TPH EBME]((TPH EBLV x, TPH EBLW y) -> {
return x op y;
}).apply Signature: [TPH EBMH, TPH EBMI](ms);
return ms2;
}
mathStrucIntegerUse(){
super(());
}
}