From 9ae5342eb57695e48885947811fae458e93c8217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Fournier?= Date: Sat, 14 Sep 2019 02:06:36 +0200 Subject: [PATCH] Normalise line terminators in tests Comparison was failing because the test file was checked out with CRLF and the expected result is written with LF. Maybe we should normalise consistently across tests. Using PMD.EOL in tests is just code obfuscation. --- .../pmd/lang/java/ast/Java13Test.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java13Test.java b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java13Test.java index e56f534591..737c6b2654 100644 --- a/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java13Test.java +++ b/pmd-java/src/test/java/net/sourceforge/pmd/lang/java/ast/Java13Test.java @@ -19,7 +19,8 @@ public class Java13Test { private static String loadSource(String name) { try { return IOUtils.toString(Java13Test.class.getResourceAsStream("jdkversiontests/java13/" + name), - StandardCharsets.UTF_8); + StandardCharsets.UTF_8) + .replaceAll("\\R", "\n"); // normalize line separators to \n } catch (IOException e) { throw new RuntimeException(e); } @@ -71,8 +72,7 @@ public class Java13Test { @Test public void testTextBlocks() { - ASTCompilationUnit compilationUnit = ParserTstUtil.parseAndTypeResolveJava("13-preview", - loadSource("TextBlocks.java")); + ASTCompilationUnit compilationUnit = ParserTstUtil.parseAndTypeResolveJava("13-preview", loadSource("TextBlocks.java")); Assert.assertNotNull(compilationUnit); List literals = compilationUnit.findDescendantsOfType(ASTLiteral.class); Assert.assertEquals(10, literals.size()); @@ -80,9 +80,14 @@ public class Java13Test { ASTLiteral literal = literals.get(i); Assert.assertTrue(literal.isTextBlock()); } - Assert.assertEquals("\"\"\"\n" + " \n" + " \n" - + "

Hello, world

\n" + " \n" - + " \n" + " \"\"\"", literals.get(0).getImage()); + Assert.assertEquals("\"\"\"\n" + + " \n" + + " \n" + + "

Hello, world

\n" + + " \n" + + " \n" + + " \"\"\"", + literals.get(0).getImage()); Assert.assertFalse(literals.get(8).isTextBlock()); Assert.assertTrue(literals.get(9).isTextBlock()); }