Skip to content

Commit

Permalink
Merge e3e59af into c87e07f
Browse files Browse the repository at this point in the history
  • Loading branch information
MysterAitch authored May 23, 2020
2 parents c87e07f + e3e59af commit 2f97c70
Show file tree
Hide file tree
Showing 32 changed files with 779 additions and 186 deletions.
22 changes: 19 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
version: '{build}'
os: Windows Server 2012

environment:
appveyor_build_worker_cloud: gce

init:
# Setup autocrlf -- by default, appveyor uses autocrlf input
# ... This affects tests which expect resource files to have the systems's line separator.
- git config --global core.autocrlf true

install:
# Download maven
- ps: |
Add-Type -AssemblyName System.IO.Compression.FileSystem
if (!(Test-Path -Path "C:\maven" )) {
Expand All @@ -12,15 +20,23 @@ install:
)
[System.IO.Compression.ZipFile]::ExtractToDirectory("C:\maven-bin.zip", "C:\maven")
}
- cmd: SET PATH=C:\maven\apache-maven-3.6.3\bin;%JAVA_HOME%\bin;%PATH%
# Setup environment variables for Maven and Java
- cmd: SET JAVA_HOME=C:\Program Files\Java\jdk10
- cmd: SET M2_HOME=C:\maven\apache-maven-3.6.3
- cmd: SET MAVEN_OPTS=-Xmx1g
- cmd: SET JAVA_OPTS=-Xmx1g
- cmd: SET M2_HOME=C:\maven\apache-maven-3.6.3
- cmd: SET JAVA_HOME=C:\Program Files\Java\jdk10
- cmd: SET PATH=C:\maven\apache-maven-3.6.3\bin;%JAVA_HOME%\bin;%PATH%
# Output the git config re: autocrlf to verify the "current" setting
- cmd: git config core.autocrlf

# Appveyor is used for testing only -- the build script is not required.
build_script:
- echo ignore this

test_script:
- mvn -B clean install --batch-mode

# Use of the cache speeds up future tests, meaning that dependencies do not need to be re-downloaded on every run.
cache:
- C:\maven\
- C:\Users\appveyor\.m2
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import static com.github.javaparser.StaticJavaParser.parse;
import static com.github.javaparser.StaticJavaParser.parseResource;
import static com.github.javaparser.utils.TestUtils.assertEqualToTextResource;
import static com.github.javaparser.utils.TestUtils.assertEqualsNoEol;
import static com.github.javaparser.utils.TestUtils.assertEqualsStringIgnoringEol;
import static com.github.javaparser.utils.Utils.EOL;
import static org.junit.jupiter.api.Assertions.assertEquals;

