mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-26 17:18:04 +00:00
added scanner parser test for ClassCanBeBytecoded
This commit is contained in:
parent
93279743f2
commit
43a05c761a
@ -0,0 +1,90 @@
|
||||
package MoreTestResources.AST;
|
||||
|
||||
import de.maishai.ast.records.Class;
|
||||
import de.maishai.ast.records.*;
|
||||
import de.maishai.typedast.Type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AbstractSyntax_ClassCanBeBytecoded {
|
||||
public static Program get() {
|
||||
List<Declaration> declarations = List.of(
|
||||
new Declaration(
|
||||
"c",
|
||||
Type.REFERENCE("ClassCanBeBytecoded")
|
||||
),
|
||||
new Declaration(
|
||||
"x",
|
||||
Type.INT
|
||||
)
|
||||
);
|
||||
List<Method> methods = getMethods();
|
||||
List<Constructor> constructors = getConstructors();
|
||||
return new Program(
|
||||
List.of(
|
||||
new Class(
|
||||
"ClassCanBeBytecoded",
|
||||
null,
|
||||
declarations,
|
||||
methods,
|
||||
constructors
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private static List<Constructor> getConstructors() {
|
||||
return List.of(getConstructor1());
|
||||
}
|
||||
|
||||
private static Constructor getConstructor1() {
|
||||
List<Parameter> parameters = List.of();
|
||||
List<Statement> statementList = List.of();
|
||||
Block block = new Block(
|
||||
statementList
|
||||
);
|
||||
return new Constructor(
|
||||
"ClassCanBeBytecoded",
|
||||
parameters,
|
||||
block
|
||||
);
|
||||
}
|
||||
|
||||
private static List<Method> getMethods() {
|
||||
return List.of(getMethod1());
|
||||
}
|
||||
|
||||
private static Method getMethod1() {
|
||||
List<Parameter> parameters = List.of(
|
||||
new Parameter(
|
||||
"var1",
|
||||
Type.INT
|
||||
)
|
||||
);
|
||||
List<Statement> statementList = List.of(
|
||||
new Print(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"var1"
|
||||
)
|
||||
),
|
||||
new Return(
|
||||
new FieldVarAccess(
|
||||
false,
|
||||
null,
|
||||
"var1"
|
||||
)
|
||||
)
|
||||
);
|
||||
Block block = new Block(
|
||||
statementList
|
||||
);
|
||||
return new Method(
|
||||
Type.INT,
|
||||
"test",
|
||||
parameters,
|
||||
block
|
||||
);
|
||||
}
|
||||
}
|
@ -179,15 +179,9 @@ class ScannerParserTests {
|
||||
// -> Corresponding Test files in src/test/testFiles/MoreTestFiles
|
||||
|
||||
@Test
|
||||
void testPublicClass() {
|
||||
Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/MoreTestFiles/PublicClass.java"));
|
||||
assertEquals(AbstractSyntax_PublicClass.get(), resultAst);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassWithField() {
|
||||
Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/MoreTestFiles/ClassWithField.java"));
|
||||
assertEquals(AbstractSyntax_ClassWithField.get(), resultAst);
|
||||
void testClassCanBeBytecoded() {
|
||||
Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/MoreTestFiles/ClassCanBeBytecoded.java"));
|
||||
assertEquals(AbstractSyntax_ClassCanBeBytecoded.get(), resultAst);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -197,9 +191,9 @@ class ScannerParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassWithMethod() {
|
||||
Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/MoreTestFiles/ClassWithMethod.java"));
|
||||
assertEquals(AbstractSyntax_ClassWithMethod.get(), resultAst);
|
||||
void testClassWithConstructorAndMethodCall() {
|
||||
Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/MoreTestFiles/ClassWithConstructorAndMethodCall.java"));
|
||||
assertEquals(AbstractSyntax_ClassWithConstructorAndMethodCall.get(), resultAst);
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -214,22 +208,33 @@ class ScannerParserTests {
|
||||
assertEquals(AbstractSyntax_ClassWithConstructorWithParameters.get(), resultAst);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassWithField() {
|
||||
Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/MoreTestFiles/ClassWithField.java"));
|
||||
assertEquals(AbstractSyntax_ClassWithField.get(), resultAst);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassWithMethod() {
|
||||
Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/MoreTestFiles/ClassWithMethod.java"));
|
||||
assertEquals(AbstractSyntax_ClassWithMethod.get(), resultAst);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassWithMethodAndField() {
|
||||
Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/MoreTestFiles/ClassWithMethodAndField.java"));
|
||||
assertEquals(AbstractSyntax_ClassWithMethodAndField.get(), resultAst);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testClassWithConstructorAndMethodCall() {
|
||||
Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/MoreTestFiles/ClassWithConstructorAndMethodCall.java"));
|
||||
assertEquals(AbstractSyntax_ClassWithConstructorAndMethodCall.get(), resultAst);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testComplexClass() {
|
||||
Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/MoreTestFiles/ComplexClass.java"));
|
||||
assertEquals(AbstractSyntax_ComplexClass.get(), resultAst);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPublicClass() {
|
||||
Program resultAst = Compiler.generateASTFromFiles(List.of("src/test/testFiles/MoreTestFiles/PublicClass.java"));
|
||||
assertEquals(AbstractSyntax_PublicClass.get(), resultAst);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user