From ae872ed906307c122597d3e869c9857feaf98ced Mon Sep 17 00:00:00 2001 From: Bruder John Date: Thu, 4 Jul 2024 08:29:50 +0200 Subject: [PATCH 1/9] removed Begin to Tast test --- src/test/java/semantic/BeginnToTAST.java | 45 ------------------ .../AllFeaturesClassExample.class | Bin 0 -> 1093 bytes .../BooleanOperations.class | Bin 0 -> 686 bytes .../CharManipulation.class | Bin 0 -> 638 bytes .../ConditionalStatements.class | Bin 0 -> 780 bytes .../EmptyClassExample.class | Bin 0 -> 208 bytes .../combinedFeatureTests/LoopExamples.class | Bin 0 -> 1004 bytes .../MethodOverloading.class | Bin 0 -> 1083 bytes .../input/singleFeatureTests/Char.class | Bin 0 -> 302 bytes .../input/singleFeatureTests/Comments.class | Bin 0 -> 206 bytes .../ConstructorMethodCall.class | Bin 0 -> 327 bytes .../ConstructorMethodCallParameters.class | Bin 0 -> 356 bytes .../ConstructorParameter.class | Bin 0 -> 226 bytes .../ConstructorThisDot.class | Bin 0 -> 256 bytes .../input/singleFeatureTests/DoWhile.class | Bin 0 -> 250 bytes .../input/singleFeatureTests/EmptyClass.class | Bin 0 -> 194 bytes .../EmptyClassWithConstructor.class | Bin 0 -> 228 bytes .../input/singleFeatureTests/Field.class | Bin 0 -> 200 bytes .../FieldWithAccessModifier.class | Bin 0 -> 236 bytes .../input/singleFeatureTests/For.class | Bin 0 -> 240 bytes .../input/singleFeatureTests/If.class | Bin 0 -> 239 bytes .../input/singleFeatureTests/IfElse.class | Bin 0 -> 258 bytes .../singleFeatureTests/IfElseIfElse.class | Bin 0 -> 290 bytes .../input/singleFeatureTests/Increment.class | Bin 0 -> 350 bytes .../input/singleFeatureTests/MainMethod.class | Bin 0 -> 265 bytes .../singleFeatureTests/MultipleClasses.class | Bin 0 -> 204 bytes .../input/singleFeatureTests/Null.class | Bin 0 -> 226 bytes .../singleFeatureTests/SelfReference.class | Bin 0 -> 466 bytes .../input/singleFeatureTests/TestClass2.class | Bin 0 -> 199 bytes .../input/singleFeatureTests/ThisDot.class | Bin 0 -> 227 bytes .../VariableCalculation.class | Bin 0 -> 723 bytes .../singleFeatureTests/VariableCompare.class | Bin 0 -> 620 bytes .../input/singleFeatureTests/VoidMethod.class | Bin 0 -> 240 bytes .../input/singleFeatureTests/While.class | Bin 0 -> 249 bytes 34 files changed, 45 deletions(-) delete mode 100644 src/test/java/semantic/BeginnToTAST.java create mode 100644 src/test/resources/input/combinedFeatureTests/AllFeaturesClassExample.class create mode 100644 src/test/resources/input/combinedFeatureTests/BooleanOperations.class create mode 100644 src/test/resources/input/combinedFeatureTests/CharManipulation.class create mode 100644 src/test/resources/input/combinedFeatureTests/ConditionalStatements.class create mode 100644 src/test/resources/input/combinedFeatureTests/EmptyClassExample.class create mode 100644 src/test/resources/input/combinedFeatureTests/LoopExamples.class create mode 100644 src/test/resources/input/combinedFeatureTests/MethodOverloading.class create mode 100644 src/test/resources/input/singleFeatureTests/Char.class create mode 100644 src/test/resources/input/singleFeatureTests/Comments.class create mode 100644 src/test/resources/input/singleFeatureTests/ConstructorMethodCall.class create mode 100644 src/test/resources/input/singleFeatureTests/ConstructorMethodCallParameters.class create mode 100644 src/test/resources/input/singleFeatureTests/ConstructorParameter.class create mode 100644 src/test/resources/input/singleFeatureTests/ConstructorThisDot.class create mode 100644 src/test/resources/input/singleFeatureTests/DoWhile.class create mode 100644 src/test/resources/input/singleFeatureTests/EmptyClass.class create mode 100644 src/test/resources/input/singleFeatureTests/EmptyClassWithConstructor.class create mode 100644 src/test/resources/input/singleFeatureTests/Field.class create mode 100644 src/test/resources/input/singleFeatureTests/FieldWithAccessModifier.class create mode 100644 src/test/resources/input/singleFeatureTests/For.class create mode 100644 src/test/resources/input/singleFeatureTests/If.class create mode 100644 src/test/resources/input/singleFeatureTests/IfElse.class create mode 100644 src/test/resources/input/singleFeatureTests/IfElseIfElse.class create mode 100644 src/test/resources/input/singleFeatureTests/Increment.class create mode 100644 src/test/resources/input/singleFeatureTests/MainMethod.class create mode 100644 src/test/resources/input/singleFeatureTests/MultipleClasses.class create mode 100644 src/test/resources/input/singleFeatureTests/Null.class create mode 100644 src/test/resources/input/singleFeatureTests/SelfReference.class create mode 100644 src/test/resources/input/singleFeatureTests/TestClass2.class create mode 100644 src/test/resources/input/singleFeatureTests/ThisDot.class create mode 100644 src/test/resources/input/singleFeatureTests/VariableCalculation.class create mode 100644 src/test/resources/input/singleFeatureTests/VariableCompare.class create mode 100644 src/test/resources/input/singleFeatureTests/VoidMethod.class create mode 100644 src/test/resources/input/singleFeatureTests/While.class diff --git a/src/test/java/semantic/BeginnToTAST.java b/src/test/java/semantic/BeginnToTAST.java deleted file mode 100644 index 8b59666..0000000 --- a/src/test/java/semantic/BeginnToTAST.java +++ /dev/null @@ -1,45 +0,0 @@ -package semantic; - -import ast.ProgramNode; -import org.antlr.v4.runtime.CharStream; -import org.antlr.v4.runtime.CharStreams; -import org.antlr.v4.runtime.CommonTokenStream; -import org.antlr.v4.runtime.tree.ParseTree; -import org.junit.jupiter.api.Test; -import parser.astBuilder.ASTBuilder; -import parser.generated.SimpleJavaLexer; -import parser.generated.SimpleJavaParser; - -import java.io.IOException; -import java.nio.file.Paths; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class BeginnToTAST { - - @Test - public void FieldTests() { - SemanticAnalyzer.clearAnalyzer(); - - CharStream codeCharStream = null; - try { - codeCharStream = CharStreams.fromPath(Paths.get("src/test/resources/input/johnsTests/FieldTests.java")); - } catch (IOException e) { - throw new RuntimeException(e); - } - SimpleJavaLexer lexer = new SimpleJavaLexer(codeCharStream); - CommonTokenStream tokenStream = new CommonTokenStream(lexer); - - SimpleJavaParser parser = new SimpleJavaParser(tokenStream); - ParseTree parseTree = parser.program(); // parse the input - - /* ------------------------- AST builder -> AST ------------------------- */ - ASTBuilder astBuilder = new ASTBuilder(); - ProgramNode abstractSyntaxTree = (ProgramNode) astBuilder.visit(parseTree); - - var result = SemanticAnalyzer.generateTast(abstractSyntaxTree); - - assertTrue(SemanticAnalyzer.errors.isEmpty()); - } - -} diff --git a/src/test/resources/input/combinedFeatureTests/AllFeaturesClassExample.class b/src/test/resources/input/combinedFeatureTests/AllFeaturesClassExample.class new file mode 100644 index 0000000000000000000000000000000000000000..b59adc2b7e01f158236a1ad77e723a9172711fe4 GIT binary patch literal 1093 zcmZ`%O-~b16g{sq(64DJUj=Cq0fn|8uyA3t8nl9Gg0jGnfE!=iNg14Wn(372o zmTd|MNh>RO(!dZ>j4HH!l^HQGiZMo2S}Dd%TFFmPD_7nx<#$!;nt>@*(Qwsidah&d zcy6ca3#qSJ1JnLj+o@YsX>YeoS9+GyYzycmr^X6~wydW4ywj+d?h9E_H6?aDS$+LX zwt`rbwVJ>{u3XNS1tRTE#dD=m^MJ|mopokCN8J|I=tqt|PsKD+#>6}1Q1$O(*NA&x`h?DCgV3Hd5>WCv@FVw`81 zOPXYU3Jb^}Pru5FZxCTXkB_Cp(IIWF&EHgNvm4ZGuc-k>AOQwqQEk3z8|vIi(Dh}W2`d9G7V~vthF-^jG`= zUwl!t1qDCAk5bR1!6M4A_s+d@?>XmQ_Q%h!-vR8R6Tm}3!VghINuYMDPE|KiHty~Z zj`c7XC_OUPrS&$@Pd7>6DDk-b{r_yDu|i^M0ObHQI4-DuN z=bfvf-Cz{))x8JN1w^#^1@a>!flb;46li^(A}S~`%bm>o*61B(G5QSo;ZKVz0*i$k zoYql1C4tMokpHO>nj@CJD(%rd=uI6cR4$2_T5*j=!D3<6--2f20OR zpzu-0+I$koHJXPWitt?c0p<~q-Z_@(fsFM@7D=O%nDj^)qf!CU@kuUO;Y9(b(XrJp zu;ii=U>Vha%zEdiMvdu_WVEbyAKTDL`&+7G(=(}(<6SHFGQbL633x+gx>F)8Z+-)8T_`M`c2kNu7Xt;kUWf-h%BbokHN5H}fx%-Xyk-a>?H zH*hZ*32YHd$Ppbrd3Y#rl|z`;t@CR&^Winzi>DGx0?EQ|lV~kArxt~0^7ak@3luN0 zqK@q;|A4kOv;7OjALYGUEOf6>ZcR{|V6|1=pI~Da&$_Kq2s~*YOFZWaR*7{~Df*u4 HbJ+OR=|(Sh3MEvQIh;9X&i6ZWW`F(p{u96})RKrGYQu67LtG$pPh>=!bG3bvR~?o($S@Bp^-` zNMqSX#>EP0?)XZ~=$w+6mq zn``B(MSTh+o55t%k*}30E-jq=kr@GY*h_@ZE4cVfv{Cx(mG(JzRc1{-S$%-0ZhV9N znLB|!+BDAs7QYx0h%?G7&Fi|XGMb0gudqKN{RK3hnG-MBjm1>u2b@di0Z$sn$^52wX1pk! m^MiXlt#KW4{kzCEIY5qbtF(D+q5u!;Bo+xM5m045f`h-jQ=H!b literal 0 HcmV?d00001 diff --git a/src/test/resources/input/combinedFeatureTests/EmptyClassExample.class b/src/test/resources/input/combinedFeatureTests/EmptyClassExample.class new file mode 100644 index 0000000000000000000000000000000000000000..a6a129d83eb7b7fa699093038b18c5956b9ac7cc GIT binary patch literal 208 zcmX^0Z`VEs1_mbvUM>bE24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00Sb_Nbc20_={f|5$-oW$Z{*NVj4f}B)F1{UZ16d=X#lbM(5SDKrYS`?C) z1d`wi&Mz%WPIb!!al|lm>VYg|P-I{Sx&s6lfe`2tAjt{j$%6R|46It)85lQ$rMZA4 ONE)J)8%Q%T@BjcvAt~Pg literal 0 HcmV?d00001 diff --git a/src/test/resources/input/combinedFeatureTests/LoopExamples.class b/src/test/resources/input/combinedFeatureTests/LoopExamples.class new file mode 100644 index 0000000000000000000000000000000000000000..2a398c6e58dba159bd89b9357647b2657cb08f32 GIT binary patch literal 1004 zcmaJ=L2nX46#fP%3+onI5GtY-D^;jkwBDrgP$IEOt0pwvpX~rul@+n zUOekTlOFs5{uY0MY1FqsA_U?dW@h(&?|a|-=IxK)7vBNwVaG%SQ3EjxONcY9obhvB zbGSUMy=tF{j%JAO+S1m~7^0QxaS{n64VV_Lz?y-#hJh9?q11qqat9+KTh(6sw$v@{ z3+~o4R5N8EjTMG9m-j_O$qv^iw(ij>&|K<(ax44Qar#IH<=XPJZX$!MfvXmB$TMUY z@G}@*Sj~|k$vj2%I0J^1fdYedpp^IgEq6UfP|a9Fbp=EEz?S0Wz-LiRtaF^t5jMg$`f;bo+ JqK3yP`~|8~{Zs$| literal 0 HcmV?d00001 diff --git a/src/test/resources/input/combinedFeatureTests/MethodOverloading.class b/src/test/resources/input/combinedFeatureTests/MethodOverloading.class new file mode 100644 index 0000000000000000000000000000000000000000..2357744da74e54140524878508a87dd6fe8f3e92 GIT binary patch literal 1083 zcmaJ=T~8B16g@+?-L@>>0wM)g1#M}i0)E%{Koeq89(PmmwPA0 zgZi0hD2Bvq$8*#hhFCUtY$C}p^G>K!**rKGzAJgt@lMh(5ldklmWc@qlbE_eRqF*x zw247>iEzFeHgRO}(04plQ@-HslBSrkFpD|D@n(}Do~=}Jm08j`Z(#w842x~v5@qQ% zxccCzQ(6UzdnzE#Y$X@bhT4gfR1xPA?wDA%kiiPW+=#vmW=E@VJxwx9kvrDH*0eC2 zydX)TCIT}UW!V%AQ&q!@A;qEmu79#CFa+Qz< zArgdK8N!-KVI3QN>>-KK!U{iOe!N7g`UB~FJaK{PE8GGua9bA)U0J=NF?8ix=WN(# q97$O8I3|#%#~Q-};v2(5WGPS5>JjzIg)xs^s-@}s37+8vmi_{y1Na&M literal 0 HcmV?d00001 diff --git a/src/test/resources/input/singleFeatureTests/Char.class b/src/test/resources/input/singleFeatureTests/Char.class new file mode 100644 index 0000000000000000000000000000000000000000..8e9c65e698b9692fda17bc8083d5cfb7c515b6c3 GIT binary patch literal 302 zcmXX=yHdhH6g@WyiCIHHd=%1HLJIf+$HL4|p%yyy8`zOBn9Rh*ucEOKXDs{xKg#he zSln|T=P~!^_v;(LEiM#1_z{8xErf#ZO26sxT365Ghhk;sRuEp7RcUVo{$My$I6@pj zB{)VR2=b+F1j?FMduQyjUhp=^hj~n0nxKQOKr|~q5Hshg7e>&TmX*2RycDK+(#4t= z^;mD3xtWx1iCyx@eS<4zdHhyb3?zD-TR0*1xQ*cN`84~4WLbZQ=mYKdz2lUak_Ytx dLbMTa=I{UBOLmv-^|wTU(}(PUBAz)0=YLd8Dh&Vt literal 0 HcmV?d00001 diff --git a/src/test/resources/input/singleFeatureTests/Comments.class b/src/test/resources/input/singleFeatureTests/Comments.class new file mode 100644 index 0000000000000000000000000000000000000000..8d74444c8006241940352d7c5197335aab576a17 GIT binary patch literal 206 zcmXv|I|{;35S-25m>4f0SgM7&fLIt11kpmVe~AxyAs>i|_p%Z!Jb;H1HxY}S*_mOP zeSe-W04oG8H0U-A4<;)+`#6G!Jh_MH^+tB{OPM_6?nV8Ml R19b0VkFkw^=rd~=d;y@sBZvS1 literal 0 HcmV?d00001 diff --git a/src/test/resources/input/singleFeatureTests/ConstructorMethodCall.class b/src/test/resources/input/singleFeatureTests/ConstructorMethodCall.class new file mode 100644 index 0000000000000000000000000000000000000000..009c42373cb5456168563ddc4036ca8f43968486 GIT binary patch literal 327 zcmZusyH3ME5S+E0m>ib}k2LA%z!KyKPzo#|MdDF_=+Djx92r}3&U_UO1t3xI0elo< z&QMb9+|J(4+|Aeb$0vX@OcerzF(Qo~`hv;YJehfEs{8qMwzjzw^iPYba0@|rcyy<* zg+UCZu?;PlrggP(O`E&AxwP(~UZtii1$ m=>)sP5kg`Q5d|7CdxrXx&Ukv;AbKVW{JysZ6mierVE+exEH=pi literal 0 HcmV?d00001 diff --git a/src/test/resources/input/singleFeatureTests/ConstructorMethodCallParameters.class b/src/test/resources/input/singleFeatureTests/ConstructorMethodCallParameters.class new file mode 100644 index 0000000000000000000000000000000000000000..6c01775e5811edc75a952be0e4de8cb02bcaae7f GIT binary patch literal 356 zcmah^yH3ME5S+Cgn;ec4o&_nOph#RKKY%E(gk*`A1WJE)PTAu4YK(4kQ|nu0Ug~)w%kn{Lxl~5!h9Hb;%vK_Jqja2h`9u_=j{$)s zN4gbeOi4Xgg#JxYsk?TWDg7j~k~`wDZgsA%3tOE3V>+=v;EZh?{*gG?i_zh{gFVK5 zt|o9ddK9lfaXkD)@PXd@X5)Y{VjVp1!AB1P=lt>C?g_KK?F`=-33lFR1_a}wRdDnR D!^=R8 literal 0 HcmV?d00001 diff --git a/src/test/resources/input/singleFeatureTests/ConstructorParameter.class b/src/test/resources/input/singleFeatureTests/ConstructorParameter.class new file mode 100644 index 0000000000000000000000000000000000000000..eabb195ade30d8262acbc7736868b9210682e4a3 GIT binary patch literal 226 zcmZusI|{-;5Pf5^Mq~UGHg?(>3%!6?CqFP1Pc$~p~OjQ=P~o< z&A@y<-`5+!94#LeI3C;p0#!oiBJXmN$n-qfMi&)ZLUpQBZD#~$7#=;;2;D`N-mJ-E zo0*+7@~W&d1TkE#!Xv?5WG6*vuXU<6`887JAftpU{yxi1td_bEy?;Z-#d`GN@l}Np eL!i#lXEk7Un8oM`dX()3$KnOBy9`25=FJ~72QDiB literal 0 HcmV?d00001 diff --git a/src/test/resources/input/singleFeatureTests/ConstructorThisDot.class b/src/test/resources/input/singleFeatureTests/ConstructorThisDot.class new file mode 100644 index 0000000000000000000000000000000000000000..1a1c4c38599720fe9b6c9abdea71dad319ee7e12 GIT binary patch literal 256 zcmZWj%MQU%5IxgYt5wg9g^eX$@B?CjNSX)>Vt-pVT%k9q)_+-u#KH&oC^5CQm@{+E zyw3acd;yrC<-vgI!17UoO=uj&RSZue*$-FIQN|g;9;rlSV}jZ1Z(Wq(I`Di{;1gO? zom{dsk29Ta4(c+~yg-5@Bv`$$zvVR5J4vW7R3ex8Ig;r{L?>3fwa(L6&Q(F$|Ca`Z y7j*ff!Cr}xfBq_BvsG4V%mUVnz85?|LFW$V_M53Q)?hN0V8Mn9hc_C`4K%-pd@f=D literal 0 HcmV?d00001 diff --git a/src/test/resources/input/singleFeatureTests/DoWhile.class b/src/test/resources/input/singleFeatureTests/DoWhile.class new file mode 100644 index 0000000000000000000000000000000000000000..d7f8c194c4d92b228c0fd34d35d1e3abd3d67c37 GIT binary patch literal 250 zcmXYrJ#NB45QX2^#tV)OuF}v@28wV2l!8Pw{1uL%UOOu=0UIHc6L1lZkP0b94v-^J z1fCH)(i^>R=k3nl|IaUgKI$GU*b0u13S2?B(qFo}*4d&vjaMcq1a2?Q(&9y6KecBH zRe^fT=gV|$1kP*z!PXe1nVIZ2vDv-rxV#9WLMNYNy}f%c%J;j(3~nj^o_{VsLko&K zlt)bE24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00Sb_Nbc1}@j!f|5$-oW$Z{Mg|t={FGEi27aH+yi~u^+@#c^ki?`Mpa@rR zerZv1s#_+A!;jFS2eN`efq@-pGYBvOG0<)x%?V`50%@>_)^-NQjbLdmAPJHNDP?5f J2GUFnJOHXMBsTy6 literal 0 HcmV?d00001 diff --git a/src/test/resources/input/singleFeatureTests/EmptyClassWithConstructor.class b/src/test/resources/input/singleFeatureTests/EmptyClassWithConstructor.class new file mode 100644 index 0000000000000000000000000000000000000000..664bf33beed4dcaa368c76f472c1260ce5efbe9a GIT binary patch literal 228 zcmZ`!!4APt5S-Ogig0z2^o9dJAPyQ%!hvvptruQXt-QWUe3p~M!3X##vF+VXcCxdR zY-T^-*BihbZ5I_-4(t}Hs1dr6xQR(DlG9`pL^3pl+EgXV%m~(CxOY$|^cI(^x%;um zvV$^bKTR^D^U$Q4VEgG&5;`lD$aQ`Rq~3`j=8d~ea~;a1Dn$S9g>ex89vse96frm% bbAy#vYM?rLf*z&qG8a#P+h!1&<=pxK$pSF# literal 0 HcmV?d00001 diff --git a/src/test/resources/input/singleFeatureTests/Field.class b/src/test/resources/input/singleFeatureTests/Field.class new file mode 100644 index 0000000000000000000000000000000000000000..e06f2cf103c1789c64fb00719460e1234458f36d GIT binary patch literal 200 zcmXX=I|{;35S-2LX^h4T2$pJLE+7^P0YS7->|c_Hybu!ziTAP+EIfdR688m*+1Z(4 z*!_H8ZvY#FJ}lS*P5>7kVVujmj0#y^qhpe*v>|vaUFv2{uxIm&K#$O(B2YNpJh_8JVB2x O4tSc_ln6s+3!@+I=peTM literal 0 HcmV?d00001 diff --git a/src/test/resources/input/singleFeatureTests/FieldWithAccessModifier.class b/src/test/resources/input/singleFeatureTests/FieldWithAccessModifier.class new file mode 100644 index 0000000000000000000000000000000000000000..a322f456660163581e52d48955bdb5799b09bb7f GIT binary patch literal 236 zcmZ{e%?`m(5QWd6N|oB#u&~2IUqB>Cnn?UC2nNDeP$bj?aS?VXqP@Lz1L>uN;y^_z9TM`L?nXz6&~TIt{jEw5 zBhQnk(>(UoPRWEof@?}BOk!UWteJ}B;(T;vvKDU07h@Hl6HhuS6U{$4{R{$a=*$Li gBFZp+8&k5buxfoAKP5}ZIDWP2mSReS0N%1a2@jvx9-m!Q`h3jvdpK@<~= zeza7C(#Q|hWWRM)JeTfPH`$D1B-Kh3XtOW$;?ajE6q(xEec6Y$^nY-2A3ozXZt1= zK>1w3`K3k4scxAdNp6UCJ&;uliVW;P7k~gG5CYu*Bsqb+P@pJCTvTg210#oxG{*u4 z&KAc1%Nf{O7#TMLC72kvfTR>q1BlJSzzk%uFmMBn5Cj@20yKmhD8t9V^dBg|#LmFZ N2vWz$zyns#3jlwFD`Wrw literal 0 HcmV?d00001 diff --git a/src/test/resources/input/singleFeatureTests/IfElseIfElse.class b/src/test/resources/input/singleFeatureTests/IfElseIfElse.class new file mode 100644 index 0000000000000000000000000000000000000000..680b310cab6113151f97dcd998d86843760f9889 GIT binary patch literal 290 zcmYjL%TB^j6r9u6-cpLtjT=l*SL#B3fVhA_V&Y?gVSih%=3*@d3tzy8xMS_g#04MV zM+wvF!h4g+oH^&robR8n4S+uOLpX31ya;>n1+A%G>TagEfYI ex0vjJ35WFTP^ojG33tneqo4!`9R^0#Vq*u~{xWO; literal 0 HcmV?d00001 diff --git a/src/test/resources/input/singleFeatureTests/Increment.class b/src/test/resources/input/singleFeatureTests/Increment.class new file mode 100644 index 0000000000000000000000000000000000000000..75faed58501bcdc4dc2deeb3a0cbc606d5fd7aaa GIT binary patch literal 350 zcmYjL%Syvg6r6LLHo0lq#s{LP3wLc7_6M{J1tH)ID%~gXBB^aEHT4VnCoWvO5W$5X z;QzQ0QRmhoa^al0=ggd$x38C100&t0p-^(+1Sq2-2nX?9+!@CCRp%@jn6wa7_Od)H zx`I-()z|Q#UHAd22n0IH(}@|GoIIy6w`>v-9*!@KpmCh#=5#tr%;X|YhMef^AHNy3 z`hr@oh|}wn_+~-zd*kUOHAk7{*Z=PC+F;nBy<%|M*Z@R|h{;)N{B6%SK)L-4d7KmL ztakk?Y9L%t&na~{-Dq#lM4sR}`&*%ZkE++5DS7yQw{it5U!#LP;_-#hSY}_R{}QJf O>Jz?v&|bK(l9eBg(mC${ literal 0 HcmV?d00001 diff --git a/src/test/resources/input/singleFeatureTests/MainMethod.class b/src/test/resources/input/singleFeatureTests/MainMethod.class new file mode 100644 index 0000000000000000000000000000000000000000..0470c083d8f0041792c4ae9f2158848bbefb809e GIT binary patch literal 265 zcmZ9Gy$ZrW5QJw<+UZ!@S;)Cx9vZ8cMJn*dEHL5L!oZ72!$feYlQ~GARg^vC^uT5UijdIj9n9OQG~q z7Kbb)*t0B^1b?BlTwTtw%(o&wv16Z^BD90u;upFpa;5j9e#9x8?2;#Pt_WjK!DZFuOU4=8K{pm0#M``$c2S4-y+G&du=|hM3^e#zLh}QtM=oyw literal 0 HcmV?d00001 diff --git a/src/test/resources/input/singleFeatureTests/MultipleClasses.class b/src/test/resources/input/singleFeatureTests/MultipleClasses.class new file mode 100644 index 0000000000000000000000000000000000000000..4585bf0309a0781a1a7b4e841df2df39cb83717c GIT binary patch literal 204 zcmX^0Z`VEs1_mbvUM>bE24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00Sb_Nbc27cetoRZ9foK)wW#Ny)AVnzlQ=lqmZpoC9mUaDVdZc=JdNMceB zP=qTuzqBYh)h!dm5kb?Z2eOPofq@<91`uEbVxTL4G$)WH3#7p!TH6^IH-e?PfFwv7 Oq?D0?8%Q%T@BjcwkSJ>a literal 0 HcmV?d00001 diff --git a/src/test/resources/input/singleFeatureTests/Null.class b/src/test/resources/input/singleFeatureTests/Null.class new file mode 100644 index 0000000000000000000000000000000000000000..47a87ef6879c6b87b3646e09ec1003666d088f1d GIT binary patch literal 226 zcmW-bJr06U5QJy>6-2-rSSp1aKx3ha6~RJd|G*amK}ZOAFAHO0;Q>69aUaEQc4oiK z?)Ufp0N7&cLW6F@@L<9sgr&HPxDxd>K4hiLJA$Z02a^!eiKUtPI!V5EIj z5lAqWsCmWSuDM7;kQB8{`&%a4lgKJ|++)+Xx!e~@IEr4XYnXAS#@`SZrw$XTci5S* gig>GbZuA00^o0Ew7@xZjox2HxX$LlQ0c#E6A4iWPasU7T literal 0 HcmV?d00001 diff --git a/src/test/resources/input/singleFeatureTests/SelfReference.class b/src/test/resources/input/singleFeatureTests/SelfReference.class new file mode 100644 index 0000000000000000000000000000000000000000..413157a7ba2c818270f0daae9225110cbac90597 GIT binary patch literal 466 zcmZ8e%Syvg5Ir|ZlQvD8Sl|4(j5!8p!(T*LL_l+H)@A>~&=n3SvTDcId?lt*+DOR7~8-1F#J#a!hK^x9PC-q6^Ok;~ZN5c7Gp2DiM;Cu_ iTily;=e?qOGeN`Od`5GO)*nm03~0(uS#e1;vHS@cn@I5h literal 0 HcmV?d00001 diff --git a/src/test/resources/input/singleFeatureTests/TestClass2.class b/src/test/resources/input/singleFeatureTests/TestClass2.class new file mode 100644 index 0000000000000000000000000000000000000000..85b51363ba1e568002e8b72e1b88048e396b7e0f GIT binary patch literal 199 zcmW+wy9&ZU5S%kH(HPOfROjL$MX#H-|_b_Jm^)Tu5;1hd!QI%vWXa6Po(5ya-G zuhWcGBst~;Ym)61Az0{CEz3)y@{LT++;P`gneWt0SH!FL2Gu!q+0@{7*rBqmEB=Rh in_0wD;_OCGP-HzI?thKX=)+{RVX@kQU|qo6K==cXSR>{D literal 0 HcmV?d00001 diff --git a/src/test/resources/input/singleFeatureTests/VariableCalculation.class b/src/test/resources/input/singleFeatureTests/VariableCalculation.class new file mode 100644 index 0000000000000000000000000000000000000000..131a2e6b75de3abf21e6521ad4ab0cea94218e30 GIT binary patch literal 723 zcmZ{g%TB^j5QhH)g>qFCFC^52CA!cTFvftFka$ZVEL=I16Fqt;T3h1d7-QnbjVluu zK7bEpoI_9%OOtk{GvEK8IrH)P_70$iQU)=^ZCE)ZkQ69f(ttKJdFLC)olEHk0?AF~ zsbEVWUR`b5NC_0%|FJ=nre=?{mj1W+R3P6B$h|tG>ydk!_I*jg zkV(<*O-S0Dm1*`v-<5mHOi+p#c-`C-71+E0^Q8IZ6@X9WY=xsRm9^Lu&pOpabq7FTSEy&t|SmkZ<~!QL}?$VXq~^>#VGCl6m4Z( KE3h;iYxxUZeqFBs literal 0 HcmV?d00001 diff --git a/src/test/resources/input/singleFeatureTests/VariableCompare.class b/src/test/resources/input/singleFeatureTests/VariableCompare.class new file mode 100644 index 0000000000000000000000000000000000000000..bf2b598420363d648239a9e90f5d6f4454e81cd4 GIT binary patch literal 620 zcma*j!A^rf5C-6X3zkYzXp4z4ns`(X_63ZIHt9*_VAF%QrL0Or!K~1y^5V(FgAd?C z8E1&m(!EFmv&?=wv%8;P?;ijzvE!lz%Yp4-18sp|E|+qc$^2m$#d9?)1=?q6o|fkV z*3t3QK}W!!N}b9$Q=?+>B()N-M@2%xze;m;Q!QepCp<6Umby~cs(dVxy1<=4_g-et zzquZRi#(aExc*OWyb1^PGLnsKz%1_@_uHK4PZ+@F0J?PN2p}{W^?8zJ c#y8NF0UzS7WsQN>*V_9qe>Q`SE{g`*Z_&Oc*8l(j literal 0 HcmV?d00001 diff --git a/src/test/resources/input/singleFeatureTests/While.class b/src/test/resources/input/singleFeatureTests/While.class new file mode 100644 index 0000000000000000000000000000000000000000..3fbdb4f503cb162e7e0a86cadb65fd33720b2cb8 GIT binary patch literal 249 zcmX^0Z`VEs1_mbvJ}w3(24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00Sb_Nbc2G;P5%$!t41{UZ16d=X#lbM(5SDKrYS`?C)1d`wlE=f$z_Dw8+ z^0|WZON)|I-N3rIz`FH77BMI=umkM}0Y)GMx&TOW0(pKw8YC{HwVi=cfXhaD9s_3! z$1_ovZ79eB?>f{EJf Date: Thu, 4 Jul 2024 09:09:55 +0200 Subject: [PATCH 2/9] added type to expression --- .../binaryexpressions/CalculationNode.java | 1 - src/main/java/semantic/SemanticAnalyzer.java | 51 +++++++++++++---- src/test/java/semantic/EndToTypedAstTest.java | 57 +++++++++++++++++++ src/test/java/semantic/SemanticHelper.java | 3 + .../IfExpressionInt.java | 1 - .../SelectRightMethodCauseParameter.java | 22 +++++++ .../SelectWrongMethodCauseParameter.java | 0 .../VariableCalculation.java | 34 +++++++++++ .../VariableCompare.java | 30 ++++++++++ 9 files changed, 186 insertions(+), 13 deletions(-) rename src/test/resources/input/{typedAstExceptionsTests => singleFeatureSemanticTests}/IfExpressionInt.java (73%) create mode 100644 src/test/resources/input/singleFeatureSemanticTests/SelectRightMethodCauseParameter.java rename src/test/resources/input/{typedAstExceptionsTests => singleFeatureSemanticTests}/SelectWrongMethodCauseParameter.java (100%) create mode 100644 src/test/resources/input/singleFeatureSemanticTests/VariableCalculation.java create mode 100644 src/test/resources/input/singleFeatureSemanticTests/VariableCompare.java diff --git a/src/main/java/ast/expressions/binaryexpressions/CalculationNode.java b/src/main/java/ast/expressions/binaryexpressions/CalculationNode.java index 9a2cc13..780fbab 100644 --- a/src/main/java/ast/expressions/binaryexpressions/CalculationNode.java +++ b/src/main/java/ast/expressions/binaryexpressions/CalculationNode.java @@ -9,7 +9,6 @@ public class CalculationNode extends BinaryNode { public CalculationNode calculationExpression; public EnumLineOperator operator; public DotNode dotExpression; - private ITypeNode typeNode; public CalculationNode(CalculationNode calculationExpression, String operator, DotNode dotExpression) { this.calculationExpression = calculationExpression; diff --git a/src/main/java/semantic/SemanticAnalyzer.java b/src/main/java/semantic/SemanticAnalyzer.java index bfc51cf..3b162c6 100644 --- a/src/main/java/semantic/SemanticAnalyzer.java +++ b/src/main/java/semantic/SemanticAnalyzer.java @@ -454,6 +454,7 @@ public class SemanticAnalyzer implements SemanticVisitor { case PLUS, MINUS: if (calcRes.getType() instanceof BaseType calcType && dotRes.getType() instanceof BaseType dotType && calcType.getTypeEnum().equals(TypeEnum.INT) && dotType.getTypeEnum().equals(TypeEnum.INT)) { + calcNode.setType(new BaseType(TypeEnum.INT)); return new TypeCheckResult(true, new BaseType(TypeEnum.INT)); } break; @@ -461,10 +462,12 @@ public class SemanticAnalyzer implements SemanticVisitor { } } else { + calcNode.setType(calcNode.getType()); return new TypeCheckResult(calcRes.isValid(), calcRes.getType()); } } else if (calcNode.dotExpression != null) { var dotRes = calcNode.dotExpression.accept(this); + calcNode.setType(dotRes.getType()); return new TypeCheckResult(dotRes.isValid(), dotRes.getType()); } return new TypeCheckResult(false, null); @@ -473,7 +476,9 @@ public class SemanticAnalyzer implements SemanticVisitor { @Override public TypeCheckResult analyze(DotNode toCheck) { if (toCheck.dotSubstractionExpression != null) { - return toCheck.dotSubstractionExpression.accept(this); + var result = toCheck.dotSubstractionExpression.accept(this); + toCheck.setType(result.getType()); + return result; } return new TypeCheckResult(false, null); } @@ -481,19 +486,35 @@ public class SemanticAnalyzer implements SemanticVisitor { @Override public TypeCheckResult analyze(DotSubstractionNode toCheck) { if (toCheck.value != null) { - return toCheck.value.accept(this); + var result = toCheck.value.accept(this); + toCheck.setType(result.getType()); + return result; } else if (toCheck.memberAccess != null) { - return toCheck.memberAccess.accept(this); + var result = toCheck.memberAccess.accept(this); + toCheck.setType(result.getType()); + return result; } else if (toCheck.methodCall != null) { - return toCheck.methodCall.accept(this); + var result = toCheck.methodCall.accept(this); + toCheck.setType(result.getType()); + return result; } else if (toCheck.identifier != null) { if (currentScope.contains(toCheck.identifier)) { - return new TypeCheckResult(true, currentScope.getLocalVar(toCheck.identifier)); + var type = currentScope.getLocalVar(toCheck.identifier); + toCheck.setType(type); + return new TypeCheckResult(true, type); } else if (currentFields.get(toCheck.identifier) != null) { - return new TypeCheckResult(true, currentFields.get(toCheck.identifier)); + var type = currentFields.get(toCheck.identifier); + toCheck.setType(type); + MemberAccessNode memberAccessNode = new MemberAccessNode(false); + memberAccessNode.identifiers.add(currentClass.identifier); + memberAccessNode.identifiers.add(toCheck.identifier); + toCheck.memberAccess = memberAccessNode; + return new TypeCheckResult(true, type); } } else if (toCheck.calculationExpression != null) { - return toCheck.calculationExpression.accept(this); + var result = toCheck.calculationExpression.accept(this); + toCheck.setType(result.getType()); + return result; } return null; } @@ -513,8 +534,8 @@ public class SemanticAnalyzer implements SemanticVisitor { } break; case OR, AND: - if (expResult.getType() instanceof BaseType expResultType && expResultType.getTypeEnum().equals(TypeEnum.INT) && - unaryResult.getType() instanceof BaseType unaryResultType && unaryResultType.getTypeEnum().equals(TypeEnum.INT)) { + if (expResult.getType() instanceof BaseType expResultType && expResultType.getTypeEnum().equals(TypeEnum.BOOL) && + unaryResult.getType() instanceof BaseType unaryResultType && unaryResultType.getTypeEnum().equals(TypeEnum.BOOL)) { return new TypeCheckResult(true, new BaseType(TypeEnum.BOOL)); } else { errors.add(new TypeMismatchException("Both types must be Boolean")); @@ -538,13 +559,17 @@ public class SemanticAnalyzer implements SemanticVisitor { if (unary.identifier != null) { if (currentScope.contains(unary.identifier)) { - return new TypeCheckResult(valid, currentScope.getLocalVar(unary.identifier)); + var type = currentScope.getLocalVar(unary.identifier); + unary.setType(type); + return new TypeCheckResult(valid, type); } else if (currentFields.get(unary.identifier) != null) { MemberAccessNode memberAccessNode = new MemberAccessNode(false); memberAccessNode.identifiers.add(currentClass.identifier); memberAccessNode.identifiers.add(unary.identifier); unary.memberAccess = memberAccessNode; - return new TypeCheckResult(valid, currentFields.get(unary.identifier)); + var type = currentFields.get(unary.identifier); + unary.setType(type); + return new TypeCheckResult(valid,type ); } else if (unary.statement != null) { var result = unary.statement.accept(this); unary.setType(result.getType()); @@ -554,15 +579,19 @@ public class SemanticAnalyzer implements SemanticVisitor { } } else if (unary.statement != null) { var result = unary.statement.accept(this); + unary.setType(result.getType()); return new TypeCheckResult(result.isValid(), result.getType()); } else if (unary.value != null) { var result = unary.value.accept(this); + unary.setType(result.getType()); return new TypeCheckResult(result.isValid(), result.getType()); } else if (unary.memberAccess != null) { var result = unary.memberAccess.accept(this); + unary.setType(result.getType()); return new TypeCheckResult(result.isValid(), result.getType()); } else if (unary.expression != null) { var result = unary.expression.accept(this); + unary.setType(result.getType()); return new TypeCheckResult(result.isValid(), result.getType()); } diff --git a/src/test/java/semantic/EndToTypedAstTest.java b/src/test/java/semantic/EndToTypedAstTest.java index be95ab2..b18b8c3 100644 --- a/src/test/java/semantic/EndToTypedAstTest.java +++ b/src/test/java/semantic/EndToTypedAstTest.java @@ -281,6 +281,63 @@ public class EndToTypedAstTest { } + @Test + public void VariableCompare(){ + + ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/singleFeatureSemanticTests/VariableCompare.java"); + + SemanticAnalyzer.generateTast(tast); + + assertTrue(SemanticAnalyzer.errors.isEmpty()); + + } + + @Test + public void IfExpressionInt(){ + + ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/singleFeatureSemanticTests/IfExpressionInt.java"); + + SemanticAnalyzer.generateTast(tast); + + assertFalse(SemanticAnalyzer.errors.isEmpty()); + assertInstanceOf(TypeMismatchException.class, SemanticAnalyzer.errors.getFirst()); + + } + + @Test + public void SelectWrongMethodCauseParameter(){ + + ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/singleFeatureSemanticTests/SelectWrongMethodCauseParameter.java"); + + SemanticAnalyzer.generateTast(tast); + + assertFalse(SemanticAnalyzer.errors.isEmpty()); + assertInstanceOf(TypeMismatchException.class, SemanticAnalyzer.errors.getFirst()); + + } + + @Test + public void SelectRightMethodCauseParameter(){ + + ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/singleFeatureSemanticTests/SelectRightMethodCauseParameter.java"); + + SemanticAnalyzer.generateTast(tast); + + assertTrue(SemanticAnalyzer.errors.isEmpty()); + + } + + @Test + public void VariableCalculation(){ + + ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/singleFeatureSemanticTests/VariableCalculation.java"); + + SemanticAnalyzer.generateTast(tast); + + assertTrue(SemanticAnalyzer.errors.isEmpty()); + + } + // ------------------ Helpers ------------------ /** diff --git a/src/test/java/semantic/SemanticHelper.java b/src/test/java/semantic/SemanticHelper.java index 7b0c0ed..ec1a45b 100644 --- a/src/test/java/semantic/SemanticHelper.java +++ b/src/test/java/semantic/SemanticHelper.java @@ -14,6 +14,9 @@ import java.io.IOException; public class SemanticHelper { public static ASTNode generateTypedASTFrom(String filePath) { + + SemanticAnalyzer.clearAnalyzer(); + CharStream testFile = null; try { testFile = CharStreams.fromFileName(filePath); diff --git a/src/test/resources/input/typedAstExceptionsTests/IfExpressionInt.java b/src/test/resources/input/singleFeatureSemanticTests/IfExpressionInt.java similarity index 73% rename from src/test/resources/input/typedAstExceptionsTests/IfExpressionInt.java rename to src/test/resources/input/singleFeatureSemanticTests/IfExpressionInt.java index 2fbbbfc..43b5101 100644 --- a/src/test/resources/input/typedAstExceptionsTests/IfExpressionInt.java +++ b/src/test/resources/input/singleFeatureSemanticTests/IfExpressionInt.java @@ -1,4 +1,3 @@ -// @expected: TypeMismatchException public class Test{ public void test(int x){ diff --git a/src/test/resources/input/singleFeatureSemanticTests/SelectRightMethodCauseParameter.java b/src/test/resources/input/singleFeatureSemanticTests/SelectRightMethodCauseParameter.java new file mode 100644 index 0000000..e148c46 --- /dev/null +++ b/src/test/resources/input/singleFeatureSemanticTests/SelectRightMethodCauseParameter.java @@ -0,0 +1,22 @@ +// @expected: TypeMismatchException +public class Test{ + + public int i; + public boolean b; + + public int test(){ + + return test(b); + + } + + public void test(int a){ + + } + + public int test(boolean bool){ + int ret = 1; + return ret; + } + +} diff --git a/src/test/resources/input/typedAstExceptionsTests/SelectWrongMethodCauseParameter.java b/src/test/resources/input/singleFeatureSemanticTests/SelectWrongMethodCauseParameter.java similarity index 100% rename from src/test/resources/input/typedAstExceptionsTests/SelectWrongMethodCauseParameter.java rename to src/test/resources/input/singleFeatureSemanticTests/SelectWrongMethodCauseParameter.java diff --git a/src/test/resources/input/singleFeatureSemanticTests/VariableCalculation.java b/src/test/resources/input/singleFeatureSemanticTests/VariableCalculation.java new file mode 100644 index 0000000..847b1a6 --- /dev/null +++ b/src/test/resources/input/singleFeatureSemanticTests/VariableCalculation.java @@ -0,0 +1,34 @@ +class VariableCalculation{ + + int aPlusB(int a, int b){ + return a + b; + } + + int aMinusB(int a, int b){ + return a - b; + } + + int aTimeB(int a, int b){ + return a * b; + } + + int aDivB(int a, int b){ + return a / b; + } + + int complexCalc (int a, int b){ + return a * b / 1 * 3; + } + + boolean aSmallerB (int a, int b){ + return a < b; + } + + boolean aGreaterB (int a, int b){ + return a > b; + } + + boolean aEqualsB (int a, int b){ + return a == b; + } +} \ No newline at end of file diff --git a/src/test/resources/input/singleFeatureSemanticTests/VariableCompare.java b/src/test/resources/input/singleFeatureSemanticTests/VariableCompare.java new file mode 100644 index 0000000..70f2a39 --- /dev/null +++ b/src/test/resources/input/singleFeatureSemanticTests/VariableCompare.java @@ -0,0 +1,30 @@ +class VariableCompare{ + + boolean trueMethod() { + return true; + } + + boolean falseMethod(){ + return false; + } + + boolean trueAndTrueMethod(){ + return true && true; + } + + boolean trueAndFalseMethod(){ + return true && false; + } + + boolean falseAndFalseMethod(){ + return false && false; + } + + boolean trueOrTrueMethod(){ + return true || true; + } + + boolean falseOrFalseMethod(){ + return false || false; + } +} \ No newline at end of file From 34bb86c7f46da5ea4a730b787f7df3cf15698122 Mon Sep 17 00:00:00 2001 From: Bruder John Date: Thu, 4 Jul 2024 10:40:13 +0200 Subject: [PATCH 3/9] fixed if Check --- src/main/java/semantic/SemanticAnalyzer.java | 8 ++++++-- src/test/java/semantic/EndToTypedAstTest.java | 11 +++++++++++ .../input/singleFeatureSemanticTests/Expression.java | 10 ++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 src/test/resources/input/singleFeatureSemanticTests/Expression.java diff --git a/src/main/java/semantic/SemanticAnalyzer.java b/src/main/java/semantic/SemanticAnalyzer.java index 3b162c6..732a6e6 100644 --- a/src/main/java/semantic/SemanticAnalyzer.java +++ b/src/main/java/semantic/SemanticAnalyzer.java @@ -316,9 +316,13 @@ public class SemanticAnalyzer implements SemanticVisitor { @Override public TypeCheckResult analyze(IfElseNode toCheck) { var resultIf = toCheck.ifStatement.accept(this); - var resultElse = toCheck.elseStatement.accept(this); + if(toCheck.elseStatement != null){ + var resultElse = toCheck.elseStatement.accept(this); + return new TypeCheckResult(resultIf.isValid() && resultElse.isValid(), new BaseType(TypeEnum.VOID)); + } - return new TypeCheckResult(resultIf.isValid() && resultElse.isValid(), new BaseType(TypeEnum.VOID)); + + return new TypeCheckResult(resultIf.isValid(), new BaseType(TypeEnum.VOID)); } @Override diff --git a/src/test/java/semantic/EndToTypedAstTest.java b/src/test/java/semantic/EndToTypedAstTest.java index b18b8c3..e319a91 100644 --- a/src/test/java/semantic/EndToTypedAstTest.java +++ b/src/test/java/semantic/EndToTypedAstTest.java @@ -338,6 +338,17 @@ public class EndToTypedAstTest { } + @Test + public void Expression(){ + + ASTNode tast = SemanticHelper.generateTypedASTFrom("src/test/resources/input/singleFeatureSemanticTests/Expression.java"); + + SemanticAnalyzer.generateTast(tast); + + assertTrue(SemanticAnalyzer.errors.isEmpty()); + + } + // ------------------ Helpers ------------------ /** diff --git a/src/test/resources/input/singleFeatureSemanticTests/Expression.java b/src/test/resources/input/singleFeatureSemanticTests/Expression.java new file mode 100644 index 0000000..a18178b --- /dev/null +++ b/src/test/resources/input/singleFeatureSemanticTests/Expression.java @@ -0,0 +1,10 @@ +class VariableCompare{ + + void trueMethod(boolean a, int c) { + if(a && c == 10){ + + } + } + + +} \ No newline at end of file From f29be4fd8c07885dcd74c3091436bcaf3720e977 Mon Sep 17 00:00:00 2001 From: Lucas <89882946+notbad3500@users.noreply.github.com> Date: Thu, 4 Jul 2024 15:22:05 +0200 Subject: [PATCH 4/9] E2E tests done --- pom.xml | 35 +- readme.md | 68 + src/main/resources/input/CompilerInput.java | 1 - src/test/Makefile | 22 +- src/test/java/main/E2EReflectionsTest.java | 2067 ++++++++++++++++++- src/test/java/main/InputFilesTest.java | 144 +- src/test/java/main/MainTest.java | 39 +- src/test/java/main/ReflectionsTest.java | 145 -- src/test/java/semantic/SemanticTest.java | 436 ++++ 9 files changed, 2711 insertions(+), 246 deletions(-) create mode 100644 readme.md delete mode 100644 src/test/java/main/ReflectionsTest.java diff --git a/pom.xml b/pom.xml index 4712163..84326da 100644 --- a/pom.xml +++ b/pom.xml @@ -23,6 +23,24 @@ 5.11.0-M2 test + + org.junit.platform + junit-platform-suite-engine + 1.11.0-M2 + test + + + org.junit.jupiter + junit-jupiter-api + 5.11.0-M2 + test + + + junit + junit + 4.13.1 + test + org.antlr antlr4-runtime @@ -44,18 +62,6 @@ 3.26.0 test - - org.junit.jupiter - junit-jupiter-api - 5.11.0-M2 - test - - - org.mockito - mockito-core - 5.11.0 - test - @@ -65,6 +71,11 @@ org.apache.maven.plugins maven-surefire-plugin 3.0.0-M5 + + + **/*Test.java + + maven-assembly-plugin diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..fc72bb8 --- /dev/null +++ b/readme.md @@ -0,0 +1,68 @@ +# "Nicht Haskel 2.0" Java Compiler + +Realisation of a subset of the Java Standard Compiler in the course Compiler Construction of the 4th semester Computer Science at the Duale Hochschule Suttgart (Horb). + +This project aims to provide a simplified version of the Java compiler, focusing on key language features and demonstrating the principles of compiler construction. + +## Realised Java syntax + +- **Data types**: `int`, `boolean`, `char` +- **Access modifier**: `public`, `protected`, `private` +- **Operators**: `=` `+` `-` `*` `%` `/` `>` `<` `>=` `<=` `==` `!=` `!` `&&` `||` `++` `--` +- **Keywords**: `class`, `this`, `while`, `do`, `if`, `else`, `for`, `return`, `new`, `switch`, `case`, `break`, `default`, `:` +- **Statements**: + - `if` ... `if else` ... `else`; + - `while` ... ; + - `do` ... `while`; + - `for`; + - `switch` ... `case` ... ; +- **Comments**: + - Single line: `// comment` + - Multi-line: `/* comment */` +- **Further functions**: + - All methods are overloadable + - High maintainability and expandability through implementation of the visitor pattern + - Logging Input and Outputs + - Error Handling in the Semantic Check + +## Project Structure + +```plain +src/ +└── main/ + ├── java/ + │ ├── ast/ -> Defining the structure of the AST + │ ├── bytecode/ -> Generate Java bytecode + │ ├── main/ -> Running the compiler + │ ├── parser/ + │ │ ├── astBuilder/ -> Builder creating the AST + │ │ ├── generated/ -> Antlr generated grammar + │ │ └── grammar/ -> Antlr grammar + │ ├── semantic/ -> Running the semantic check + │ └── visitor/ -> Visitor interface + └── resources/ +test/ +└── java/ +│ ├── main/ -> MainTest, E2ETests, UtilityTests +│ ├── parser/ -> Performs tests on the parser +│ └── semantic/ -> Performs tests on the semantic check +└── resources/ -> Ressources for running the Tests +``` + +## Class-Diagramm AST + +![AST Diagramm](ast.png) + +## Used Tools + +- [Maven 4.0](https://maven.apache.org/index.html) + - Used for automating the build process and managing dependencies. +- [ANTLR4 v.13.1](https://www.antlr.org/) + - Used to parse the input Java code into the Abstract Syntax Tree. + + +## How to run the compiler + +## Download + +```bash \ No newline at end of file diff --git a/src/main/resources/input/CompilerInput.java b/src/main/resources/input/CompilerInput.java index 825490d..463fab7 100644 --- a/src/main/resources/input/CompilerInput.java +++ b/src/main/resources/input/CompilerInput.java @@ -8,7 +8,6 @@ public class Node { public void main() { Compiler compiler = new Compiler(); int i = compiler.add(5, 8); - return i; } } diff --git a/src/test/Makefile b/src/test/Makefile index a19508b..54c905d 100644 --- a/src/test/Makefile +++ b/src/test/Makefile @@ -10,13 +10,7 @@ compile-javac: compile-raupenpiler: cd ../.. ; mvn -DskipTests install cd ../.. ; mvn exec:java -DgenJar=true -DgenClass=true -Dexec.mainClass="main.Main" -Dexec.args="'src/main/resources/input/CompilerInput.java' 'src/main/resources/output'" - cp ../main/resources/output/CompilerInput.class .java/resources/output/raupenpiler - -test: compile-javac compile-raupenpiler test-javac test-raupenpiler - -test-javac: - # gleich wie bei raupenpiler, kann ich ohne funktionierenden Compiler nicht testen - + # cp ../main/resources/output/CompilerInput.class .java/resources/output/raupenpiler test-raupenpiler: # move the compiled class to the test/main folder @@ -29,17 +23,19 @@ test-raupenpiler: clean: - # clean output folders + # clean main output folders rm -f ../main/resources/output/*.class rm -f ../main/resources/output/*.jar + # clean resources output folders rm -f ./resources/output/javac/*.class rm -f ./resources/output/raupenpiler/*.class + rm -f ./resources/output/raupenpiler/*.jar # clean logs - rm -f ../main/resources/logs/*.log + rm -f ../main/resources/logs/* # clean test/java/main folders from .class files for End-to-End tests rm -f ./java/main/*.class - # clean javac output from combinedFeatureTests - rm -f ./resources/input/combinedFeatureTests/*.class - rm -f ./resources/input/singleFeatureTests/*.class - rm -f ./resources/input/typedAstFeatureTests/*.class + # clean javac output from every folder + rm -f ./resources/input/*/*.class + # clean test results from maven surefire plugin + rm -f ../../target/surefire-reports/*.txt diff --git a/src/test/java/main/E2EReflectionsTest.java b/src/test/java/main/E2EReflectionsTest.java index f461417..78d479d 100644 --- a/src/test/java/main/E2EReflectionsTest.java +++ b/src/test/java/main/E2EReflectionsTest.java @@ -1,9 +1,14 @@ package main; +import java.io.IOException; + import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; -import java.util.Arrays; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; import org.junit.jupiter.api.Test; @@ -14,77 +19,79 @@ import static org.junit.jupiter.api.Assertions.*; public class E2EReflectionsTest { @Test - public void AllFeaturesClassExampleTest(){ + public void CharTest() { + final String FILE_NAME = "Char"; try { - Main.main(new String[]{"src/test/resources/input/combinedFeatureTests/AllFeaturesClassExample.java", "src/test/resources/output/raupenpiler"}); + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available assertNotNull(javac, "Java Compiler is not available"); - javac.run(null, null, null, "src/test/resources/input/combinedFeatureTests/AllFeaturesClassExample.java"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); - Class clazz = Class.forName("src.resources.input.combinedFeatureTests.AllFeaturesClassExample"); - ClassLoader classLoader = getClass().getClassLoader(); - // Class clazz = classLoader.loadClass("main.AllFeaturesClassExample"); // Class Name - assertEquals("main.AllFeaturesClassExample", clazz.getName()); + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + // Constructors - Constructor[] actualConstructors = clazz.getDeclaredConstructors(); - assertTrue(actualConstructors.length > 0, "No constructors found"); + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); - Constructor expectedConstructor = clazz.getConstructor(int.class, boolean.class, char.class); + assertEquals(javacConstructors.length, raupenpilerConstructors.length); - boolean constructorFound = false; - for (Constructor constructor : actualConstructors) { - if (constructor.equals(expectedConstructor)) { - constructorFound = true; - break; + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } } } - assertTrue(constructorFound, "Expected constructor not found in actual constructors"); + // Methods - Method[] actualMethodNames = clazz.getDeclaredMethods(); - assertTrue(actualMethodNames.length > 0); - for (Method method : actualMethodNames) { - System.out.println("Method: " + method.getName()); + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); } - // Method Names - String[] expectedMethodNames = { - "controlStructures", - "logicalOperations", - "add", - "subtract", - "multiply", - "divide", - "modulo", - "main" - }; - - for (Method method : actualMethodNames) { - assertTrue(Arrays.asList(expectedMethodNames).contains(method.getName())); - } // Fields - Field[] actualFields = clazz.getDeclaredFields(); - assertTrue(actualFields.length > 0, "No fields found"); + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); - Field expectedField = clazz.getDeclaredField("c"); - assertEquals(expectedField.getType(), char.class); + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); - boolean fieldFound = false; - for (Field field : actualFields) { - if (field.equals(expectedField)) { - fieldFound = true; - break; + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } } } - assertTrue(fieldFound, "Expected field not found in actual fields"); - - } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { e.printStackTrace(); @@ -92,4 +99,1968 @@ public class E2EReflectionsTest { throw new RuntimeException(e); } } + + @Test + public void CommentsTest() { + final String FILE_NAME = "Comments"; + try { + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + + + // Class Name + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + + + // Constructors + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + + assertEquals(javacConstructors.length, raupenpilerConstructors.length); + + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } + } + } + + + // Methods + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + } + + + // Fields + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } + } + } + + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Test + public void ConstructorMethodCallTest() { + final String FILE_NAME = "ConstructorMethodCall"; + try { + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + + + // Class Name + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + + + // Constructors + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + + assertEquals(javacConstructors.length, raupenpilerConstructors.length); + + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } + } + } + + + // Methods + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + } + + + // Fields + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } + } + } + + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Test + public void ConstructorMethodCallParametersTest() { + final String FILE_NAME = "ConstructorMethodCallParameters"; + try { + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + + + // Class Name + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + + + // Constructors + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + + assertEquals(javacConstructors.length, raupenpilerConstructors.length); + + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } + } + } + + + // Methods + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + } + + + // Fields + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } + } + } + + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Test + public void ConstructorParameterTest() { + final String FILE_NAME = "ConstructorParameter"; + try { + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + + + // Class Name + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + + + // Constructors + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + + assertEquals(javacConstructors.length, raupenpilerConstructors.length); + + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } + } + } + + + // Methods + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + } + + + // Fields + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } + } + } + + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Test + public void ConstructorThisDotTest() { + final String FILE_NAME = "ConstructorThisDot"; + try { + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + + + // Class Name + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + + + // Constructors + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + + assertEquals(javacConstructors.length, raupenpilerConstructors.length); + + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } + } + } + + + // Methods + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + } + + + // Fields + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } + } + } + + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Test + public void DoWhileTest() { + final String FILE_NAME = "DoWhile"; + try { + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + + + // Class Name + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + + + // Constructors + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + + assertEquals(javacConstructors.length, raupenpilerConstructors.length); + + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } + } + } + + + // Methods + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + } + + + // Fields + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } + } + } + + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Test + public void EmptyClassTest() { + final String FILE_NAME = "EmptyClass"; + try { + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + + + // Class Name + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + + + // Constructors + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + + assertEquals(javacConstructors.length, raupenpilerConstructors.length); + + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } + } + } + + + // Methods + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + } + + + // Fields + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } + } + } + + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Test + public void EmptyClassWithConstructorTest() { + final String FILE_NAME = "EmptyClassWithConstructor"; + try { + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + + + // Class Name + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + + + // Constructors + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + + assertEquals(javacConstructors.length, raupenpilerConstructors.length); + + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } + } + } + + + // Methods + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + } + + + // Fields + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } + } + } + + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Test + public void FieldTest() { + final String FILE_NAME = "Field"; + try { + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + + + // Class Name + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + + + // Constructors + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + + assertEquals(javacConstructors.length, raupenpilerConstructors.length); + + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } + } + } + + + // Methods + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + } + + + // Fields + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } + } + } + + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Test + public void FieldWithAccessModifierTest() { + final String FILE_NAME = "FieldWithAccessModifier"; + try { + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + + + // Class Name + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + + + // Constructors + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + + assertEquals(javacConstructors.length, raupenpilerConstructors.length); + + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } + } + } + + + // Methods + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + } + + + // Fields + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } + } + } + + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Test + public void ForTest() { + final String FILE_NAME = "For"; + try { + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + + + // Class Name + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + + + // Constructors + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + + assertEquals(javacConstructors.length, raupenpilerConstructors.length); + + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } + } + } + + + // Methods + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + } + + + // Fields + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } + } + } + + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + + @Test + public void IfTest() { + final String FILE_NAME = "If"; + try { + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + + + // Class Name + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + + + // Constructors + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + + assertEquals(javacConstructors.length, raupenpilerConstructors.length); + + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } + } + } + + + // Methods + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + } + + + // Fields + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } + } + } + + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + @Test + public void IfElseTest() { + final String FILE_NAME = "IfElse"; + try { + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + + + // Class Name + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + + + // Constructors + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + + assertEquals(javacConstructors.length, raupenpilerConstructors.length); + + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } + } + } + + + // Methods + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + } + + + // Fields + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } + } + } + + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + @Test + public void IfElseIfElseTest() { + final String FILE_NAME = "IfElseIfElse"; + try { + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + + + // Class Name + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + + + // Constructors + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + + assertEquals(javacConstructors.length, raupenpilerConstructors.length); + + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } + } + } + + + // Methods + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + } + + + // Fields + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } + } + } + + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + @Test + public void IncrementTest() { + final String FILE_NAME = "Increment"; + try { + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + + + // Class Name + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + + + // Constructors + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + + assertEquals(javacConstructors.length, raupenpilerConstructors.length); + + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } + } + } + + + // Methods + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + } + + + // Fields + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } + } + } + + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + @Test + public void MainMethodTest() { + final String FILE_NAME = "MainMethod"; + try { + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + + + // Class Name + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + + + // Constructors + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + + assertEquals(javacConstructors.length, raupenpilerConstructors.length); + + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } + } + } + + + // Methods + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + } + + + // Fields + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } + } + } + + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + @Test + public void MultipleClassesTest() { + final String FILE_NAME = "MultipleClasses"; + try { + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + + + // Class Name + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + + + // Constructors + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + + assertEquals(javacConstructors.length, raupenpilerConstructors.length); + + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } + } + } + + + // Methods + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + } + + + // Fields + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } + } + } + + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + @Test + public void NullTest() { + final String FILE_NAME = "Null"; + try { + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + + + // Class Name + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + + + // Constructors + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + + assertEquals(javacConstructors.length, raupenpilerConstructors.length); + + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } + } + } + + + // Methods + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + } + + + // Fields + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } + } + } + + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + @Test + public void SelfReferenceTest() { + final String FILE_NAME = "SelfReference"; + try { + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + + + // Class Name + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + + + // Constructors + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + + assertEquals(javacConstructors.length, raupenpilerConstructors.length); + + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } + } + } + + + // Methods + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + } + + + // Fields + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } + } + } + + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + @Test + public void ThisDotTest() { + final String FILE_NAME = "ThisDot"; + try { + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + + + // Class Name + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + + + // Constructors + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + + assertEquals(javacConstructors.length, raupenpilerConstructors.length); + + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } + } + } + + + // Methods + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + } + + + // Fields + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } + } + } + + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + @Test + public void VariableCalculationTest() { + final String FILE_NAME = "VariableCalculation"; + try { + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + + + // Class Name + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + + + // Constructors + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + + assertEquals(javacConstructors.length, raupenpilerConstructors.length); + + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } + } + } + + + // Methods + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + } + + + // Fields + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } + } + } + + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + @Test + public void VariableCompareTest() { + final String FILE_NAME = "VariableCompare"; + try { + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + + + // Class Name + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + + + // Constructors + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + + assertEquals(javacConstructors.length, raupenpilerConstructors.length); + + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } + } + } + + + // Methods + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + } + + + // Fields + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } + } + } + + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + @Test + public void VoidMethodTest() { + final String FILE_NAME = "VoidMethod"; + try { + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + + + // Class Name + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + + + // Constructors + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + + assertEquals(javacConstructors.length, raupenpilerConstructors.length); + + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } + } + } + + + // Methods + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + } + + + // Fields + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } + } + } + + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + @Test + public void WhileTest() { + final String FILE_NAME = "While"; + try { + // compile with raupenpiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + // compile with javac + javac.run(null, null, null, "src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java"); + moveFile("src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".class", "src/test/resources/output/javac/" + FILE_NAME + ".class"); + + // Load the javac class + Path javacClassPath = Paths.get("src/test/resources/output/javac"); + ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); + Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); + + // Load the raupenpiler class + Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); + ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); + Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + + + // Class Name + assertEquals(FILE_NAME, javacLoadedClass.getName()); + assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + + + // Constructors + Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); + Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + + assertEquals(javacConstructors.length, raupenpilerConstructors.length); + + for(Constructor c : javacConstructors) { + for(Constructor raupenpilerConstructor : raupenpilerConstructors) { + assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); + if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { + assertEquals(c.getName(), raupenpilerConstructor.getName()); + } + } + } + + + // Methods + Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); + Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + + assertEquals(javacMethods.length, raupenpilerMethods.length); + + for (int i = 0; i < javacMethods.length; i++) { + assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + } + + + // Fields + Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); + Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + + assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + + for (Field field : javacLoadedClassDeclaredFields) { + for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { + if (field.getName().equals(raupenpilerField.getName())) { + assertEquals(field.getType(), raupenpilerField.getType()); + // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + } + } + } + + } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { + e.printStackTrace(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + // Helpers + + public static void moveFile(String sourceFilePath, String destinationFilePath) throws IOException { + Path sourcePath = Paths.get(sourceFilePath); + Path destinationPath = Paths.get(destinationFilePath); + Files.move(sourcePath, destinationPath, StandardCopyOption.REPLACE_EXISTING); + } } \ No newline at end of file diff --git a/src/test/java/main/InputFilesTest.java b/src/test/java/main/InputFilesTest.java index 4529c9d..3ba18f3 100644 --- a/src/test/java/main/InputFilesTest.java +++ b/src/test/java/main/InputFilesTest.java @@ -1,5 +1,6 @@ package main; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import javax.tools.JavaCompiler; @@ -26,13 +27,17 @@ public class InputFilesTest { // Assert that the compiler is available assertNotNull(javac, "Java Compiler is not available"); - File folder1 = new File("src/test/resources/input/combinedFeatureTests"); - File folder2 = new File("src/test/resources/input/singleFeatureTests"); - File folder3 = new File("src/test/resources/input/typedAstFeatureTests"); + File combinedFeatureTests = new File("src/test/resources/input/combinedFeatureTests"); + File endabgabeTests = new File("src/test/resources/input/endabgabeTests"); + File singleFeatureSemanticTests = new File("src/test/resources/input/singleFeatureSemanticTests"); + File singleFeatureTests = new File("src/test/resources/input/singleFeatureTests"); + File typedAstFeatureTests = new File("src/test/resources/input/typedAstFeatureTests"); - List files = getJavaFilesFromDirectory(folder1); - files.addAll(getJavaFilesFromDirectory(folder2)); - files.addAll(getJavaFilesFromDirectory(folder3)); + List files = getJavaFilesFromDirectory(combinedFeatureTests); + // files.addAll(getJavaFilesFromDirectory(endabgabeTests)); + // files.addAll(getJavaFilesFromDirectory(singleFeatureSemanticTests)); + files.addAll(getJavaFilesFromDirectory(singleFeatureTests)); + // files.addAll(getJavaFilesFromDirectory(typedAstFeatureTests)); if (!files.isEmpty()) { for (File file : files) { @@ -47,6 +52,133 @@ public class InputFilesTest { } } + @Test + public void areCombinedFeatureTestsValid() throws IOException { + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + + File combinedFeatureTests = new File("src/test/resources/input/combinedFeatureTests"); + + List files = getJavaFilesFromDirectory(combinedFeatureTests); + + if (!files.isEmpty()) { + for (File file : files) { + // Try to compile the file and get the result + int result = javac.run(null, null, null, file.getPath()); + + // Assert that the compilation succeeded (i.e., the result is zero) + assertEquals(0, result, "Expected compilation success for " + file.getName()); + } + } else { + System.out.println("No files found in the directories."); + } + } + + @Test + @Disabled + public void areEndabgabeTestsActuallyValid() throws IOException { + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + + File endabgabeTests = new File("src/test/resources/input/endabgabeTests"); + + List files = getJavaFilesFromDirectory(endabgabeTests); + + if (!files.isEmpty()) { + for (File file : files) { + // Try to compile the file and get the result + int result = javac.run(null, null, null, file.getPath()); + + // Assert that the compilation succeeded (i.e., the result is zero) + assertEquals(0, result, "Expected compilation success for " + file.getName()); + } + } else { + System.out.println("No files found in the directories."); + } + } + + @Test + @Disabled + public void areSingleFeatureSemanticTestsActuallyValid() throws IOException { + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + + File singleFeatureSemanticTests = new File("src/test/resources/input/singleFeatureSemanticTests"); + + List files = getJavaFilesFromDirectory(singleFeatureSemanticTests); + + if (!files.isEmpty()) { + for (File file : files) { + // Try to compile the file and get the result + int result = javac.run(null, null, null, file.getPath()); + + // Assert that the compilation succeeded (i.e., the result is zero) + assertEquals(0, result, "Expected compilation success for " + file.getName()); + } + } else { + System.out.println("No files found in the directories."); + } + } + + + @Test + public void areSingleFeatureTestsActuallyValid() throws IOException { + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + + File singleFeatureTests = new File("src/test/resources/input/singleFeatureTests"); + + List files = getJavaFilesFromDirectory(singleFeatureTests); + + if (!files.isEmpty()) { + for (File file : files) { + // Try to compile the file and get the result + int result = javac.run(null, null, null, file.getPath()); + + // Assert that the compilation succeeded (i.e., the result is zero) + assertEquals(0, result, "Expected compilation success for " + file.getName()); + } + } else { + System.out.println("No files found in the directories."); + } + } + + + @Test + @Disabled + public void areTypedAstFeatureTestsActuallyValid() throws IOException { + // Get the system Java compiler + JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); + // Assert that the compiler is available + assertNotNull(javac, "Java Compiler is not available"); + + File typedAstFeatureTests = new File("src/test/resources/input/typedAstFeatureTests"); + + List files = getJavaFilesFromDirectory(typedAstFeatureTests); + + if (!files.isEmpty()) { + for (File file : files) { + // Try to compile the file and get the result + int result = javac.run(null, null, null, file.getPath()); + + // Assert that the compilation succeeded (i.e., the result is zero) + assertEquals(0, result, "Expected compilation success for " + file.getName()); + } + } else { + System.out.println("No files found in the directories."); + } + } + + + /** * This test method checks if invalid Java files fail to compile as expected. diff --git a/src/test/java/main/MainTest.java b/src/test/java/main/MainTest.java index 24389bc..890f4cd 100644 --- a/src/test/java/main/MainTest.java +++ b/src/test/java/main/MainTest.java @@ -1,28 +1,25 @@ package main; -import org.junit.jupiter.api.Test; -import org.antlr.v4.runtime.CharStream; -import org.antlr.v4.runtime.CharStreams; - -import java.io.IOException; -import java.nio.file.Paths; - +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import parser.ParserTest; +import parser.ScannerTest; +import semantic.EndToTypedAstTest; +import semantic.SemanticTest; /** - * run every test: mvn test - * Nutzen dieser Klasse: Eigentlich nicht vorhanden, in der Main gibts nichts zu testen + * This class is a test suite that runs all the test classes in the project. + *

run: mvn test + *

check results in console or target/surefire-reports */ +@RunWith(Suite.class) +@Suite.SuiteClasses({ + InputFilesTest.class, + ScannerTest.class, + ParserTest.class, + SemanticTest.class, + EndToTypedAstTest.class +}) public class MainTest { - @Test - void test() { - CharStream codeCharStream = null; - try { - codeCharStream = CharStreams.fromPath(Paths.get("src/main/test/resources/CompilerInput.java")); - Main.compileFile(codeCharStream, "src/main/test/resources/output"); - } catch (IOException e) { - System.err.println("Error reading the file: " + e.getMessage()); - } - } + // This class remains empty, it is used only as a holder for the above annotations } - - diff --git a/src/test/java/main/ReflectionsTest.java b/src/test/java/main/ReflectionsTest.java deleted file mode 100644 index d47d95a..0000000 --- a/src/test/java/main/ReflectionsTest.java +++ /dev/null @@ -1,145 +0,0 @@ -package main; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.Arrays; -import java.util.List; - -import org.antlr.v4.runtime.CharStream; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.*; - - -public class ReflectionsTest { - - @Test - public void testSimpleJavaLexerClass() throws ClassNotFoundException, NoSuchMethodException { - Class clazz = Class.forName("parser.generated.SimpleJavaLexer"); - - // Class Name - assertEquals("parser.generated.SimpleJavaLexer", clazz.getName()); - - // Constructors - Constructor[] actualConstructors = clazz.getDeclaredConstructors(); - assertTrue(actualConstructors.length > 0, "No constructors found"); - - Constructor expectedConstructor = clazz.getConstructor(CharStream.class); - - boolean constructorFound = false; - for (Constructor constructor : actualConstructors) { - if (constructor.equals(expectedConstructor)) { - constructorFound = true; - break; - } - } - assertTrue(constructorFound, "Expected constructor not found in actual constructors"); - - - - // Methods - Method[] actualMethodNames = clazz.getDeclaredMethods(); - assertTrue(actualMethodNames.length > 0); - Arrays.stream(actualMethodNames).forEach(method -> System.out.println("Method: " + method.getName())); - - List expectedMethodNames = Arrays.asList( - "getTokenNames", - "getVocabulary", - "getGrammarFileName", - "getRuleNames", - "getSerializedATN", - "getChannelNames", - "getModeNames", - "getATN", - "makeRuleNames", - "makeLiteralNames", - "makeSymbolicNames" - ); - - for (Method method : actualMethodNames) { - assertTrue(expectedMethodNames.contains(method.getName())); - } - - for (String expectedMethodName : expectedMethodNames) { - boolean methodFound = false; - for (Method method : actualMethodNames) { - if (method.getName().equals(expectedMethodName)) { - methodFound = true; - break; - } - } - assertTrue(methodFound, "Expected method " + expectedMethodName + " not found in actual methods"); - } - - - // Fields - Field[] actualFieldNames = clazz.getDeclaredFields(); - assertTrue(actualFieldNames.length > 0); - Arrays.stream(actualFieldNames).forEach(field -> System.out.println("Field: " + field.getName())); - - List expectedFieldNames = Arrays.asList( - "_decisionToDFA", - "_sharedContextCache", - "channelNames", - "modeNames", - "ruleNames", - "_LITERAL_NAMES", - "_SYMBOLIC_NAMES", - "VOCABULARY", - "tokenNames", - "_serializedATN", - "_ATN" - ); - - for (Field field : actualFieldNames) { - assertTrue(expectedFieldNames.contains(field.getName())); - } - } - - @Test - public void testSimpleJavaParserClass() throws ClassNotFoundException { - Class clazz = Class.forName("parser.generated.SimpleJavaParser"); - - // Class Name - assertEquals("parser.generated.SimpleJavaParser", clazz.getName()); - - // Constructors - Constructor[] constructors = clazz.getDeclaredConstructors(); - assertTrue(constructors.length > 0); - - // Methods - Method[] methods = clazz.getDeclaredMethods(); - assertTrue(methods.length > 0); - Arrays.stream(methods).forEach(method -> System.out.println("Method: " + method.getName())); - - // Fields - Field[] fields = clazz.getDeclaredFields(); - assertTrue(fields.length > 0); - Arrays.stream(fields).forEach(field -> System.out.println("Field: " + field.getName())); - } - - @Test - public void testASTBuilderClass() throws ClassNotFoundException { - Class clazz = Class.forName("parser.astBuilder.ASTBuilder"); - - // Class Name - assertEquals("parser.astBuilder.ASTBuilder", clazz.getName()); - - // Constructors - Constructor[] constructors = clazz.getDeclaredConstructors(); - assertTrue(constructors.length > 0); - - // Methods - Method[] methods = clazz.getDeclaredMethods(); - assertTrue(methods.length > 0); - Arrays.stream(methods).forEach(method -> System.out.println("Method: " + method.getName())); - - // Fields - Field[] fields = clazz.getDeclaredFields(); - assertTrue(fields.length > 0); - Arrays.stream(fields).forEach(field -> System.out.println("Field: " + field.getName())); - } - - // Similarly, you can add tests for SemanticAnalyzer and ByteCodeGenerator -} diff --git a/src/test/java/semantic/SemanticTest.java b/src/test/java/semantic/SemanticTest.java index f406580..ac7393f 100644 --- a/src/test/java/semantic/SemanticTest.java +++ b/src/test/java/semantic/SemanticTest.java @@ -1,5 +1,441 @@ package semantic; +import ast.ASTNode; +import ast.ClassNode; +import ast.ProgramNode; +import ast.expressions.IExpressionNode; +import ast.expressions.unaryexpressions.MemberAccessNode; +import ast.expressions.unaryexpressions.UnaryNode; +import ast.members.ConstructorNode; +import ast.members.FieldNode; +import ast.members.MethodNode; +import ast.parameters.ParameterNode; +import ast.statementexpressions.AssignNode; +import ast.statementexpressions.AssignableNode; +import ast.statementexpressions.methodcallstatementnexpressions.MethodCallNode; +import ast.statements.BlockNode; +import ast.statements.ReturnNode; +import ast.type.AccessModifierNode; +import ast.type.EnumValueNode; +import ast.type.ValueNode; +import ast.type.type.BaseType; +import ast.type.type.TypeEnum; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import parser.Helper; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class SemanticTest { + @BeforeEach + public void setUp() { + SemanticAnalyzer.clearAnalyzer(); + } + + @Test + @DisplayName("Empty Class Test") + public void emptyClassTest() { + ClassNode emptyClass = Helper.generateEmptyClass("EmptyClass"); + ProgramNode abstractSyntaxTree = new ProgramNode(); + abstractSyntaxTree.addClass(emptyClass); + + ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree); + for (Exception runtimeException : SemanticAnalyzer.errors) { + runtimeException.printStackTrace(); + } + assertTrue(SemanticAnalyzer.errors.isEmpty()); + assertNotNull(typedAst); + } + + + @Test + @DisplayName("Multiple Empty Classes Test") + public void multipleEmptyClassesTest() { + ClassNode class1 = Helper.generateEmptyClass("MultipleClasses"); + ClassNode class2 = Helper.generateEmptyClass("TestClass2"); + ProgramNode abstractSyntaxTree = new ProgramNode(); + abstractSyntaxTree.addClass(class1); + abstractSyntaxTree.addClass(class2); + + ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree); + for (Exception runtimeException : SemanticAnalyzer.errors) { + runtimeException.printStackTrace(); + } + assertTrue(SemanticAnalyzer.errors.isEmpty()); + assertNotNull(typedAst); + } + + + @Test + @DisplayName("Empty Class Test with Constructor") + public void emptyClassWithConstructorTest() { + ClassNode class1 = Helper.generateEmptyClass("EmptyClassWithConstructor"); + ProgramNode abstractSyntaxTree = new ProgramNode(); + abstractSyntaxTree.addClass(class1); + + ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree); + for (Exception runtimeException : SemanticAnalyzer.errors) { + runtimeException.printStackTrace(); + } + assertTrue(SemanticAnalyzer.errors.isEmpty()); + assertNotNull(typedAst); + } + + @Test + @DisplayName("Field Test") + public void fieldTest() { + ClassNode class1 = Helper.generateEmptyClass("Field"); + class1.addMember(new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.INT), "a")); + + ProgramNode abstractSyntaxTree = new ProgramNode(); + abstractSyntaxTree.addClass(class1); + + ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree); + for (Exception runtimeException : SemanticAnalyzer.errors) { + runtimeException.printStackTrace(); + } + assertTrue(SemanticAnalyzer.errors.isEmpty()); + assertNotNull(typedAst); + } + + @Test + @DisplayName("Field Test with Accessmodifier") + public void fieldTestWithModifier() { + ClassNode class1 = Helper.generateEmptyClass("FieldWithAccessModifier"); + class1.addMember(new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.INT), "a")); + + ProgramNode abstractSyntaxTree = new ProgramNode(); + abstractSyntaxTree.addClass(class1); + + ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree); + for (Exception runtimeException : SemanticAnalyzer.errors) { + runtimeException.printStackTrace(); + } + assertTrue(SemanticAnalyzer.errors.isEmpty()); + assertNotNull(typedAst); + } + + @Test + @DisplayName("Comments Ignore Test") + public void commentsIgnoreTest() { + ClassNode class1 = Helper.generateEmptyClass("Comments"); + class1.addMember(new FieldNode(new AccessModifierNode("private"), new BaseType(TypeEnum.INT), "a")); + + ProgramNode abstractSyntaxTree = new ProgramNode(); + abstractSyntaxTree.addClass(class1); + + ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree); + for (Exception runtimeException : SemanticAnalyzer.errors) { + runtimeException.printStackTrace(); + } + assertTrue(SemanticAnalyzer.errors.isEmpty()); + assertNotNull(typedAst); + } + + @Test + @DisplayName("Constructor Parameter Test") + public void constructorParameterTest() { + BlockNode block = new BlockNode(); + block.addStatement(new ReturnNode(null)); + ConstructorNode constructor = new ConstructorNode("public", "ConstructorParameter", block); + constructor.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "a")); + constructor.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "b")); + + ClassNode class1 = new ClassNode("public", "ConstructorParameter"); + class1.addMember(constructor); + + ProgramNode abstractSyntaxTree = new ProgramNode(); + abstractSyntaxTree.addClass(class1); + + ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree); + for (Exception runtimeException : SemanticAnalyzer.errors) { + runtimeException.printStackTrace(); + } + assertTrue(SemanticAnalyzer.errors.isEmpty()); + assertNotNull(typedAst); + } + + @Test + @DisplayName("This Dot Test") + public void thisDotTest() { + BlockNode block = new BlockNode(); + MemberAccessNode memberAccess = new MemberAccessNode(true); + memberAccess.addIdentifier("a"); + + AssignableNode assignable = new AssignableNode(memberAccess); + + ValueNode value = new ValueNode(EnumValueNode.INT_VALUE, "1"); + IExpressionNode expression = new UnaryNode(value); + + block.addStatement(new AssignNode(assignable, expression)); + block.addStatement(new ReturnNode(null)); + ConstructorNode constructor = new ConstructorNode("public", "ThisDot", block); + + ClassNode class1 = new ClassNode("public", "ThisDot"); + class1.addMember(new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.INT), "a")); + class1.addMember(constructor); + + ProgramNode abstractSyntaxTree = new ProgramNode(); + abstractSyntaxTree.addClass(class1); + + ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree); + for (Exception runtimeException : SemanticAnalyzer.errors) { + runtimeException.printStackTrace(); + } + assertTrue(SemanticAnalyzer.errors.isEmpty()); + assertNotNull(typedAst); + } + + @Test + @DisplayName("Constructor This Dot Test") + public void constructorThisDotTest() { + BlockNode block = new BlockNode(); + MemberAccessNode memberAccess = new MemberAccessNode(true); + memberAccess.addIdentifier("a"); + + AssignableNode assignable = new AssignableNode(memberAccess); + + IExpressionNode expression = new UnaryNode("a"); + + block.addStatement(new AssignNode(assignable, expression)); + block.addStatement(new ReturnNode(null)); + ConstructorNode constructor = new ConstructorNode("public", "ConstructorThisDot", block); + constructor.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "a")); + + ClassNode class1 = new ClassNode("public", "ConstructorThisDot"); + class1.addMember(new FieldNode(new AccessModifierNode("private"), new BaseType(TypeEnum.INT), "a")); + class1.addMember(constructor); + + ProgramNode abstractSyntaxTree = new ProgramNode(); + abstractSyntaxTree.addClass(class1); + + ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree); + for (Exception runtimeException : SemanticAnalyzer.errors) { + runtimeException.printStackTrace(); + } + assertTrue(SemanticAnalyzer.errors.isEmpty()); + assertNotNull(typedAst); + } + + @Test + @DisplayName("Void Methoden Test") + public void voidMethodenTest() { + ClassNode class1 = Helper.generateEmptyClass("VoidMethod"); + BlockNode block = new BlockNode(); + block.addStatement(new ReturnNode(null)); + class1.addMember(new MethodNode("public", null, true, "test", block)); + + ProgramNode abstractSyntaxTree = new ProgramNode(); + abstractSyntaxTree.addClass(class1); + + ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree); + for (Exception runtimeException : SemanticAnalyzer.errors) { + runtimeException.printStackTrace(); + } + assertTrue(SemanticAnalyzer.errors.isEmpty()); + assertNotNull(typedAst); + } + + @Test + @DisplayName("Constructor Method call Test") + public void constructorMethodCallTest() { + BlockNode blockCon = new BlockNode(); + MemberAccessNode memberAccess = new MemberAccessNode(true); + memberAccess.addIdentifier("a"); + + AssignableNode assignable = new AssignableNode(memberAccess); + + IExpressionNode expression = new UnaryNode(new MethodCallNode(null, "testMethod")); + + blockCon.addStatement(new AssignNode(assignable, expression)); + blockCon.addStatement(new ReturnNode(null)); + ConstructorNode constructor = new ConstructorNode("public", "ConstructorMethodCall", blockCon); + + BlockNode blockMethod = new BlockNode(); + blockMethod.addStatement(new ReturnNode(new UnaryNode(new ValueNode(EnumValueNode.INT_VALUE, "1")))); + MethodNode method = new MethodNode("public", new BaseType(TypeEnum.INT), false, "testMethod", blockMethod); + + ClassNode class1 = new ClassNode("public", "ConstructorMethodCall"); + class1.addMember(new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.INT), "a")); + class1.addMember(constructor); + class1.addMember(method); + + ProgramNode abstractSyntaxTree = new ProgramNode(); + abstractSyntaxTree.addClass(class1); + + ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree); + for (Exception runtimeException : SemanticAnalyzer.errors) { + runtimeException.printStackTrace(); + } + assertTrue(SemanticAnalyzer.errors.isEmpty()); + assertNotNull(typedAst); + } + + @Test + @DisplayName("Constructor Method call Parameters Test") + public void constructorMethodCallParametersTest() { + BlockNode blockCon = new BlockNode(); + MemberAccessNode memberAccess = new MemberAccessNode(true); + memberAccess.addIdentifier("a"); + + AssignableNode assignable = new AssignableNode(memberAccess); + + MethodCallNode methodCall = new MethodCallNode(null, "testMethod"); + methodCall.addExpression(new UnaryNode("a")); + IExpressionNode expression = new UnaryNode(methodCall); + + blockCon.addStatement(new AssignNode(assignable, expression)); + blockCon.addStatement(new ReturnNode(null)); + ConstructorNode constructor = new ConstructorNode("public", "ConstructorMethodCallParameters", blockCon); + constructor.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "a")); + + BlockNode blockMethod = new BlockNode(); + blockMethod.addStatement(new ReturnNode(new UnaryNode("a"))); + MethodNode method = new MethodNode("public", new BaseType(TypeEnum.INT), false, "testMethod", blockMethod); + method.addParameter(new ParameterNode(new BaseType(TypeEnum.INT), "a")); + + ClassNode class1 = new ClassNode("public", "ConstructorMethodCallParameters"); + class1.addMember(new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.INT), "a")); + class1.addMember(constructor); + class1.addMember(method); + + ProgramNode abstractSyntaxTree = new ProgramNode(); + abstractSyntaxTree.addClass(class1); + + ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree); + for (Exception runtimeException : SemanticAnalyzer.errors) { + runtimeException.printStackTrace(); + } + assertTrue(SemanticAnalyzer.errors.isEmpty()); + assertNotNull(typedAst); + } + + @Test + @DisplayName("Char Test") + public void charTest() { + BlockNode blockCon = new BlockNode(); + MemberAccessNode memberAccess = new MemberAccessNode(true); + memberAccess.addIdentifier("a"); + + AssignableNode assignable = new AssignableNode(memberAccess); + + MethodCallNode methodCall = new MethodCallNode(null, "testMethod"); + methodCall.addExpression(new UnaryNode("a")); + IExpressionNode expression = new UnaryNode(methodCall); + + blockCon.addStatement(new AssignNode(assignable, expression)); + blockCon.addStatement(new ReturnNode(null)); + ConstructorNode constructor = new ConstructorNode("public", "Char", blockCon); + constructor.addParameter(new ParameterNode(new BaseType(TypeEnum.CHAR), "a")); + + BlockNode blockMethod = new BlockNode(); + blockMethod.addStatement(new ReturnNode(new UnaryNode("a"))); + MethodNode method = new MethodNode("public", new BaseType(TypeEnum.CHAR), false, "testMethod", blockMethod); + method.addParameter(new ParameterNode(new BaseType(TypeEnum.CHAR), "a")); + + ClassNode class1 = new ClassNode("public", "Char"); + class1.addMember(new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.CHAR), "a")); + class1.addMember(constructor); + class1.addMember(method); + + ProgramNode abstractSyntaxTree = new ProgramNode(); + abstractSyntaxTree.addClass(class1); + + ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree); + for (Exception runtimeException : SemanticAnalyzer.errors) { + runtimeException.printStackTrace(); + } + assertTrue(SemanticAnalyzer.errors.isEmpty()); + assertNotNull(typedAst); + } + + @Test + @DisplayName("Null Test") + public void nullTest() { + BlockNode blockCon = new BlockNode(); + MemberAccessNode memberAccess = new MemberAccessNode(true); + memberAccess.addIdentifier("a"); + + AssignableNode assignable = new AssignableNode(memberAccess); + + blockCon.addStatement(new AssignNode(assignable, new UnaryNode(new ValueNode(EnumValueNode.NULL_VALUE, "null")))); + blockCon.addStatement(new ReturnNode(null)); + ConstructorNode constructor = new ConstructorNode("public", "Null", blockCon); + + ClassNode class1 = new ClassNode("public", "Null"); + class1.addMember(new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.INT), "a")); + class1.addMember(constructor); + + ProgramNode abstractSyntaxTree = new ProgramNode(); + abstractSyntaxTree.addClass(class1); + + ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree); + for (Exception runtimeException : SemanticAnalyzer.errors) { + runtimeException.printStackTrace(); + } + assertTrue(SemanticAnalyzer.errors.isEmpty()); + assertNotNull(typedAst); + } + + @Test + @DisplayName("Self Reference Test") + public void selfReferenceTest() { + + } + + @Test + @DisplayName("Variable Compare Test") + public void variableCompareTest() { + + } + + @Test + @DisplayName("Variable Calculation Test") + public void variableCalculationTest() { + + } + + @Test + @DisplayName("Main Method Test") + public void mainMethodTest() { + + } + + @Test + @DisplayName("While Test") + public void whileTest() { + + } + + @Test + @DisplayName("Do While Test") + public void doWhileTest() { + + } + + @Test + @DisplayName("For Test") + public void forTest() { + + } + + @Test + @DisplayName("Increment Test") + public void incrementTest() { + ClassNode classNode = Helper.generateEmptyClass("Increment"); + classNode.addMember(new FieldNode(new AccessModifierNode("public"), new BaseType(TypeEnum.INT), "a")); + + ProgramNode abstractSyntaxTree = new ProgramNode(); + abstractSyntaxTree.addClass(classNode); + + ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree); + for (Exception runtimeException : SemanticAnalyzer.errors) { + runtimeException.printStackTrace(); + } + assertTrue(SemanticAnalyzer.errors.isEmpty()); + assertNotNull(typedAst); + } } \ No newline at end of file From fb5372bc8f9b4906cd9299c0a1dccf855782a2db Mon Sep 17 00:00:00 2001 From: Lucas <89882946+notbad3500@users.noreply.github.com> Date: Thu, 4 Jul 2024 15:22:37 +0200 Subject: [PATCH 5/9] make clean --- .../AllFeaturesClassExample.class | Bin 1093 -> 0 bytes .../combinedFeatureTests/BooleanOperations.class | Bin 686 -> 0 bytes .../combinedFeatureTests/CharManipulation.class | Bin 638 -> 0 bytes .../ConditionalStatements.class | Bin 780 -> 0 bytes .../combinedFeatureTests/EmptyClassExample.class | Bin 208 -> 0 bytes .../combinedFeatureTests/LoopExamples.class | Bin 1004 -> 0 bytes .../combinedFeatureTests/MethodOverloading.class | Bin 1083 -> 0 bytes .../input/singleFeatureTests/Char.class | Bin 302 -> 0 bytes .../input/singleFeatureTests/Comments.class | Bin 206 -> 0 bytes .../ConstructorMethodCall.class | Bin 327 -> 0 bytes .../ConstructorMethodCallParameters.class | Bin 356 -> 0 bytes .../ConstructorParameter.class | Bin 226 -> 0 bytes .../singleFeatureTests/ConstructorThisDot.class | Bin 256 -> 0 bytes .../input/singleFeatureTests/DoWhile.class | Bin 250 -> 0 bytes .../input/singleFeatureTests/EmptyClass.class | Bin 194 -> 0 bytes .../EmptyClassWithConstructor.class | Bin 228 -> 0 bytes .../input/singleFeatureTests/Field.class | Bin 200 -> 0 bytes .../FieldWithAccessModifier.class | Bin 236 -> 0 bytes .../resources/input/singleFeatureTests/For.class | Bin 240 -> 0 bytes .../resources/input/singleFeatureTests/If.class | Bin 239 -> 0 bytes .../input/singleFeatureTests/IfElse.class | Bin 258 -> 0 bytes .../input/singleFeatureTests/IfElseIfElse.class | Bin 290 -> 0 bytes .../input/singleFeatureTests/Increment.class | Bin 350 -> 0 bytes .../input/singleFeatureTests/MainMethod.class | Bin 265 -> 0 bytes .../singleFeatureTests/MultipleClasses.class | Bin 204 -> 0 bytes .../input/singleFeatureTests/Null.class | Bin 226 -> 0 bytes .../input/singleFeatureTests/SelfReference.class | Bin 466 -> 0 bytes .../input/singleFeatureTests/TestClass2.class | Bin 199 -> 0 bytes .../input/singleFeatureTests/ThisDot.class | Bin 227 -> 0 bytes .../singleFeatureTests/VariableCalculation.class | Bin 723 -> 0 bytes .../singleFeatureTests/VariableCompare.class | Bin 620 -> 0 bytes .../input/singleFeatureTests/VoidMethod.class | Bin 240 -> 0 bytes .../input/singleFeatureTests/While.class | Bin 249 -> 0 bytes .../CallMethodFromObjekt$Car.class | Bin 448 -> 0 bytes .../CallMethodFromObjekt.class | Bin 461 -> 0 bytes 35 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/test/resources/input/combinedFeatureTests/AllFeaturesClassExample.class delete mode 100644 src/test/resources/input/combinedFeatureTests/BooleanOperations.class delete mode 100644 src/test/resources/input/combinedFeatureTests/CharManipulation.class delete mode 100644 src/test/resources/input/combinedFeatureTests/ConditionalStatements.class delete mode 100644 src/test/resources/input/combinedFeatureTests/EmptyClassExample.class delete mode 100644 src/test/resources/input/combinedFeatureTests/LoopExamples.class delete mode 100644 src/test/resources/input/combinedFeatureTests/MethodOverloading.class delete mode 100644 src/test/resources/input/singleFeatureTests/Char.class delete mode 100644 src/test/resources/input/singleFeatureTests/Comments.class delete mode 100644 src/test/resources/input/singleFeatureTests/ConstructorMethodCall.class delete mode 100644 src/test/resources/input/singleFeatureTests/ConstructorMethodCallParameters.class delete mode 100644 src/test/resources/input/singleFeatureTests/ConstructorParameter.class delete mode 100644 src/test/resources/input/singleFeatureTests/ConstructorThisDot.class delete mode 100644 src/test/resources/input/singleFeatureTests/DoWhile.class delete mode 100644 src/test/resources/input/singleFeatureTests/EmptyClass.class delete mode 100644 src/test/resources/input/singleFeatureTests/EmptyClassWithConstructor.class delete mode 100644 src/test/resources/input/singleFeatureTests/Field.class delete mode 100644 src/test/resources/input/singleFeatureTests/FieldWithAccessModifier.class delete mode 100644 src/test/resources/input/singleFeatureTests/For.class delete mode 100644 src/test/resources/input/singleFeatureTests/If.class delete mode 100644 src/test/resources/input/singleFeatureTests/IfElse.class delete mode 100644 src/test/resources/input/singleFeatureTests/IfElseIfElse.class delete mode 100644 src/test/resources/input/singleFeatureTests/Increment.class delete mode 100644 src/test/resources/input/singleFeatureTests/MainMethod.class delete mode 100644 src/test/resources/input/singleFeatureTests/MultipleClasses.class delete mode 100644 src/test/resources/input/singleFeatureTests/Null.class delete mode 100644 src/test/resources/input/singleFeatureTests/SelfReference.class delete mode 100644 src/test/resources/input/singleFeatureTests/TestClass2.class delete mode 100644 src/test/resources/input/singleFeatureTests/ThisDot.class delete mode 100644 src/test/resources/input/singleFeatureTests/VariableCalculation.class delete mode 100644 src/test/resources/input/singleFeatureTests/VariableCompare.class delete mode 100644 src/test/resources/input/singleFeatureTests/VoidMethod.class delete mode 100644 src/test/resources/input/singleFeatureTests/While.class delete mode 100644 src/test/resources/input/typedAstFeatureTests/CallMethodFromObjekt$Car.class delete mode 100644 src/test/resources/input/typedAstFeatureTests/CallMethodFromObjekt.class diff --git a/src/test/resources/input/combinedFeatureTests/AllFeaturesClassExample.class b/src/test/resources/input/combinedFeatureTests/AllFeaturesClassExample.class deleted file mode 100644 index b59adc2b7e01f158236a1ad77e723a9172711fe4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1093 zcmZ`%O-~b16g{sq(64DJUj=Cq0fn|8uyA3t8nl9Gg0jGnfE!=iNg14Wn(372o zmTd|MNh>RO(!dZ>j4HH!l^HQGiZMo2S}Dd%TFFmPD_7nx<#$!;nt>@*(Qwsidah&d zcy6ca3#qSJ1JnLj+o@YsX>YeoS9+GyYzycmr^X6~wydW4ywj+d?h9E_H6?aDS$+LX zwt`rbwVJ>{u3XNS1tRTE#dD=m^MJ|mopokCN8J|I=tqt|PsKD+#>6}1Q1$O(*NA&x`h?DCgV3Hd5>WCv@FVw`81 zOPXYU3Jb^}Pru5FZxCTXkB_Cp(IIWF&EHgNvm4ZGuc-k>AOQwqQEk3z8|vIi(Dh}W2`d9G7V~vthF-^jG`= zUwl!t1qDCAk5bR1!6M4A_s+d@?>XmQ_Q%h!-vR8R6Tm}3!VghINuYMDPE|KiHty~Z zj`c7XC_OUPrS&$@Pd7>6DDk-b{r_yDu|i^M0ObHQI4-DuN z=bfvf-Cz{))x8JN1w^#^1@a>!flb;46li^(A}S~`%bm>o*61B(G5QSo;ZKVz0*i$k zoYql1C4tMokpHO>nj@CJD(%rd=uI6cR4$2_T5*j=!D3<6--2f20OR zpzu-0+I$koHJXPWitt?c0p<~q-Z_@(fsFM@7D=O%nDj^)qf!CU@kuUO;Y9(b(XrJp zu;ii=U>Vha%zEdiMvdu_WVEbyAKTDL`&+7G(=(}(<6SHFGQbL633x+gx>F)8Z+-)8T_`M`c2kNu7Xt;kUWf-h%BbokHN5H}fx%-Xyk-a>?H zH*hZ*32YHd$Ppbrd3Y#rl|z`;t@CR&^Winzi>DGx0?EQ|lV~kArxt~0^7ak@3luN0 zqK@q;|A4kOv;7OjALYGUEOf6>ZcR{|V6|1=pI~Da&$_Kq2s~*YOFZWaR*7{~Df*u4 HbJ+OR=|(Sh3MEvQIh;9X&i6ZWW`F(p{u96})RKrGYQu67LtG$pPh>=!bG3bvR~?o($S@Bp^-` zNMqSX#>EP0?)XZ~=$w+6mq zn``B(MSTh+o55t%k*}30E-jq=kr@GY*h_@ZE4cVfv{Cx(mG(JzRc1{-S$%-0ZhV9N znLB|!+BDAs7QYx0h%?G7&Fi|XGMb0gudqKN{RK3hnG-MBjm1>u2b@di0Z$sn$^52wX1pk! m^MiXlt#KW4{kzCEIY5qbtF(D+q5u!;Bo+xM5m045f`h-jQ=H!b diff --git a/src/test/resources/input/combinedFeatureTests/EmptyClassExample.class b/src/test/resources/input/combinedFeatureTests/EmptyClassExample.class deleted file mode 100644 index a6a129d83eb7b7fa699093038b18c5956b9ac7cc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 208 zcmX^0Z`VEs1_mbvUM>bE24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00Sb_Nbc20_={f|5$-oW$Z{*NVj4f}B)F1{UZ16d=X#lbM(5SDKrYS`?C) z1d`wi&Mz%WPIb!!al|lm>VYg|P-I{Sx&s6lfe`2tAjt{j$%6R|46It)85lQ$rMZA4 ONE)J)8%Q%T@BjcvAt~Pg diff --git a/src/test/resources/input/combinedFeatureTests/LoopExamples.class b/src/test/resources/input/combinedFeatureTests/LoopExamples.class deleted file mode 100644 index 2a398c6e58dba159bd89b9357647b2657cb08f32..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1004 zcmaJ=L2nX46#fP%3+onI5GtY-D^;jkwBDrgP$IEOt0pwvpX~rul@+n zUOekTlOFs5{uY0MY1FqsA_U?dW@h(&?|a|-=IxK)7vBNwVaG%SQ3EjxONcY9obhvB zbGSUMy=tF{j%JAO+S1m~7^0QxaS{n64VV_Lz?y-#hJh9?q11qqat9+KTh(6sw$v@{ z3+~o4R5N8EjTMG9m-j_O$qv^iw(ij>&|K<(ax44Qar#IH<=XPJZX$!MfvXmB$TMUY z@G}@*Sj~|k$vj2%I0J^1fdYedpp^IgEq6UfP|a9Fbp=EEz?S0Wz-LiRtaF^t5jMg$`f;bo+ JqK3yP`~|8~{Zs$| diff --git a/src/test/resources/input/combinedFeatureTests/MethodOverloading.class b/src/test/resources/input/combinedFeatureTests/MethodOverloading.class deleted file mode 100644 index 2357744da74e54140524878508a87dd6fe8f3e92..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1083 zcmaJ=T~8B16g@+?-L@>>0wM)g1#M}i0)E%{Koeq89(PmmwPA0 zgZi0hD2Bvq$8*#hhFCUtY$C}p^G>K!**rKGzAJgt@lMh(5ldklmWc@qlbE_eRqF*x zw247>iEzFeHgRO}(04plQ@-HslBSrkFpD|D@n(}Do~=}Jm08j`Z(#w842x~v5@qQ% zxccCzQ(6UzdnzE#Y$X@bhT4gfR1xPA?wDA%kiiPW+=#vmW=E@VJxwx9kvrDH*0eC2 zydX)TCIT}UW!V%AQ&q!@A;qEmu79#CFa+Qz< zArgdK8N!-KVI3QN>>-KK!U{iOe!N7g`UB~FJaK{PE8GGua9bA)U0J=NF?8ix=WN(# q97$O8I3|#%#~Q-};v2(5WGPS5>JjzIg)xs^s-@}s37+8vmi_{y1Na&M diff --git a/src/test/resources/input/singleFeatureTests/Char.class b/src/test/resources/input/singleFeatureTests/Char.class deleted file mode 100644 index 8e9c65e698b9692fda17bc8083d5cfb7c515b6c3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 302 zcmXX=yHdhH6g@WyiCIHHd=%1HLJIf+$HL4|p%yyy8`zOBn9Rh*ucEOKXDs{xKg#he zSln|T=P~!^_v;(LEiM#1_z{8xErf#ZO26sxT365Ghhk;sRuEp7RcUVo{$My$I6@pj zB{)VR2=b+F1j?FMduQyjUhp=^hj~n0nxKQOKr|~q5Hshg7e>&TmX*2RycDK+(#4t= z^;mD3xtWx1iCyx@eS<4zdHhyb3?zD-TR0*1xQ*cN`84~4WLbZQ=mYKdz2lUak_Ytx dLbMTa=I{UBOLmv-^|wTU(}(PUBAz)0=YLd8Dh&Vt diff --git a/src/test/resources/input/singleFeatureTests/Comments.class b/src/test/resources/input/singleFeatureTests/Comments.class deleted file mode 100644 index 8d74444c8006241940352d7c5197335aab576a17..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 206 zcmXv|I|{;35S-25m>4f0SgM7&fLIt11kpmVe~AxyAs>i|_p%Z!Jb;H1HxY}S*_mOP zeSe-W04oG8H0U-A4<;)+`#6G!Jh_MH^+tB{OPM_6?nV8Ml R19b0VkFkw^=rd~=d;y@sBZvS1 diff --git a/src/test/resources/input/singleFeatureTests/ConstructorMethodCall.class b/src/test/resources/input/singleFeatureTests/ConstructorMethodCall.class deleted file mode 100644 index 009c42373cb5456168563ddc4036ca8f43968486..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 327 zcmZusyH3ME5S+E0m>ib}k2LA%z!KyKPzo#|MdDF_=+Djx92r}3&U_UO1t3xI0elo< z&QMb9+|J(4+|Aeb$0vX@OcerzF(Qo~`hv;YJehfEs{8qMwzjzw^iPYba0@|rcyy<* zg+UCZu?;PlrggP(O`E&AxwP(~UZtii1$ m=>)sP5kg`Q5d|7CdxrXx&Ukv;AbKVW{JysZ6mierVE+exEH=pi diff --git a/src/test/resources/input/singleFeatureTests/ConstructorMethodCallParameters.class b/src/test/resources/input/singleFeatureTests/ConstructorMethodCallParameters.class deleted file mode 100644 index 6c01775e5811edc75a952be0e4de8cb02bcaae7f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 356 zcmah^yH3ME5S+Cgn;ec4o&_nOph#RKKY%E(gk*`A1WJE)PTAu4YK(4kQ|nu0Ug~)w%kn{Lxl~5!h9Hb;%vK_Jqja2h`9u_=j{$)s zN4gbeOi4Xgg#JxYsk?TWDg7j~k~`wDZgsA%3tOE3V>+=v;EZh?{*gG?i_zh{gFVK5 zt|o9ddK9lfaXkD)@PXd@X5)Y{VjVp1!AB1P=lt>C?g_KK?F`=-33lFR1_a}wRdDnR D!^=R8 diff --git a/src/test/resources/input/singleFeatureTests/ConstructorParameter.class b/src/test/resources/input/singleFeatureTests/ConstructorParameter.class deleted file mode 100644 index eabb195ade30d8262acbc7736868b9210682e4a3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 226 zcmZusI|{-;5Pf5^Mq~UGHg?(>3%!6?CqFP1Pc$~p~OjQ=P~o< z&A@y<-`5+!94#LeI3C;p0#!oiBJXmN$n-qfMi&)ZLUpQBZD#~$7#=;;2;D`N-mJ-E zo0*+7@~W&d1TkE#!Xv?5WG6*vuXU<6`887JAftpU{yxi1td_bEy?;Z-#d`GN@l}Np eL!i#lXEk7Un8oM`dX()3$KnOBy9`25=FJ~72QDiB diff --git a/src/test/resources/input/singleFeatureTests/ConstructorThisDot.class b/src/test/resources/input/singleFeatureTests/ConstructorThisDot.class deleted file mode 100644 index 1a1c4c38599720fe9b6c9abdea71dad319ee7e12..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 256 zcmZWj%MQU%5IxgYt5wg9g^eX$@B?CjNSX)>Vt-pVT%k9q)_+-u#KH&oC^5CQm@{+E zyw3acd;yrC<-vgI!17UoO=uj&RSZue*$-FIQN|g;9;rlSV}jZ1Z(Wq(I`Di{;1gO? zom{dsk29Ta4(c+~yg-5@Bv`$$zvVR5J4vW7R3ex8Ig;r{L?>3fwa(L6&Q(F$|Ca`Z y7j*ff!Cr}xfBq_BvsG4V%mUVnz85?|LFW$V_M53Q)?hN0V8Mn9hc_C`4K%-pd@f=D diff --git a/src/test/resources/input/singleFeatureTests/DoWhile.class b/src/test/resources/input/singleFeatureTests/DoWhile.class deleted file mode 100644 index d7f8c194c4d92b228c0fd34d35d1e3abd3d67c37..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 250 zcmXYrJ#NB45QX2^#tV)OuF}v@28wV2l!8Pw{1uL%UOOu=0UIHc6L1lZkP0b94v-^J z1fCH)(i^>R=k3nl|IaUgKI$GU*b0u13S2?B(qFo}*4d&vjaMcq1a2?Q(&9y6KecBH zRe^fT=gV|$1kP*z!PXe1nVIZ2vDv-rxV#9WLMNYNy}f%c%J;j(3~nj^o_{VsLko&K zlt)bE24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00Sb_Nbc1}@j!f|5$-oW$Z{Mg|t={FGEi27aH+yi~u^+@#c^ki?`Mpa@rR zerZv1s#_+A!;jFS2eN`efq@-pGYBvOG0<)x%?V`50%@>_)^-NQjbLdmAPJHNDP?5f J2GUFnJOHXMBsTy6 diff --git a/src/test/resources/input/singleFeatureTests/EmptyClassWithConstructor.class b/src/test/resources/input/singleFeatureTests/EmptyClassWithConstructor.class deleted file mode 100644 index 664bf33beed4dcaa368c76f472c1260ce5efbe9a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 228 zcmZ`!!4APt5S-Ogig0z2^o9dJAPyQ%!hvvptruQXt-QWUe3p~M!3X##vF+VXcCxdR zY-T^-*BihbZ5I_-4(t}Hs1dr6xQR(DlG9`pL^3pl+EgXV%m~(CxOY$|^cI(^x%;um zvV$^bKTR^D^U$Q4VEgG&5;`lD$aQ`Rq~3`j=8d~ea~;a1Dn$S9g>ex89vse96frm% bbAy#vYM?rLf*z&qG8a#P+h!1&<=pxK$pSF# diff --git a/src/test/resources/input/singleFeatureTests/Field.class b/src/test/resources/input/singleFeatureTests/Field.class deleted file mode 100644 index e06f2cf103c1789c64fb00719460e1234458f36d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 200 zcmXX=I|{;35S-2LX^h4T2$pJLE+7^P0YS7->|c_Hybu!ziTAP+EIfdR688m*+1Z(4 z*!_H8ZvY#FJ}lS*P5>7kVVujmj0#y^qhpe*v>|vaUFv2{uxIm&K#$O(B2YNpJh_8JVB2x O4tSc_ln6s+3!@+I=peTM diff --git a/src/test/resources/input/singleFeatureTests/FieldWithAccessModifier.class b/src/test/resources/input/singleFeatureTests/FieldWithAccessModifier.class deleted file mode 100644 index a322f456660163581e52d48955bdb5799b09bb7f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 236 zcmZ{e%?`m(5QWd6N|oB#u&~2IUqB>Cnn?UC2nNDeP$bj?aS?VXqP@Lz1L>uN;y^_z9TM`L?nXz6&~TIt{jEw5 zBhQnk(>(UoPRWEof@?}BOk!UWteJ}B;(T;vvKDU07h@Hl6HhuS6U{$4{R{$a=*$Li gBFZp+8&k5buxfoAKP5}ZIDWP2mSReS0N%1a2@jvx9-m!Q`h3jvdpK@<~= zeza7C(#Q|hWWRM)JeTfPH`$D1B-Kh3XtOW$;?ajE6q(xEec6Y$^nY-2A3ozXZt1= zK>1w3`K3k4scxAdNp6UCJ&;uliVW;P7k~gG5CYu*Bsqb+P@pJCTvTg210#oxG{*u4 z&KAc1%Nf{O7#TMLC72kvfTR>q1BlJSzzk%uFmMBn5Cj@20yKmhD8t9V^dBg|#LmFZ N2vWz$zyns#3jlwFD`Wrw diff --git a/src/test/resources/input/singleFeatureTests/IfElseIfElse.class b/src/test/resources/input/singleFeatureTests/IfElseIfElse.class deleted file mode 100644 index 680b310cab6113151f97dcd998d86843760f9889..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 290 zcmYjL%TB^j6r9u6-cpLtjT=l*SL#B3fVhA_V&Y?gVSih%=3*@d3tzy8xMS_g#04MV zM+wvF!h4g+oH^&robR8n4S+uOLpX31ya;>n1+A%G>TagEfYI ex0vjJ35WFTP^ojG33tneqo4!`9R^0#Vq*u~{xWO; diff --git a/src/test/resources/input/singleFeatureTests/Increment.class b/src/test/resources/input/singleFeatureTests/Increment.class deleted file mode 100644 index 75faed58501bcdc4dc2deeb3a0cbc606d5fd7aaa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 350 zcmYjL%Syvg6r6LLHo0lq#s{LP3wLc7_6M{J1tH)ID%~gXBB^aEHT4VnCoWvO5W$5X z;QzQ0QRmhoa^al0=ggd$x38C100&t0p-^(+1Sq2-2nX?9+!@CCRp%@jn6wa7_Od)H zx`I-()z|Q#UHAd22n0IH(}@|GoIIy6w`>v-9*!@KpmCh#=5#tr%;X|YhMef^AHNy3 z`hr@oh|}wn_+~-zd*kUOHAk7{*Z=PC+F;nBy<%|M*Z@R|h{;)N{B6%SK)L-4d7KmL ztakk?Y9L%t&na~{-Dq#lM4sR}`&*%ZkE++5DS7yQw{it5U!#LP;_-#hSY}_R{}QJf O>Jz?v&|bK(l9eBg(mC${ diff --git a/src/test/resources/input/singleFeatureTests/MainMethod.class b/src/test/resources/input/singleFeatureTests/MainMethod.class deleted file mode 100644 index 0470c083d8f0041792c4ae9f2158848bbefb809e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 265 zcmZ9Gy$ZrW5QJw<+UZ!@S;)Cx9vZ8cMJn*dEHL5L!oZ72!$feYlQ~GARg^vC^uT5UijdIj9n9OQG~q z7Kbb)*t0B^1b?BlTwTtw%(o&wv16Z^BD90u;upFpa;5j9e#9x8?2;#Pt_WjK!DZFuOU4=8K{pm0#M``$c2S4-y+G&du=|hM3^e#zLh}QtM=oyw diff --git a/src/test/resources/input/singleFeatureTests/MultipleClasses.class b/src/test/resources/input/singleFeatureTests/MultipleClasses.class deleted file mode 100644 index 4585bf0309a0781a1a7b4e841df2df39cb83717c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 204 zcmX^0Z`VEs1_mbvUM>bE24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00Sb_Nbc27cetoRZ9foK)wW#Ny)AVnzlQ=lqmZpoC9mUaDVdZc=JdNMceB zP=qTuzqBYh)h!dm5kb?Z2eOPofq@<91`uEbVxTL4G$)WH3#7p!TH6^IH-e?PfFwv7 Oq?D0?8%Q%T@BjcwkSJ>a diff --git a/src/test/resources/input/singleFeatureTests/Null.class b/src/test/resources/input/singleFeatureTests/Null.class deleted file mode 100644 index 47a87ef6879c6b87b3646e09ec1003666d088f1d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 226 zcmW-bJr06U5QJy>6-2-rSSp1aKx3ha6~RJd|G*amK}ZOAFAHO0;Q>69aUaEQc4oiK z?)Ufp0N7&cLW6F@@L<9sgr&HPxDxd>K4hiLJA$Z02a^!eiKUtPI!V5EIj z5lAqWsCmWSuDM7;kQB8{`&%a4lgKJ|++)+Xx!e~@IEr4XYnXAS#@`SZrw$XTci5S* gig>GbZuA00^o0Ew7@xZjox2HxX$LlQ0c#E6A4iWPasU7T diff --git a/src/test/resources/input/singleFeatureTests/SelfReference.class b/src/test/resources/input/singleFeatureTests/SelfReference.class deleted file mode 100644 index 413157a7ba2c818270f0daae9225110cbac90597..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 466 zcmZ8e%Syvg5Ir|ZlQvD8Sl|4(j5!8p!(T*LL_l+H)@A>~&=n3SvTDcId?lt*+DOR7~8-1F#J#a!hK^x9PC-q6^Ok;~ZN5c7Gp2DiM;Cu_ iTily;=e?qOGeN`Od`5GO)*nm03~0(uS#e1;vHS@cn@I5h diff --git a/src/test/resources/input/singleFeatureTests/TestClass2.class b/src/test/resources/input/singleFeatureTests/TestClass2.class deleted file mode 100644 index 85b51363ba1e568002e8b72e1b88048e396b7e0f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 199 zcmW+wy9&ZU5S%kH(HPOfROjL$MX#H-|_b_Jm^)Tu5;1hd!QI%vWXa6Po(5ya-G zuhWcGBst~;Ym)61Az0{CEz3)y@{LT++;P`gneWt0SH!FL2Gu!q+0@{7*rBqmEB=Rh in_0wD;_OCGP-HzI?thKX=)+{RVX@kQU|qo6K==cXSR>{D diff --git a/src/test/resources/input/singleFeatureTests/VariableCalculation.class b/src/test/resources/input/singleFeatureTests/VariableCalculation.class deleted file mode 100644 index 131a2e6b75de3abf21e6521ad4ab0cea94218e30..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 723 zcmZ{g%TB^j5QhH)g>qFCFC^52CA!cTFvftFka$ZVEL=I16Fqt;T3h1d7-QnbjVluu zK7bEpoI_9%OOtk{GvEK8IrH)P_70$iQU)=^ZCE)ZkQ69f(ttKJdFLC)olEHk0?AF~ zsbEVWUR`b5NC_0%|FJ=nre=?{mj1W+R3P6B$h|tG>ydk!_I*jg zkV(<*O-S0Dm1*`v-<5mHOi+p#c-`C-71+E0^Q8IZ6@X9WY=xsRm9^Lu&pOpabq7FTSEy&t|SmkZ<~!QL}?$VXq~^>#VGCl6m4Z( KE3h;iYxxUZeqFBs diff --git a/src/test/resources/input/singleFeatureTests/VariableCompare.class b/src/test/resources/input/singleFeatureTests/VariableCompare.class deleted file mode 100644 index bf2b598420363d648239a9e90f5d6f4454e81cd4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 620 zcma*j!A^rf5C-6X3zkYzXp4z4ns`(X_63ZIHt9*_VAF%QrL0Or!K~1y^5V(FgAd?C z8E1&m(!EFmv&?=wv%8;P?;ijzvE!lz%Yp4-18sp|E|+qc$^2m$#d9?)1=?q6o|fkV z*3t3QK}W!!N}b9$Q=?+>B()N-M@2%xze;m;Q!QepCp<6Umby~cs(dVxy1<=4_g-et zzquZRi#(aExc*OWyb1^PGLnsKz%1_@_uHK4PZ+@F0J?PN2p}{W^?8zJ c#y8NF0UzS7WsQN>*V_9qe>Q`SE{g`*Z_&Oc*8l(j diff --git a/src/test/resources/input/singleFeatureTests/While.class b/src/test/resources/input/singleFeatureTests/While.class deleted file mode 100644 index 3fbdb4f503cb162e7e0a86cadb65fd33720b2cb8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 249 zcmX^0Z`VEs1_mbvJ}w3(24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00Sb_Nbc2G;P5%$!t41{UZ16d=X#lbM(5SDKrYS`?C)1d`wlE=f$z_Dw8+ z^0|WZON)|I-N3rIz`FH77BMI=umkM}0Y)GMx&TOW0(pKw8YC{HwVi=cfXhaD9s_3! z$1_ovZ79eB?>f{EJf|Gu(`o&&XhJn6C7MyHPG^Y};{>8xrM!Gjp3} z#>FwAx{XQjdr87Nj8&GgY_r7&&cv`Kry@bIESV*_gI$SxQk||}0H^&4dS4SOf<1!a3eH;k>t8#+V{($=?i5x(1qY7Z-P$~;m9Iaywb%~y^N~oa$`U82FSONe5 diff --git a/src/test/resources/input/typedAstFeatureTests/CallMethodFromObjekt.class b/src/test/resources/input/typedAstFeatureTests/CallMethodFromObjekt.class deleted file mode 100644 index 4fee59341e764ff0ae786b9ad56c3223cc8e5682..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 461 zcmZ`#!A`IN#DcdsT3o~DGtxgYxJ1;IQ% zxhcX%(SqZm1eZ|vR1gd~y^ChOI9h7Uy;zK?BD4nUnn#|B&m5Fdu~2ofi5j8tpO9eB zIUPSR&$97-A#VLRN&BHpA%QtBnlYg=@IxN0mJ^Pz)g%xmpZvI-akPr3-19ZrTsP=c zuS_V7I7x@BpGXL9KMXnc0+l2z(3D@}P Date: Thu, 4 Jul 2024 15:58:46 +0200 Subject: [PATCH 6/9] Add Class name to Memberaccesnode and identifier to assignable --- src/main/java/semantic/SemanticAnalyzer.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/semantic/SemanticAnalyzer.java b/src/main/java/semantic/SemanticAnalyzer.java index 732a6e6..7b6e2cb 100644 --- a/src/main/java/semantic/SemanticAnalyzer.java +++ b/src/main/java/semantic/SemanticAnalyzer.java @@ -253,6 +253,7 @@ public class SemanticAnalyzer implements SemanticVisitor { if (toCheck.memberAccess != null) { var result = toCheck.memberAccess.accept(this); + toCheck.identifier = toCheck.memberAccess.identifiers.getLast(); toCheck.setTypeNode(result.getType()); return result; } else { @@ -608,11 +609,15 @@ public class SemanticAnalyzer implements SemanticVisitor { ITypeNode currentType = null; int start = 0; if(!memberAccessNode.identifiers.isEmpty()){ - if(currentFields.get(memberAccessNode.identifiers.get(0)) != null){ - memberAccessNode.identifiers.add(0, currentClass.identifier); - start = 1; + if(currentFields.get(memberAccessNode.identifiers.getFirst()) != null){ + memberAccessNode.identifiers.addFirst(currentClass.identifier); + start++; } } + if(context.getClasses().get(memberAccessNode.identifiers.getFirst()) != null){ + memberAccessNode.identifiers.addFirst(currentClass.identifier); + start++; + } for (int i = start; i < memberAccessNode.identifiers.size(); i++) { String s = memberAccessNode.identifiers.get(i); From 2e3a7850a40815180326ddb80d5a15f6e8ba3c84 Mon Sep 17 00:00:00 2001 From: Bruder John Date: Thu, 4 Jul 2024 16:29:42 +0200 Subject: [PATCH 7/9] Fix Double Name --- src/main/java/semantic/SemanticAnalyzer.java | 2 +- .../typedAstFeatureTests/CorrectTest.java | 21 +++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/semantic/SemanticAnalyzer.java b/src/main/java/semantic/SemanticAnalyzer.java index 7b6e2cb..0a9e373 100644 --- a/src/main/java/semantic/SemanticAnalyzer.java +++ b/src/main/java/semantic/SemanticAnalyzer.java @@ -614,7 +614,7 @@ public class SemanticAnalyzer implements SemanticVisitor { start++; } } - if(context.getClasses().get(memberAccessNode.identifiers.getFirst()) != null){ + if(context.getClasses().get(memberAccessNode.identifiers.getFirst()) == null){ memberAccessNode.identifiers.addFirst(currentClass.identifier); start++; } diff --git a/src/test/resources/input/typedAstFeatureTests/CorrectTest.java b/src/test/resources/input/typedAstFeatureTests/CorrectTest.java index 53a8f3c..d5533fd 100644 --- a/src/test/resources/input/typedAstFeatureTests/CorrectTest.java +++ b/src/test/resources/input/typedAstFeatureTests/CorrectTest.java @@ -1,13 +1,16 @@ -public class Klasse1 { - public int test; - - public int test1() { - test = 5; - return 1; +public class Compiler { + Node node; + public int add(int i, int j) { + node = new Node(); + node.x = 1; + return i+j; } +} - public void test2() { - int testInt; - testInt = this.test1(); +public class Node { + public int x; + public void main() { + Compiler compiler = new Compiler(); + int i = compiler.add(5, 8); } } \ No newline at end of file From 9b8155ebab61ce6ad53930d7d3035e1ac584f491 Mon Sep 17 00:00:00 2001 From: Bruder John Date: Thu, 4 Jul 2024 16:31:45 +0200 Subject: [PATCH 8/9] added class identifier to member acces node --- src/main/java/semantic/SemanticAnalyzer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/semantic/SemanticAnalyzer.java b/src/main/java/semantic/SemanticAnalyzer.java index 0a9e373..8146052 100644 --- a/src/main/java/semantic/SemanticAnalyzer.java +++ b/src/main/java/semantic/SemanticAnalyzer.java @@ -635,7 +635,8 @@ public class SemanticAnalyzer implements SemanticVisitor { } else { if (currentType instanceof ReferenceType reference) { var currentTypeClass = context.getClass(reference.getIdentifier()); - + memberAccessNode.identifiers.add(i, reference.getIdentifier()); + i++; var currentField = currentTypeClass.getField(s); if (currentField.getAccessModifier().accessType == EnumAccessModifierNode.PUBLIC) { currentType = currentField.getType(); From 2f7b31025488a0bbad9254203c1846e54fb9ab37 Mon Sep 17 00:00:00 2001 From: Lucas <89882946+notbad3500@users.noreply.github.com> Date: Thu, 4 Jul 2024 16:49:14 +0200 Subject: [PATCH 9/9] refactoring, readme --- .gitignore | 6 +- readme.md | 38 +- src/main/java/main/Main.java | 28 +- ...penLogger.java => MiniCompilerLogger.java} | 10 +- src/test/Makefile | 12 +- src/test/java/main/E2EReflectionsTest.java | 1250 ++++++++--------- src/test/java/main/EndToEndTester.java | 2 - 7 files changed, 683 insertions(+), 663 deletions(-) rename src/main/java/main/{RaupenLogger.java => MiniCompilerLogger.java} (96%) diff --git a/.gitignore b/.gitignore index cb648af..5d19a24 100644 --- a/.gitignore +++ b/.gitignore @@ -77,10 +77,10 @@ fabric.properties .idea/caches/build_file_checksums.ser /target -src/main/resources/logs/RaupenLog.log +src/main/resources/logs/miniCompilerLog.log src/main/resources/output/CompilerInput.class src/test/resources/output/javac/CompilerInput$Test.class src/test/resources/output/javac/CompilerInput.class -src/test/resources/output/raupenpiler/CompilerInput.class -src/test/resources/output/raupenpiler/CompilerInput$Test.class +src/test/resources/output/miniCompiler/CompilerInput.class +src/test/resources/output/miniCompiler/CompilerInput$Test.class .idea/inspectionProfiles/Project_Default.xml diff --git a/readme.md b/readme.md index fc72bb8..8d2f771 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # "Nicht Haskel 2.0" Java Compiler -Realisation of a subset of the Java Standard Compiler in the course Compiler Construction of the 4th semester Computer Science at the Duale Hochschule Suttgart (Horb). +Realisation of a subset of the Java Standard Compiler in the course Compiler Construction of the 4th semester Computer Science at the Duale Hochschule Stuttgart (Horb). This project aims to provide a simplified version of the Java compiler, focusing on key language features and demonstrating the principles of compiler construction. @@ -62,7 +62,39 @@ test/ ## How to run the compiler +### Possibilities +### 1. Start miniCompiler using make: +Make needs to be installed +```bash +cd .\src\test\ ; make clean compile-miniCompiler +``` -## Download +### 2. Start miniCompiler using jar: +If you do not have the .jar, download it [here](https://gitea.hb.dhbw-stuttgart.de/i22005/NichtHaskell2.0/src/branch/Endabgabe/src) or compile it using mvn package or make first +``` +java.exe -DgenJar=bool -DgenClass=bool -jar path_to_jar\jarName.jar 'path_to_input_file.java' 'path_to_output_directory' +``` -```bash \ No newline at end of file +Example (jar needs to be in the target directory) +```bash + java.exe -DgenJar=true -DgenClass=true -jar .\target\JavaCompiler-1.0-jar-with-dependencies.jar 'src/main/resources/input/CompilerInput.java' 'src/main/resources/output' +``` + +- set DgenJar true, to generate the jar, false for no jar + +``` + DgenJar=true +``` + +- set DgenClass true, to generate class files, false for no class files + +``` + DgenClass=true + ``` + +## How to run tests + +```bash +mvn test +``` +Or start them manually in your IDE \ No newline at end of file diff --git a/src/main/java/main/Main.java b/src/main/java/main/Main.java index 5f1395b..a596fae 100644 --- a/src/main/java/main/Main.java +++ b/src/main/java/main/Main.java @@ -17,10 +17,10 @@ import java.util.Optional; /** - * Start Raupenpiler using make: + * Start miniCompiler using make: *

cd .\src\test\ - *

make clean compile-raupenpiler - *

Start Raupenpiler using jar: + *

make clean compile-miniCompiler + *

Start miniCompiler using jar: *

java.exe -DgenJar=true_OR_false -DgenClass=true_OR_false -jar path_to_jar\JavaCompiler-1.0-jar-with-dependencies.jar 'path_to_input_file.java' 'path_to_output_directory' *

Example (jar needs to be in the target directory, compile with make or mvn package first): * java.exe -DgenJar=true -DgenClass=true -jar .\target\JavaCompiler-1.0-jar-with-dependencies.jar 'src/main/resources/input/CompilerInput.java' 'src/main/resources/output' @@ -40,16 +40,6 @@ public class Main { System.err.println("Error reading the file: " + e.getMessage()); } } - /* !!! Else Branch (main ohne args starten) ist nicht zur Verwendung vorgesehen, immer mit args starten !!! - else { - try { - CharStream codeCharStream = CharStreams.fromPath(Paths.get("src/main/resources/input/CompilerInput.java")); - compileFile(codeCharStream); - } catch (IOException e) { - System.err.println("Error reading the file: " + e.getMessage()); - } - } - */ } /** @@ -66,7 +56,7 @@ public class Main { */ static void compileFile(CharStream inputCharStream, String outputDirectoryPath) { // Initialize the logger - new RaupenLogger(); + new MiniCompilerLogger(); /* ------------------------- Scanner -> tokens ------------------------- */ // Use the SimpleJavaLexer to tokenize the input CharStream @@ -74,27 +64,27 @@ public class Main { CommonTokenStream tokenStream = new CommonTokenStream(lexer); tokenStream.fill(); // Log the tokens - RaupenLogger.logScanner(tokenStream); + MiniCompilerLogger.logScanner(tokenStream); /*------------------------- Parser -> Parsetree -------------------------*/ // Use the SimpleJavaParser to parse the tokens and generate a ParseTree SimpleJavaParser parser = new SimpleJavaParser(tokenStream); ParseTree parseTree = parser.program(); // parse the input // Log the ParseTree - RaupenLogger.logParser(parseTree, parser); + MiniCompilerLogger.logParser(parseTree, parser); /*------------------------- AST builder -> AST -------------------------*/ // Use the ASTBuilder to visit the ParseTree and generate an Abstract Syntax Tree (AST) ASTBuilder astBuilder = new ASTBuilder(); ASTNode abstractSyntaxTree = astBuilder.visit(parseTree); // Log the AST - RaupenLogger.logAST(abstractSyntaxTree); + MiniCompilerLogger.logAST(abstractSyntaxTree); /*------------------------- Semantic Analyzer -> typed AST -------------------------*/ // Use the SemanticAnalyzer to generate a typed AST ASTNode typedAst = SemanticAnalyzer.generateTast(abstractSyntaxTree); // Log the typed AST - RaupenLogger.logSemanticAnalyzer(typedAst); + MiniCompilerLogger.logSemanticAnalyzer(typedAst); if(SemanticAnalyzer.errors.isEmpty()){ /*------------------------- Bytecode Generator -> Bytecode -------------------------*/ @@ -107,7 +97,7 @@ public class Main { assert typedAst != null; byteCodeGenerator.visit((ProgramNode) typedAst); // Log the bytecode generation - RaupenLogger.logBytecodeGenerator(); + MiniCompilerLogger.logBytecodeGenerator(); } else { for(Exception exception : SemanticAnalyzer.errors){ exception.printStackTrace(); diff --git a/src/main/java/main/RaupenLogger.java b/src/main/java/main/MiniCompilerLogger.java similarity index 96% rename from src/main/java/main/RaupenLogger.java rename to src/main/java/main/MiniCompilerLogger.java index 90bc7e2..f2314a1 100644 --- a/src/main/java/main/RaupenLogger.java +++ b/src/main/java/main/MiniCompilerLogger.java @@ -29,11 +29,11 @@ import java.util.logging.*; * consoleHandler.setLevel(Level.OFF); * fileHandler.setLevel(Level.ALL); */ -public class RaupenLogger { +public class MiniCompilerLogger { - static Logger logger = Logger.getLogger("RaupenLogs"); + static Logger logger = Logger.getLogger("miniCompilerLogs"); - public RaupenLogger() { + public MiniCompilerLogger() { // ------------------------- Logging ------------------------- logger.setLevel(Level.ALL); logger.getParent().getHandlers()[0].setLevel(Level.ALL); @@ -66,7 +66,7 @@ public class RaupenLogger { logger.addHandler(consoleHandler); // Configure file handler - Handler fileHandler = new FileHandler("src/main/resources/logs/RaupenLog.log"); + Handler fileHandler = new FileHandler("src/main/resources/logs/miniCompiler.log"); // Toggle file logging on/off fileHandler.setLevel(Level.ALL); fileHandler.setFormatter(new CustomFormatter()); @@ -117,7 +117,7 @@ public class RaupenLogger { public static void logBytecodeGenerator() { // Printing the bytecode logger.info("-------------------- Bytecode Generator -> Bytecode --------------------"); - logger.info("Bytecode generated"); + logger.info("Bytecode generated without errors."); logger.info("\n"); } diff --git a/src/test/Makefile b/src/test/Makefile index 54c905d..1fc9648 100644 --- a/src/test/Makefile +++ b/src/test/Makefile @@ -2,17 +2,17 @@ ### IntelliJs play buttons do not work. Run in "src/test" folder with "make" command to run all ### Or run only parts with "make compile-javac", "make clean" etc. -all: compile-javac compile-raupenpiler +all: compile-javac compile-miniCompiler compile-javac: javac -d .\resources\output\javac .\resources\input\CompilerInput.java -compile-raupenpiler: +compile-miniCompiler: cd ../.. ; mvn -DskipTests install cd ../.. ; mvn exec:java -DgenJar=true -DgenClass=true -Dexec.mainClass="main.Main" -Dexec.args="'src/main/resources/input/CompilerInput.java' 'src/main/resources/output'" - # cp ../main/resources/output/CompilerInput.class .java/resources/output/raupenpiler + # cp ../main/resources/output/CompilerInput.class .java/resources/output/miniCompiler -test-raupenpiler: +test-miniCompiler: # move the compiled class to the test/main folder mv ../main/resources/output/CompilerInput.class .java/main/ # compile the test class @@ -28,8 +28,8 @@ clean: rm -f ../main/resources/output/*.jar # clean resources output folders rm -f ./resources/output/javac/*.class - rm -f ./resources/output/raupenpiler/*.class - rm -f ./resources/output/raupenpiler/*.jar + rm -f ./resources/output/miniCompiler/*.class + rm -f ./resources/output/miniCompiler/*.jar # clean logs rm -f ../main/resources/logs/* # clean test/java/main folders from .class files for End-to-End tests diff --git a/src/test/java/main/E2EReflectionsTest.java b/src/test/java/main/E2EReflectionsTest.java index 78d479d..28c95ed 100644 --- a/src/test/java/main/E2EReflectionsTest.java +++ b/src/test/java/main/E2EReflectionsTest.java @@ -22,8 +22,8 @@ public class E2EReflectionsTest { public void CharTest() { final String FILE_NAME = "Char"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -37,28 +37,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -66,29 +66,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } @@ -104,8 +104,8 @@ public class E2EReflectionsTest { public void CommentsTest() { final String FILE_NAME = "Comments"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -119,28 +119,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -148,29 +148,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } @@ -186,8 +186,8 @@ public class E2EReflectionsTest { public void ConstructorMethodCallTest() { final String FILE_NAME = "ConstructorMethodCall"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -201,28 +201,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -230,29 +230,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } @@ -268,8 +268,8 @@ public class E2EReflectionsTest { public void ConstructorMethodCallParametersTest() { final String FILE_NAME = "ConstructorMethodCallParameters"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -283,28 +283,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -312,29 +312,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } @@ -350,8 +350,8 @@ public class E2EReflectionsTest { public void ConstructorParameterTest() { final String FILE_NAME = "ConstructorParameter"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -365,28 +365,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -394,29 +394,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } @@ -432,8 +432,8 @@ public class E2EReflectionsTest { public void ConstructorThisDotTest() { final String FILE_NAME = "ConstructorThisDot"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -447,28 +447,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -476,29 +476,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } @@ -514,8 +514,8 @@ public class E2EReflectionsTest { public void DoWhileTest() { final String FILE_NAME = "DoWhile"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -529,28 +529,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -558,29 +558,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } @@ -596,8 +596,8 @@ public class E2EReflectionsTest { public void EmptyClassTest() { final String FILE_NAME = "EmptyClass"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -611,28 +611,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -640,29 +640,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } @@ -678,8 +678,8 @@ public class E2EReflectionsTest { public void EmptyClassWithConstructorTest() { final String FILE_NAME = "EmptyClassWithConstructor"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -693,28 +693,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -722,29 +722,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } @@ -760,8 +760,8 @@ public class E2EReflectionsTest { public void FieldTest() { final String FILE_NAME = "Field"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -775,28 +775,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -804,29 +804,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } @@ -842,8 +842,8 @@ public class E2EReflectionsTest { public void FieldWithAccessModifierTest() { final String FILE_NAME = "FieldWithAccessModifier"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -857,28 +857,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -886,29 +886,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } @@ -924,8 +924,8 @@ public class E2EReflectionsTest { public void ForTest() { final String FILE_NAME = "For"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -939,28 +939,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -968,29 +968,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } @@ -1007,8 +1007,8 @@ public class E2EReflectionsTest { public void IfTest() { final String FILE_NAME = "If"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -1022,28 +1022,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -1051,29 +1051,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } @@ -1088,8 +1088,8 @@ public class E2EReflectionsTest { public void IfElseTest() { final String FILE_NAME = "IfElse"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -1103,28 +1103,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -1132,29 +1132,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } @@ -1169,8 +1169,8 @@ public class E2EReflectionsTest { public void IfElseIfElseTest() { final String FILE_NAME = "IfElseIfElse"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -1184,28 +1184,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -1213,29 +1213,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } @@ -1250,8 +1250,8 @@ public class E2EReflectionsTest { public void IncrementTest() { final String FILE_NAME = "Increment"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -1265,28 +1265,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -1294,29 +1294,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } @@ -1331,8 +1331,8 @@ public class E2EReflectionsTest { public void MainMethodTest() { final String FILE_NAME = "MainMethod"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -1346,28 +1346,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -1375,29 +1375,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } @@ -1412,8 +1412,8 @@ public class E2EReflectionsTest { public void MultipleClassesTest() { final String FILE_NAME = "MultipleClasses"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -1427,28 +1427,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -1456,29 +1456,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } @@ -1493,8 +1493,8 @@ public class E2EReflectionsTest { public void NullTest() { final String FILE_NAME = "Null"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -1508,28 +1508,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -1537,29 +1537,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } @@ -1574,8 +1574,8 @@ public class E2EReflectionsTest { public void SelfReferenceTest() { final String FILE_NAME = "SelfReference"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -1589,28 +1589,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -1618,29 +1618,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } @@ -1655,8 +1655,8 @@ public class E2EReflectionsTest { public void ThisDotTest() { final String FILE_NAME = "ThisDot"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -1670,28 +1670,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -1699,29 +1699,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } @@ -1736,8 +1736,8 @@ public class E2EReflectionsTest { public void VariableCalculationTest() { final String FILE_NAME = "VariableCalculation"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -1751,28 +1751,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -1780,29 +1780,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } @@ -1817,8 +1817,8 @@ public class E2EReflectionsTest { public void VariableCompareTest() { final String FILE_NAME = "VariableCompare"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -1832,28 +1832,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -1861,29 +1861,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } @@ -1898,8 +1898,8 @@ public class E2EReflectionsTest { public void VoidMethodTest() { final String FILE_NAME = "VoidMethod"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -1913,28 +1913,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -1942,29 +1942,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } @@ -1979,8 +1979,8 @@ public class E2EReflectionsTest { public void WhileTest() { final String FILE_NAME = "While"; try { - // compile with raupenpiler - Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/raupenpiler"}); + // compile with miniCompiler + Main.main(new String[]{"src/test/resources/input/singleFeatureTests/" + FILE_NAME + ".java", "src/test/resources/output/miniCompiler"}); // Get the system Java compiler JavaCompiler javac = ToolProvider.getSystemJavaCompiler(); // Assert that the compiler is available @@ -1994,28 +1994,28 @@ public class E2EReflectionsTest { ClassLoader javacClassLoader = new java.net.URLClassLoader(new java.net.URL[]{javacClassPath.toUri().toURL()}); Class javacLoadedClass = javacClassLoader.loadClass(FILE_NAME); - // Load the raupenpiler class - Path raupenpilerClassPath = Paths.get("src/test/resources/output/raupenpiler"); - ClassLoader raupenpilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{raupenpilerClassPath.toUri().toURL()}); - Class raupenpilerLoadedClass = raupenpilerClassLoader.loadClass(FILE_NAME); + // Load the miniCompiler class + Path miniCompilerClassPath = Paths.get("src/test/resources/output/miniCompiler"); + ClassLoader miniCompilerClassLoader = new java.net.URLClassLoader(new java.net.URL[]{miniCompilerClassPath.toUri().toURL()}); + Class miniCompilerLoadedClass = miniCompilerClassLoader.loadClass(FILE_NAME); // Class Name assertEquals(FILE_NAME, javacLoadedClass.getName()); - assertEquals(FILE_NAME, raupenpilerLoadedClass.getName()); + assertEquals(FILE_NAME, miniCompilerLoadedClass.getName()); // Constructors Constructor[] javacConstructors = javacLoadedClass.getDeclaredConstructors(); - Constructor[] raupenpilerConstructors = raupenpilerLoadedClass.getDeclaredConstructors(); + Constructor[] miniCompilerConstructors = miniCompilerLoadedClass.getDeclaredConstructors(); - assertEquals(javacConstructors.length, raupenpilerConstructors.length); + assertEquals(javacConstructors.length, miniCompilerConstructors.length); for(Constructor c : javacConstructors) { - for(Constructor raupenpilerConstructor : raupenpilerConstructors) { - assertEquals(c.getParameterCount(), raupenpilerConstructor.getParameterCount()); - if (c.getParameterCount() == raupenpilerConstructor.getParameterCount()) { - assertEquals(c.getName(), raupenpilerConstructor.getName()); + for(Constructor miniCompilerConstructor : miniCompilerConstructors) { + assertEquals(c.getParameterCount(), miniCompilerConstructor.getParameterCount()); + if (c.getParameterCount() == miniCompilerConstructor.getParameterCount()) { + assertEquals(c.getName(), miniCompilerConstructor.getName()); } } } @@ -2023,29 +2023,29 @@ public class E2EReflectionsTest { // Methods Method[] javacMethods = javacLoadedClass.getDeclaredMethods(); - Method[] raupenpilerMethods = raupenpilerLoadedClass.getDeclaredMethods(); + Method[] miniCompilerMethods = miniCompilerLoadedClass.getDeclaredMethods(); - assertEquals(javacMethods.length, raupenpilerMethods.length); + assertEquals(javacMethods.length, miniCompilerMethods.length); for (int i = 0; i < javacMethods.length; i++) { - assertEquals(javacMethods[i].getName(), raupenpilerMethods[i].getName()); - assertEquals(javacMethods[i].getReturnType(), raupenpilerMethods[i].getReturnType()); - assertEquals(javacMethods[i].getParameterCount(), raupenpilerMethods[i].getParameterCount()); - // assertEquals(javacMethods[i].getModifiers(), raupenpilerMethods[i].getModifiers()); + assertEquals(javacMethods[i].getName(), miniCompilerMethods[i].getName()); + assertEquals(javacMethods[i].getReturnType(), miniCompilerMethods[i].getReturnType()); + assertEquals(javacMethods[i].getParameterCount(), miniCompilerMethods[i].getParameterCount()); + // assertEquals(javacMethods[i].getModifiers(), miniCompilerMethods[i].getModifiers()); } // Fields Field[] javacLoadedClassDeclaredFields = javacLoadedClass.getDeclaredFields(); - Field[] raupenpilerLoadedClassDeclaredFields = raupenpilerLoadedClass.getDeclaredFields(); + Field[] miniCompilerLoadedClassDeclaredFields = miniCompilerLoadedClass.getDeclaredFields(); - assertEquals(javacLoadedClassDeclaredFields.length, raupenpilerLoadedClassDeclaredFields.length); + assertEquals(javacLoadedClassDeclaredFields.length, miniCompilerLoadedClassDeclaredFields.length); for (Field field : javacLoadedClassDeclaredFields) { - for (Field raupenpilerField : raupenpilerLoadedClassDeclaredFields) { - if (field.getName().equals(raupenpilerField.getName())) { - assertEquals(field.getType(), raupenpilerField.getType()); - // assertEquals(field.getModifiers(), raupenpilerField.getModifiers()); + for (Field miniCompilerField : miniCompilerLoadedClassDeclaredFields) { + if (field.getName().equals(miniCompilerField.getName())) { + assertEquals(field.getType(), miniCompilerField.getType()); + // assertEquals(field.getModifiers(), miniCompilerField.getModifiers()); } } } diff --git a/src/test/java/main/EndToEndTester.java b/src/test/java/main/EndToEndTester.java index 233a9c3..d7e40ef 100644 --- a/src/test/java/main/EndToEndTester.java +++ b/src/test/java/main/EndToEndTester.java @@ -11,8 +11,6 @@ package main; * Wenn unser Compiler funktioniert, sollten keine Errors kommen (sondern nur die Ausgaben, die wir in der CompilerInput.java Datei gemacht haben, * oder Methoden, die wir hier aufrufen).

* - *

PROBLEM: Hier kommen Errors, was eigentlich heißt, dass der Compiler nicht funktioniert, der Test sollte eigentlich passen. - *
DENN: Wenn ich statt unserem CompilerInput.class die CompilerInput.class von javac verwende (aus src/test/resources/output/javac ), dann funktioniert es.

*/ public class EndToEndTester { public static void main(String[] args) {