Expand Down Expand Up @@ -75,7 +75,7 @@ void issue200EnumConstantsWithCommentsForceVerticalAlignment() {
" /** const2 javadoc */" + EOL +
" ANOTHER_CONSTANT" + EOL +
"}");
assertEqualsNoEol("public enum X {\n" +
assertEqualsStringIgnoringEol("public enum X {\n" +
"\n" +
" /**\n" +
" * const1 javadoc\n" +
Expand All @@ -99,7 +99,7 @@ void issue234LosingCommentsInArrayInitializerExpr() {
"" + EOL +
"}");

assertEqualsNoEol("@Anno(stuff = {// Just,\n" +
assertEqualsStringIgnoringEol("@Anno(stuff = {// Just,\n" +
"// an,\n" +
"// example\n" +
"})\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.junit.jupiter.api.Test;

import static com.github.javaparser.StaticJavaParser.parse;
import static com.github.javaparser.utils.TestUtils.assertEqualsNoEol;
import static com.github.javaparser.utils.TestUtils.assertEqualsStringIgnoringEol;
import static com.github.javaparser.utils.Utils.EOL;
import static org.junit.jupiter.api.Assertions.*;

Expand Down Expand Up @@ -97,7 +97,7 @@ void testReplaceDuplicateJavaDocComment() {
methodDeclaration.setJavadocComment("", javadoc);

// Assert
assertEqualsNoEol("public class MyClass {\n" +
assertEqualsStringIgnoringEol("public class MyClass {\n" +
"\n" +
" /**\n" +
" * Change Javadoc\n" +
Expand Down Expand Up @@ -138,7 +138,7 @@ void testRemoveDuplicateComment() {
methodDeclaration.removeComment();

// Assert
assertEqualsNoEol("public class MyClass {\n" +
assertEqualsStringIgnoringEol("public class MyClass {\n" +
"\n" +
" public void oneMethod() {\n" +
" }\n" +
Expand Down Expand Up @@ -176,7 +176,7 @@ void testRemoveDuplicateJavaDocComment() {
methodDeclaration.removeJavaDocComment();

// Assert
assertEqualsNoEol("public class MyClass {\n" +
assertEqualsStringIgnoringEol("public class MyClass {\n" +
"\n" +
" /**\n" +
" * Comment A\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

import static com.github.javaparser.StaticJavaParser.parseBlock;
import static com.github.javaparser.StaticJavaParser.parseExpression;
import static com.github.javaparser.utils.TestUtils.assertEqualsNoEol;
import static com.github.javaparser.utils.TestUtils.assertEqualsStringIgnoringEol;
import static org.junit.jupiter.api.Assertions.assertEquals;

class LambdaExprTest {
Expand Down Expand Up @@ -73,7 +73,7 @@ void oneParameterAndExpressionUtilityConstructor() {
@Test
void oneParameterAndStatementUtilityConstructor() {
LambdaExpr expr = new LambdaExpr(new Parameter(new UnknownType(), "a"), parseBlock("{return 5;}"));
assertEqualsNoEol("a -> {\n return 5;\n}", expr.toString());
assertEqualsStringIgnoringEol("a -> {\n return 5;\n}", expr.toString());
}

@Test
Expand All @@ -85,13 +85,13 @@ void multipleParametersAndExpressionUtilityConstructor() {
@Test
void multipleParametersAndStatementUtilityConstructor() {
LambdaExpr expr = new LambdaExpr(new NodeList<>(new Parameter(new UnknownType(), "a"), new Parameter(new UnknownType(), "b")), parseBlock("{return 5;}"));
assertEqualsNoEol("(a, b) -> {\n return 5;\n}", expr.toString());
assertEqualsStringIgnoringEol("(a, b) -> {\n return 5;\n}", expr.toString());
}

@Test
void zeroParametersAndStatementUtilityConstructor() {
LambdaExpr expr = new LambdaExpr(new NodeList<>(), parseBlock("{return 5;}"));
assertEqualsNoEol("() -> {\n return 5;\n}", expr.toString());
assertEqualsStringIgnoringEol("() -> {\n return 5;\n}", expr.toString());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import static com.github.javaparser.ParserConfiguration.LanguageLevel.JAVA_12;
import static com.github.javaparser.utils.TestParser.parseCompilationUnit;
import static com.github.javaparser.utils.TestParser.parseStatement;
import static com.github.javaparser.utils.TestUtils.assertEqualsNoEol;
import static com.github.javaparser.utils.TestUtils.assertEqualsStringIgnoringEol;
import static org.junit.jupiter.api.Assertions.assertEquals;

class YieldStmtTest {
Expand All @@ -46,7 +46,7 @@ void threadYieldShouldNotBreak() {
@Test
void keywordShouldNotInterfereWithIdentifiers() {
CompilationUnit compilationUnit = parseCompilationUnit(JAVA_12, "class yield { yield yield(yield yield){yield();} }");
assertEqualsNoEol("class yield {\n" +
assertEqualsStringIgnoringEol("class yield {\n" +
"\n" +
" yield yield(yield yield) {\n" +
" yield();\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

import static com.github.javaparser.StaticJavaParser.parse;
import static com.github.javaparser.StaticJavaParser.parseExpression;
import static com.github.javaparser.utils.TestUtils.assertEqualsNoEol;
import static com.github.javaparser.utils.TestUtils.assertEqualsStringIgnoringEol;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;

Expand Down Expand Up @@ -130,11 +130,11 @@ void parents() {
Node.ParentsVisitor visitor = new Node.ParentsVisitor(x);
assertEquals("x = 1", visitor.next().toString());
assertEquals("int x = 1;", visitor.next().toString());
assertEqualsNoEol("class X {\n" +
assertEqualsStringIgnoringEol("class X {\n" +
"\n" +
" int x = 1;\n" +
"}", visitor.next().toString());
assertEqualsNoEol("class X {\n" +
assertEqualsStringIgnoringEol("class X {\n" +
"\n" +
" int x = 1;\n" +
"}\n", visitor.next().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import static com.github.javaparser.ParserConfiguration.LanguageLevel.JAVA_9;
import static com.github.javaparser.Providers.provider;
import static com.github.javaparser.StaticJavaParser.parseName;
import static com.github.javaparser.utils.TestUtils.assertEqualsNoEol;
import static com.github.javaparser.utils.TestUtils.assertEqualsStringIgnoringEol;
import static com.github.javaparser.utils.Utils.EOL;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
Expand Down Expand Up @@ -228,7 +228,7 @@ void fluentInterface() {
.addModuleName("other.bar")
);

assertEqualsNoEol("@SuppressWarnings(\"module\")\n" +
assertEqualsStringIgnoringEol("@SuppressWarnings(\"module\")\n" +
"module com.laamella.base {\n" +
" requires transitive java.desktop;\n" +
" exports com.laamella.base.entity.channel;\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

import static com.github.javaparser.StaticJavaParser.parse;
import static com.github.javaparser.StaticJavaParser.parseExpression;
import static com.github.javaparser.utils.TestUtils.assertEqualsNoEol;
import static com.github.javaparser.utils.TestUtils.assertEqualsStringIgnoringEol;
import static org.junit.jupiter.api.Assertions.assertEquals;

class DotPrinterTest {
Expand Down Expand Up @@ -84,7 +84,7 @@ void testIssue1871() {
DotPrinter printer = new DotPrinter(false);
CompilationUnit cu = parse("//q\"q\nclass X{}");
String output = printer.output(cu);
assertEqualsNoEol("digraph {\n" +
assertEqualsStringIgnoringEol("digraph {\n" +
"n0 [label=\"root\"];\n" +
"n1 [label=\"types\"];\n" +
"n0 -> n1;\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

import static com.github.javaparser.StaticJavaParser.parse;
import static com.github.javaparser.utils.TestParser.*;
import static com.github.javaparser.utils.TestUtils.assertEqualsNoEol;
import static com.github.javaparser.utils.TestUtils.assertEqualsStringIgnoringEol;
import static com.github.javaparser.utils.Utils.EOL;
import static org.junit.jupiter.api.Assertions.assertEquals;

Expand Down Expand Up @@ -233,7 +233,7 @@ void printImportsDefaultOrder() {
String code = "import x.y.z;import a.b.c;import static b.c.d;class c {}";
CompilationUnit cu = parse(code);
String content = cu.toString();
assertEqualsNoEol("import x.y.z;\n" +
assertEqualsStringIgnoringEol("import x.y.z;\n" +
"import a.b.c;\n" +
"import static b.c.d;\n" +
"\n" +
Expand All @@ -247,7 +247,7 @@ void printImportsOrdered() {
CompilationUnit cu = parse(code);
PrettyPrinterConfiguration orderImports = new PrettyPrinterConfiguration().setOrderImports(true);
String content = cu.toString(orderImports);
assertEqualsNoEol("import static b.c.d;\n" +
assertEqualsStringIgnoringEol("import static b.c.d;\n" +
"import a.b.c;\n" +
"import x.y.z;\n" +
"\n" +
Expand All @@ -260,7 +260,7 @@ void multilineJavadocGetsFormatted() {
CompilationUnit cu = new CompilationUnit();
cu.addClass("X").addMethod("abc").setJavadocComment("line1\n line2 *\n * line3");

assertEqualsNoEol("public class X {\n" +
assertEqualsStringIgnoringEol("public class X {\n" +
"\n" +
" /**\n" +
" * line1\n" +
Expand All @@ -277,7 +277,7 @@ void emptyJavadocGetsFormatted() {
CompilationUnit cu = new CompilationUnit();
cu.addClass("X").addMethod("abc").setJavadocComment("");

assertEqualsNoEol("public class X {\n" +
assertEqualsStringIgnoringEol("public class X {\n" +
"\n" +
" /**\n" +
" */\n" +
Expand All @@ -291,7 +291,7 @@ void multilineJavadocWithLotsOfEmptyLinesGetsFormattedNeatly() {
CompilationUnit cu = new CompilationUnit();
cu.addClass("X").addMethod("abc").setJavadocComment("\n\n\n ab\n\n\n cd\n\n\n");

assertEqualsNoEol("public class X {\n" +
assertEqualsStringIgnoringEol("public class X {\n" +
"\n" +
" /**\n" +
" * ab\n" +
Expand All @@ -308,7 +308,7 @@ void singlelineJavadocGetsFormatted() {
CompilationUnit cu = new CompilationUnit();
cu.addClass("X").addMethod("abc").setJavadocComment("line1");

assertEqualsNoEol("public class X {\n" +
assertEqualsStringIgnoringEol("public class X {\n" +
"\n" +
" /**\n" +
" * line1\n" +
Expand All @@ -323,7 +323,7 @@ void javadocAlwaysGetsASpaceBetweenTheAsteriskAndTheRestOfTheLine() {
CompilationUnit cu = new CompilationUnit();
cu.addClass("X").addMethod("abc").setJavadocComment("line1\nline2");

assertEqualsNoEol("public class X {\n" +
assertEqualsStringIgnoringEol("public class X {\n" +
"\n" +
" /**\n" +
" * line1\n" +
Expand All @@ -341,7 +341,7 @@ void javadocAlwaysGetsAnAdditionalSpaceOrNeverGetsIt() {
"line2\n" +
" 3");

assertEqualsNoEol("public class X {\n" +
assertEqualsStringIgnoringEol("public class X {\n" +
"\n" +
" /**\n" +
" * line1\n" +
Expand All @@ -358,7 +358,7 @@ void singlelineCommentGetsFormatted() {
CompilationUnit cu = new CompilationUnit();
cu.addClass("X").addMethod("abc").setComment(new LineComment(" line1 \n "));

assertEqualsNoEol("public class X {\n" +
assertEqualsStringIgnoringEol("public class X {\n" +
"\n" +
" // line1\n" +
" void abc() {\n" +
Expand All @@ -378,7 +378,7 @@ void blockcommentGetsNoFormatting() {
" }\n" +
"}\n");

assertEqualsNoEol("class A {\n" +
assertEqualsStringIgnoringEol("class A {\n" +
"\n" +
" public void helloWorld(String greeting, String name) {\n" +
" // sdfsdfsdf\n" +
Expand Down Expand Up @@ -416,7 +416,7 @@ void javadocIssue1907_allLeadingSpaces() {
"public void add(int x, int y){}}";

CompilationUnit cu_allLeadingSpaces = parse(input_allLeadingSpaces);
assertEqualsNoEol(expected, cu_allLeadingSpaces.toString());
assertEqualsStringIgnoringEol(expected, cu_allLeadingSpaces.toString());
}

@Test
Expand All @@ -432,7 +432,7 @@ void javadocIssue1907_singleMissingLeadingSpace() {
"public void add(int x, int y){}}";

CompilationUnit cu_singleMissingLeadingSpace = parse(input_singleMissingLeadingSpace);
assertEqualsNoEol(expected, cu_singleMissingLeadingSpace.toString());
assertEqualsStringIgnoringEol(expected, cu_singleMissingLeadingSpace.toString());
}

@Test
Expand All @@ -448,13 +448,13 @@ void javadocIssue1907_leadingTab() {
"public void add(int x, int y){}}";

CompilationUnit cu_leadingTab = parseCompilationUnit(input_leadingTab);
assertEqualsNoEol(expected, cu_leadingTab.toString());
assertEqualsStringIgnoringEol(expected, cu_leadingTab.toString());
}

@Test
void printYield() {
Statement statement = parseStatement("yield 5*5;");
assertEqualsNoEol("yield 5 * 5;", statement.toString());
assertEqualsStringIgnoringEol("yield 5 * 5;", statement.toString());
}

@Test
Expand All @@ -467,7 +467,7 @@ void printTextBlock() {
" </html>\n" +
" \"\"\";}");

assertEqualsNoEol("String html = \"\"\"\n" +
assertEqualsStringIgnoringEol("String html = \"\"\"\n" +
" <html>\n" +
" <body>\n" +
" <p>Hello, world</p>\n" +
Expand All @@ -482,7 +482,7 @@ void printTextBlock2() {
" <html>\n" +
" </html>\"\"\";}");

assertEqualsNoEol("String html = \"\"\"\n" +
assertEqualsStringIgnoringEol("String html = \"\"\"\n" +
" <html>\n" +
" </html>\"\"\";", cu.getClassByName("X").get().getFieldByName("html").get().toString());
}
Expand Down
Loading

0 comments on commit 2f97c70

Please sign in to comment.