From ffdedd4f99bf1854b59fde45e14a67941634b372 Mon Sep 17 00:00:00 2001 From: Victorious3 Date: Wed, 1 Mar 2023 15:55:15 +0100 Subject: [PATCH] Add OL tests --- resources/bytecode/javFiles/OLFun.jav | 5 +++++ resources/bytecode/javFiles/OLFun2.jav | 2 +- .../target/generate/ASTToTargetAST.java | 2 +- src/test/java/targetast/TestComplete.java | 12 ++++++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/resources/bytecode/javFiles/OLFun.jav b/resources/bytecode/javFiles/OLFun.jav index adf8c6a8..ae4c9c5b 100644 --- a/resources/bytecode/javFiles/OLFun.jav +++ b/resources/bytecode/javFiles/OLFun.jav @@ -9,5 +9,10 @@ public class OLFun { //f = x -> {return x + x;}; m(f, x) { x = f.apply(x+x); + return x; + } + + m2(y) { + m(x -> x * 2, y); } } \ No newline at end of file diff --git a/resources/bytecode/javFiles/OLFun2.jav b/resources/bytecode/javFiles/OLFun2.jav index 406c0d98..6b6f38ac 100644 --- a/resources/bytecode/javFiles/OLFun2.jav +++ b/resources/bytecode/javFiles/OLFun2.jav @@ -8,6 +8,6 @@ public class OLFun2 { x; m(f){ - x = f.apply(x + x) + x = f.apply(x + x); } } \ No newline at end of file diff --git a/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java b/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java index c518b23c..86c94f7e 100644 --- a/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java +++ b/src/main/java/de/dhbwstuttgart/target/generate/ASTToTargetAST.java @@ -205,7 +205,7 @@ public class ASTToTargetAST { all.addAll(toAdd); HashSet newPairs = new HashSet<>(); - + // Loop from hell outer: for (var tph : typeVariables) { diff --git a/src/test/java/targetast/TestComplete.java b/src/test/java/targetast/TestComplete.java index c78afbec..e2b86f27 100644 --- a/src/test/java/targetast/TestComplete.java +++ b/src/test/java/targetast/TestComplete.java @@ -585,4 +585,16 @@ public class TestComplete { var classFiles = generateClassFiles("Cycle.jav", new ByteArrayClassLoader()); var instance = classFiles.get("Cycle").getDeclaredConstructor().newInstance(); } + + @Test + public void olFunTest() throws Exception { + var classFiles = generateClassFiles("OLFun.jav", new ByteArrayClassLoader()); + var instance = classFiles.get("OLFun").getDeclaredConstructor().newInstance(); + } + + @Test + public void olFun2Test() throws Exception { + var classFiles = generateClassFiles("OLFun2.jav", new ByteArrayClassLoader()); + var instance = classFiles.get("OLFun2").getDeclaredConstructor().newInstance(); + } }