From 97cb020d45b46577504dabdcb1addb3939715e0c Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Tue, 14 Jul 2015 14:49:46 +0200 Subject: [PATCH] =?UTF-8?q?Bytecode=20Tests=20anf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/bytecode/Return.jav | 11 ++++++++++ test/bytecode/Return.java | 45 +++++++++++++++++++++++++++++++++++++++ test/bytecode/Test.java | 8 +++++++ 3 files changed, 64 insertions(+) create mode 100644 test/bytecode/Return.jav create mode 100644 test/bytecode/Return.java create mode 100644 test/bytecode/Test.java diff --git a/test/bytecode/Return.jav b/test/bytecode/Return.jav new file mode 100644 index 000000000..08c297924 --- /dev/null +++ b/test/bytecode/Return.jav @@ -0,0 +1,11 @@ +class Assign{ + +method() {a; + a = 20; + b; + b=59; + return a + b; + } + + +} \ No newline at end of file diff --git a/test/bytecode/Return.java b/test/bytecode/Return.java new file mode 100644 index 000000000..2d7c48037 --- /dev/null +++ b/test/bytecode/Return.java @@ -0,0 +1,45 @@ +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 Return { + + public final static String rootDirectory = System.getProperty("user.dir")+"/test/bytecode/"; + public final static String testFile = "Assign.jav"; + public final static String outputFile = "Assign.class"; + + @Test + public void test() { + LoggerConfiguration logConfig = new LoggerConfiguration().setOutput(Section.PARSER, System.out); + MyCompilerAPI compiler = MyCompiler.getAPI(logConfig); + try { + compiler.parse(new File(rootDirectory + testFile)); + compiler.typeReconstruction(); + ByteCodeResult bytecode = compiler.generateBytecode(); + System.out.println(bytecode); + bytecode.getByteCode().getJavaClass().dump(new File(rootDirectory + outputFile)); + } catch (IOException | yyException e) { + e.printStackTrace(); + TestCase.fail(); + } + } + +} diff --git a/test/bytecode/Test.java b/test/bytecode/Test.java new file mode 100644 index 000000000..e50bce6ab --- /dev/null +++ b/test/bytecode/Test.java @@ -0,0 +1,8 @@ +/** + * Diese Klasse testet die generierte EmptyClass.class-Datei + */ +class Test{ +public static void main(String[] args){ + new EmptyClass(); +} +}