From bdbe20552e4493212661d36c2f009e715a964a3a Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Thu, 29 Oct 2015 15:16:19 +0100 Subject: [PATCH] =?UTF-8?q?Tests=20zu=20Bytecodegenerierung=20anf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/bytecode/Binary.jav | 10 ++++++ test/bytecode/Binary2.jav | 16 +++++++++ test/bytecode/BinaryTest.java | 34 +++++++++++++++++++ test/bytecode/BinaryTest2.java | 34 +++++++++++++++++++ .../MultipleTypesInsertTester.java | 6 ++-- 5 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 test/bytecode/Binary.jav create mode 100644 test/bytecode/Binary2.jav create mode 100644 test/bytecode/BinaryTest.java create mode 100644 test/bytecode/BinaryTest2.java diff --git a/test/bytecode/Binary.jav b/test/bytecode/Binary.jav new file mode 100644 index 00000000..3ea073fb --- /dev/null +++ b/test/bytecode/Binary.jav @@ -0,0 +1,10 @@ +class Binary{ + +void method() { +a; +a = 20; +b; +b=59 + a; +} + +} \ No newline at end of file diff --git a/test/bytecode/Binary2.jav b/test/bytecode/Binary2.jav new file mode 100644 index 00000000..f587c123 --- /dev/null +++ b/test/bytecode/Binary2.jav @@ -0,0 +1,16 @@ +class OL { + + Integer m(Integer x) { return x + x; } + + Boolean m(Boolean x) {return x || x; } +} + +class Binary2 { + + main(x) { + ol; + ol = new OL(); + return ol.m(x); + } + +} \ No newline at end of file diff --git a/test/bytecode/BinaryTest.java b/test/bytecode/BinaryTest.java new file mode 100644 index 00000000..37b0ab82 --- /dev/null +++ b/test/bytecode/BinaryTest.java @@ -0,0 +1,34 @@ +package bytecode; + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.IOException; + +import junit.framework.TestCase; + +import org.junit.Test; + +import plugindevelopment.TypeInsertTester; +import de.dhbwstuttgart.core.MyCompiler; +import de.dhbwstuttgart.core.MyCompilerAPI; +import de.dhbwstuttgart.logger.LoggerConfiguration; +import de.dhbwstuttgart.logger.Section; +import de.dhbwstuttgart.parser.JavaParser.yyException; +import de.dhbwstuttgart.typeinference.ByteCodeResult; +import de.dhbwstuttgart.typeinference.Menge; +import de.dhbwstuttgart.typeinference.TypeinferenceResultSet; +import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet; + +public class BinaryTest { + + public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/"; + public final static String testFile = "Binary.jav"; + public final static String outputFile = "Binary.class"; + + @Test + public void test() { + SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile); + } + +} diff --git a/test/bytecode/BinaryTest2.java b/test/bytecode/BinaryTest2.java new file mode 100644 index 00000000..8660ef0e --- /dev/null +++ b/test/bytecode/BinaryTest2.java @@ -0,0 +1,34 @@ +package bytecode; + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.IOException; + +import junit.framework.TestCase; + +import org.junit.Test; + +import plugindevelopment.TypeInsertTester; +import de.dhbwstuttgart.core.MyCompiler; +import de.dhbwstuttgart.core.MyCompilerAPI; +import de.dhbwstuttgart.logger.LoggerConfiguration; +import de.dhbwstuttgart.logger.Section; +import de.dhbwstuttgart.parser.JavaParser.yyException; +import de.dhbwstuttgart.typeinference.ByteCodeResult; +import de.dhbwstuttgart.typeinference.Menge; +import de.dhbwstuttgart.typeinference.TypeinferenceResultSet; +import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet; + +public class BinaryTest2 { + + public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/"; + public final static String testFile = "Binary2.jav"; + public final static String outputFile = "Binary2.class"; + + @Test + public void test() { + SingleClassTester.compileToBytecode(rootDirectory+testFile, rootDirectory+outputFile); + } + +} diff --git a/test/plugindevelopment/TypeInsertTests/MultipleTypesInsertTester.java b/test/plugindevelopment/TypeInsertTests/MultipleTypesInsertTester.java index 80628a37..d4fee620 100755 --- a/test/plugindevelopment/TypeInsertTests/MultipleTypesInsertTester.java +++ b/test/plugindevelopment/TypeInsertTests/MultipleTypesInsertTester.java @@ -14,6 +14,7 @@ import de.dhbwstuttgart.logger.Section; import de.dhbwstuttgart.logger.SectionLogger; import de.dhbwstuttgart.logger.Timewatch; import de.dhbwstuttgart.parser.JavaParser.yyException; +import de.dhbwstuttgart.syntaxtree.SourceFile; import de.dhbwstuttgart.typeinference.TypeinferenceResultSet; import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertPoint; import de.dhbwstuttgart.typeinference.typedeployment.TypeInsertSet; @@ -78,8 +79,9 @@ public class MultipleTypesInsertTester extends TypeInsertTester{ String inferedSource = ""; MyCompilerAPI compiler = MyCompiler.getAPI(logConfig); try { - compiler.parse(new File(rootDirectory + sourceFileToInfere)); - Menge results = compiler.typeReconstruction(); + Menge parsedSource = new Menge<>(); + parsedSource.add(compiler.parse(new File(rootDirectory + sourceFileToInfere))); + Menge results = compiler.typeReconstruction(parsedSource); //TestCase.assertTrue("Es darf nicht mehr als eine Lösungsmöglichkeit geben und nicht "+results.size(), results.size()==1); for(TypeinferenceResultSet result : results){ TypeInsertSet point = result.getTypeInsertionPoints();