Package de.monticore.runtime.junit
Class PrettyPrinterTester
java.lang.Object
de.monticore.runtime.junit.PrettyPrinterTester
Offers functions to test pretty printers
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacePrettyPrinterTester.ParseFunction<N extends de.monticore.ast.ASTNode>Represents the function that parses a String. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <N extends de.monticore.ast.ASTNode>
voidtestPrettyPrinter(String model, de.monticore.antlr4.MCConcreteParser parser, PrettyPrinterTester.ParseFunction<N> parseFunc, Function<N, String> prettyPrintFunc) Tests pretty printing.static <N extends de.monticore.ast.ASTNode>
voidtestPrettyPrinter(String model, de.monticore.antlr4.MCConcreteParser parser, PrettyPrinterTester.ParseFunction<N> parseFunc, Function<N, String> prettyPrintFunc, Predicate<String> additionalCheck) Tests pretty printing.
-
Constructor Details
-
PrettyPrinterTester
public PrettyPrinterTester()
-
-
Method Details
-
testPrettyPrinter
public static <N extends de.monticore.ast.ASTNode> void testPrettyPrinter(String model, de.monticore.antlr4.MCConcreteParser parser, PrettyPrinterTester.ParseFunction<N> parseFunc, Function<N, String> prettyPrintFunc, Predicate<String> additionalCheck) Tests pretty printing. The Model is parsed, pretty printed and parsed again. The AST of the pretty printed model is expected to be comparable to the AST of the original model.- Type Parameters:
N- the type of the ASTNode after parsing- Parameters:
model- the model to be pretty printedparser- the parser used to convert the model to an ASTparseFunc- the concrete parse function used, e.g.,myParser::parse_StringMyNonTerminalprettyPrintFunc- the actual pretty printing operation, e.g.,ast -> MyMill.prettyPrint(ast, true)additionalCheck- additional check on the pretty printed String
-
testPrettyPrinter
public static <N extends de.monticore.ast.ASTNode> void testPrettyPrinter(String model, de.monticore.antlr4.MCConcreteParser parser, PrettyPrinterTester.ParseFunction<N> parseFunc, Function<N, String> prettyPrintFunc) Tests pretty printing. The Model is parsed, pretty printed and parsed again. The AST of the pretty printed model is expected to be comparable to the AST of the original model.- Type Parameters:
N- the type of the ASTNode after parsing- Parameters:
model- the model to be pretty printedparser- the parser used to convert the model to an ASTparseFunc- the concrete parse function used, e.g.,myParser::parse_StringMyNonTerminalprettyPrintFunc- the actual pretty printing operation, e.g.,ast -> MyMill.prettyPrint(ast, true)
-