From 8060278e3f073ec631ac0531898c8ee591b2a345 Mon Sep 17 00:00:00 2001 From: JanUlrich Date: Thu, 13 Mar 2014 01:21:02 +0100 Subject: [PATCH] =?UTF-8?q?Kleine=20=C3=84nderungen=20an=20Tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mycompiler/mytest/LambdaTest.java | 1 + test/bytecode/BytecodeTester.java | 2 +- test/bytecode/GeneralTest.java | 2 +- test/mycompiler/test/lambda/TestInterface.jav | 8 +- .../test/lambda/testResults/LambdaTest.log | 166 +++++++----------- 5 files changed, 74 insertions(+), 105 deletions(-) diff --git a/src/mycompiler/mytest/LambdaTest.java b/src/mycompiler/mytest/LambdaTest.java index 519886f7..43aa5e30 100755 --- a/src/mycompiler/mytest/LambdaTest.java +++ b/src/mycompiler/mytest/LambdaTest.java @@ -189,6 +189,7 @@ public class LambdaTest { }catch(Exception e){ e.printStackTrace(); assertNotNull("Fehler bei Typinferenzalgorithmus. Message: "+e.getMessage(), resultSet); + fail(); } return resultSet; } diff --git a/test/bytecode/BytecodeTester.java b/test/bytecode/BytecodeTester.java index 1fdddafb..db64d3d8 100644 --- a/test/bytecode/BytecodeTester.java +++ b/test/bytecode/BytecodeTester.java @@ -21,7 +21,7 @@ public class BytecodeTester{ public static Vector testCodegen(String sourceCode){ MyCompilerAPI compiler = MyCompiler.getAPI(); - compiler.parse("class EmptyClass{}"); + compiler.parse(sourceCode); Vector ret = null; try { ret = compiler.codeGeneration(null); diff --git a/test/bytecode/GeneralTest.java b/test/bytecode/GeneralTest.java index 2f909050..816ecfbf 100644 --- a/test/bytecode/GeneralTest.java +++ b/test/bytecode/GeneralTest.java @@ -24,7 +24,7 @@ public class GeneralTest extends TestCase{ } assertTrue("Es darf nur eine ClassFile erstellt werden", cfs.size()==1); try { - FileOutputStream output = new FileOutputStream(new File(BytecodeTester.rootDirectory+"target-file")); + FileOutputStream output = new FileOutputStream(new File(BytecodeTester.rootDirectory+"FieldTest.class")); output.write(cfs.firstElement().getBytecode()); } catch (IOException e) { e.printStackTrace(); diff --git a/test/mycompiler/test/lambda/TestInterface.jav b/test/mycompiler/test/lambda/TestInterface.jav index 0adbc2a1..569e1294 100644 --- a/test/mycompiler/test/lambda/TestInterface.jav +++ b/test/mycompiler/test/lambda/TestInterface.jav @@ -1,3 +1,9 @@ interface TestInterface{ - + methode(); +} + +class TestClass implements TestInterface{ + methode(){ + return "test"; + } } \ No newline at end of file diff --git a/test/mycompiler/test/lambda/testResults/LambdaTest.log b/test/mycompiler/test/lambda/testResults/LambdaTest.log index 03bd567c..4aa85c5a 100644 --- a/test/mycompiler/test/lambda/testResults/LambdaTest.log +++ b/test/mycompiler/test/lambda/testResults/LambdaTest.log @@ -1,123 +1,85 @@ -Class DEBUG [Typeinference] Erstellte Assumptions: this: MatrixMethod Assumptions: -[MethodAssumption: Matrix null { []] +Class DEBUG [Typeinference] Erstellte Assumptions: this: ConstructorTest1Method Assumptions: +[MethodAssumption: ConstructorTest1 null { [no type [var], (var = int 1)]] FieldVar Assumptions: -[typinferenz.assumptions.FieldAssumption@cd7e6ef] +[] LocalVar Assumptions: [] Parameter Assumptions: [] -Block DEBUG [Typeinference] Prozessing statement: null Return null (( [ f, ]) -> null { [null Return null (f.apply( [ null (this(null)), m, ]))]) -Block DEBUG [Typeinference] Prozessing statement: null Return null (f.apply( [ null (this(null)), m, ])) -Block DEBUG [Typeinference] Prozessing statement: TPH CJ Return TPH CF (f: TPH CD.apply( [ Matrix (this(null)), m: TPH CB, ])) -Block DEBUG [Typeinference] Prozessing statement: TPH CK Return TPH CE (( [ TPH CD f, ]) -> TPH CJ { [TPH CJ Return TPH CF (f: TPH CD.apply( [ Matrix (this(null)), m: TPH CB, ]))]) -Class DEBUG [Typeinference] Erstellte Constraints: TPH BZ < TPH BZ -[(TPH CG <. TPH CF), (Matrix <. TPH CH), (TPH CB <. TPH CI), (TPH CD <. FunN), ] -TPH CF < TPH CJ -Fun1< TPH CJ, TPH CD > < TPH CE -TPH CE < TPH CK -Fun1< TPH CK, TPH CB > < TPH CC -TPH CC < TPH BZ +Block DEBUG [Typeinference] Prozessing statement: no type [var] +Block DEBUG [Typeinference] Prozessing statement: (var = int 1) +Block DEBUG [Typeinference] Prozessing statement: void(var: TPH D = int 1) +Block DEBUG [Typeinference] Prozessing statement: TPH D [var] +Class DEBUG [Typeinference] Erstellte Constraints: int < TPH D +TPH D < TPH E -SourceFile DEBUG [Typeinference] Karthesisches Produkt der Constraints: [[(TPH BZ <. TPH BZ), (TPH CG <. TPH CF), (Matrix <. TPH CH), (TPH CB <. TPH CI), (TPH CD <. FunN), (TPH CF <. TPH CJ), (Fun1< TPH CJ, TPH CD > <. TPH CE), (TPH CE <. TPH CK), (Fun1< TPH CK, TPH CB > <. TPH CC), (TPH CC <. TPH BZ)]] -SourceFile DEBUG [Typeinference] Unifiziertes Ergebnis: [[(TPH CG <. TPH CF), (TPH CB <. TPH CI), (TPH CF <. TPH CJ), (TPH CK = Fun1< TPH CJ, FunN >), (TPH BZ = Fun1< Fun1< TPH CJ, FunN >, TPH CB >), (TPH CH = Matrix), (TPH CD = FunN), (TPH CE = Fun1< TPH CJ, FunN >), (TPH CC = Fun1< Fun1< TPH CJ, FunN >, TPH CB >)], [(TPH CG <. TPH CF), (TPH CB <. TPH CI), (TPH CF <. TPH CJ), (TPH CK = Fun1< TPH CJ, FunN >), (TPH BZ = Fun1< Fun1< TPH CJ, FunN >, TPH CB >), (TPH CH = Vector< Vector< GTV Integer > >), (TPH CD = FunN), (TPH CE = Fun1< TPH CJ, FunN >), (TPH CC = Fun1< Fun1< TPH CJ, FunN >, TPH CB >)], [(TPH CG <. TPH CF), (TPH CB <. TPH CI), (TPH CF <. TPH CJ), (TPH CK = Fun1< TPH CJ, FunN >), (TPH BZ = Fun1< Fun1< TPH CJ, FunN >, TPH CB >), (TPH CH = Vector< ? extends Vector< GTV Integer > >), (TPH CD = FunN), (TPH CE = Fun1< TPH CJ, FunN >), (TPH CC = Fun1< Fun1< TPH CJ, FunN >, TPH CB >)], [(TPH CG <. TPH CF), (TPH CB <. TPH CI), (TPH CF <. TPH CJ), (TPH CK = Fun1< TPH CJ, FunN >), (TPH BZ = Fun1< Fun1< TPH CJ, FunN >, TPH CB >), (TPH CH = Vector< ? extends Vector< ? extends GTV Integer > >), (TPH CD = FunN), (TPH CE = Fun1< TPH CJ, FunN >), (TPH CC = Fun1< Fun1< TPH CJ, FunN >, TPH CB >)], [(TPH CG <. TPH CF), (TPH CB <. TPH CI), (TPH CF <. TPH CJ), (TPH CK = Fun1< TPH CJ, FunN >), (TPH BZ = Fun1< Fun1< TPH CJ, FunN >, TPH CB >), (TPH CH = Vector< ? extends Vector< ? super GTV Integer > >), (TPH CD = FunN), (TPH CE = Fun1< TPH CJ, FunN >), (TPH CC = Fun1< Fun1< TPH CJ, FunN >, TPH CB >)], [(TPH CG <. TPH CF), (TPH CB <. TPH CI), (TPH CF <. TPH CJ), (TPH CK = Fun1< TPH CJ, FunN >), (TPH BZ = Fun1< Fun1< TPH CJ, FunN >, TPH CB >), (TPH CH = Vector< ? super Vector< GTV Integer > >), (TPH CD = FunN), (TPH CE = Fun1< TPH CJ, FunN >), (TPH CC = Fun1< Fun1< TPH CJ, FunN >, TPH CB >)], [(TPH CG <. TPH CF), (TPH CB <. TPH CI), (TPH CF <. TPH CJ), (TPH CK = Fun1< TPH CJ, FunN >), (TPH BZ = Fun1< Fun1< TPH CJ, FunN >, TPH CB >), (TPH CH = Vector< ? super Matrix >), (TPH CD = FunN), (TPH CE = Fun1< TPH CJ, FunN >), (TPH CC = Fun1< Fun1< TPH CJ, FunN >, TPH CB >)]] +SourceFile DEBUG [Typeinference] Karthesisches Produkt der Constraints: [[(int <. TPH D), (TPH D <. TPH E)]] +SourceFile DEBUG [Typeinference] Unifiziertes Ergebnis: [[(TPH E = int), (TPH D = int)]] SourceFile DEBUG [Typeinference] JavaFiles: -SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH CG <. TPH CF), (TPH CB <. TPH CI), (TPH CF <. TPH CJ), (TPH CK = Fun1< TPH CJ, FunN >), (TPH BZ = Fun1< Fun1< TPH CJ, FunN >, TPH CB >), (TPH CH = Matrix), (TPH CD = FunN), (TPH CE = Fun1< TPH CJ, FunN >), (TPH CC = Fun1< Fun1< TPH CJ, FunN >, TPH CB >)] +SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH E = int), (TPH D = int)] -SourceFile DEBUG [Typeinference] class Matrix extends Vector> +SourceFile DEBUG [Typeinference] class ConstructorTest1 extends Object { -Fun1, CB> op = (CB m) -> { -return (FunN f) -> { -return f.apply(this, m);; -}; -}; -Matrix Matrix() +ConstructorTest1 ConstructorTest1() +{ +int var; +var = 1; +} +} + +Class DEBUG [Typeinference] Erstellte Assumptions: this: ConstructorTest2Method Assumptions: +[MethodAssumption: void void { [(var = NEW ConstructorTest1)], MethodAssumption: ConstructorTest2 null { []] +FieldVar Assumptions: +[typinferenz.assumptions.FieldAssumption@27beded] +LocalVar Assumptions: +[] +Parameter Assumptions: +[] + +Block DEBUG [Typeinference] Prozessing statement: (var = NEW ConstructorTest1) +Block DEBUG [Typeinference] Prozessing statement: void(var: TPH B = NEW ConstructorTest1) +Class DEBUG [Typeinference] Erstellte Constraints: TPH B < TPH B +[(ConstructorTest1 <. ConstructorTest1), (ConstructorTest1 <. ConstructorTest1), ] +ConstructorTest1 < TPH B +TPH B < TPH G +void < void + +SourceFile DEBUG [Typeinference] Karthesisches Produkt der Constraints: [[(TPH B <. TPH B), (ConstructorTest1 <. ConstructorTest1), (ConstructorTest1 <. TPH B), (TPH B <. TPH G), (void <. void)], [(TPH B <. TPH B), (ConstructorTest1 <. ConstructorTest1), (ConstructorTest1 <. TPH B), (TPH B <. TPH G), (void <. void)]] +SourceFile DEBUG [Typeinference] Unifiziertes Ergebnis: [[(TPH G = ConstructorTest1), (TPH B = ConstructorTest1)]] +SourceFile DEBUG [Typeinference] +JavaFiles: + +SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH G = ConstructorTest1), (TPH B = ConstructorTest1)] + +SourceFile DEBUG [Typeinference] class ConstructorTest2 extends Object +{ +ConstructorTest1 var; +void method() +{ +var = new ConstructorTest1(); +} +ConstructorTest2 ConstructorTest2() { } } -SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH CG <. TPH CF), (TPH CB <. TPH CI), (TPH CF <. TPH CJ), (TPH CK = Fun1< TPH CJ, FunN >), (TPH BZ = Fun1< Fun1< TPH CJ, FunN >, TPH CB >), (TPH CH = Vector< Vector< GTV Integer > >), (TPH CD = FunN), (TPH CE = Fun1< TPH CJ, FunN >), (TPH CC = Fun1< Fun1< TPH CJ, FunN >, TPH CB >)] +SourceFile DEBUG [Typeinference] Unifiziertes Ergebnis: [[(TPH G = ConstructorTest1), (TPH B = ConstructorTest1)]] +SourceFile DEBUG [Typeinference] +JavaFiles: -SourceFile DEBUG [Typeinference] class Matrix extends Vector> +SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH G = ConstructorTest1), (TPH B = ConstructorTest1)] + +SourceFile DEBUG [Typeinference] class ConstructorTest2 extends Object { -Fun1, CB> op = (CB m) -> { -return (FunN f) -> { -return f.apply(this, m);; -}; -}; -Matrix Matrix() -{ -} -} - -SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH CG <. TPH CF), (TPH CB <. TPH CI), (TPH CF <. TPH CJ), (TPH CK = Fun1< TPH CJ, FunN >), (TPH BZ = Fun1< Fun1< TPH CJ, FunN >, TPH CB >), (TPH CH = Vector< ? extends Vector< GTV Integer > >), (TPH CD = FunN), (TPH CE = Fun1< TPH CJ, FunN >), (TPH CC = Fun1< Fun1< TPH CJ, FunN >, TPH CB >)] - -SourceFile DEBUG [Typeinference] class Matrix extends Vector> -{ -Fun1, CB> op = (CB m) -> { -return (FunN f) -> { -return f.apply(this, m);; -}; -}; -Matrix Matrix() -{ -} -} - -SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH CG <. TPH CF), (TPH CB <. TPH CI), (TPH CF <. TPH CJ), (TPH CK = Fun1< TPH CJ, FunN >), (TPH BZ = Fun1< Fun1< TPH CJ, FunN >, TPH CB >), (TPH CH = Vector< ? extends Vector< ? extends GTV Integer > >), (TPH CD = FunN), (TPH CE = Fun1< TPH CJ, FunN >), (TPH CC = Fun1< Fun1< TPH CJ, FunN >, TPH CB >)] - -SourceFile DEBUG [Typeinference] class Matrix extends Vector> -{ -Fun1, CB> op = (CB m) -> { -return (FunN f) -> { -return f.apply(this, m);; -}; -}; -Matrix Matrix() -{ -} -} - -SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH CG <. TPH CF), (TPH CB <. TPH CI), (TPH CF <. TPH CJ), (TPH CK = Fun1< TPH CJ, FunN >), (TPH BZ = Fun1< Fun1< TPH CJ, FunN >, TPH CB >), (TPH CH = Vector< ? extends Vector< ? super GTV Integer > >), (TPH CD = FunN), (TPH CE = Fun1< TPH CJ, FunN >), (TPH CC = Fun1< Fun1< TPH CJ, FunN >, TPH CB >)] - -SourceFile DEBUG [Typeinference] class Matrix extends Vector> -{ -Fun1, CB> op = (CB m) -> { -return (FunN f) -> { -return f.apply(this, m);; -}; -}; -Matrix Matrix() -{ -} -} - -SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH CG <. TPH CF), (TPH CB <. TPH CI), (TPH CF <. TPH CJ), (TPH CK = Fun1< TPH CJ, FunN >), (TPH BZ = Fun1< Fun1< TPH CJ, FunN >, TPH CB >), (TPH CH = Vector< ? super Vector< GTV Integer > >), (TPH CD = FunN), (TPH CE = Fun1< TPH CJ, FunN >), (TPH CC = Fun1< Fun1< TPH CJ, FunN >, TPH CB >)] - -SourceFile DEBUG [Typeinference] class Matrix extends Vector> -{ -Fun1, CB> op = (CB m) -> { -return (FunN f) -> { -return f.apply(this, m);; -}; -}; -Matrix Matrix() -{ -} -} - -SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH CG <. TPH CF), (TPH CB <. TPH CI), (TPH CF <. TPH CJ), (TPH CK = Fun1< TPH CJ, FunN >), (TPH BZ = Fun1< Fun1< TPH CJ, FunN >, TPH CB >), (TPH CH = Vector< ? super Matrix >), (TPH CD = FunN), (TPH CE = Fun1< TPH CJ, FunN >), (TPH CC = Fun1< Fun1< TPH CJ, FunN >, TPH CB >)] - -SourceFile DEBUG [Typeinference] class Matrix extends Vector> -{ -Fun1, CB> op = (CB m) -> { -return (FunN f) -> { -return f.apply(this, m);; -}; -}; -Matrix Matrix() +ConstructorTest1 var; +void method() +{ +var = new ConstructorTest1(); +} +ConstructorTest2 ConstructorTest2() { } }