diff options
author | Roel Spilker <r.spilker@gmail.com> | 2009-11-27 04:18:28 +0100 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2009-11-27 04:23:41 +0100 |
commit | 391db3dcecdd0d94eb76b656e655346891b02bb4 (patch) | |
tree | 592d79167f4f5a6ce92813cfd962fa51228d3ee0 /test | |
parent | e54c3f36e3122dfe34a119178cfcca2dcdbad998 (diff) | |
download | lombok-391db3dcecdd0d94eb76b656e655346891b02bb4.tar.gz lombok-391db3dcecdd0d94eb76b656e655346891b02bb4.tar.bz2 lombok-391db3dcecdd0d94eb76b656e655346891b02bb4.zip |
Thorough work on inserting comments in the proper place for delombok; should now work fine with GWT native methods!
NON-NLS-1 is still theoretically problematic, but that'll be a fix for another day.
Also added ability to recognize that nothing has changed, which will copy the original file instead of reparsing it.
Diffstat (limited to 'test')
4 files changed, 17 insertions, 18 deletions
diff --git a/test/delombok/src/lombok/delombok/TestLombokFiles.java b/test/delombok/src/lombok/delombok/TestLombokFiles.java index 10782830..f04a0a34 100644 --- a/test/delombok/src/lombok/delombok/TestLombokFiles.java +++ b/test/delombok/src/lombok/delombok/TestLombokFiles.java @@ -52,10 +52,9 @@ public class TestLombokFiles { public void testSources() throws Exception { File[] listFiles = BEFORE_FOLDER.listFiles(); for (File file : listFiles) { - ParseResult parseResult = parser.parseFile(file.toString()); + ParseResult parseResult = parser.parse(file.toString(), true); StringWriter writer = new StringWriter(); parseResult.print(writer); - System.out.println(writer); compare(file.getName(), readAfter(file), writer.toString()); } } @@ -63,6 +62,9 @@ public class TestLombokFiles { private void compare(String name, String expectedFile, String actualFile) { String[] expectedLines = expectedFile.split("(\\r?\\n)"); String[] actualLines = actualFile.split("(\\r?\\n)"); + if (actualLines[0].startsWith("// Generated by delombok at ")) { + actualLines[0] = ""; + } expectedLines = removeBlanks(expectedLines); actualLines = removeBlanks(actualLines); int size = Math.min(expectedLines.length, actualLines.length); diff --git a/test/delombok/src/lombok/delombok/TestSourceFiles.java b/test/delombok/src/lombok/delombok/TestSourceFiles.java index b662651d..91ace773 100644 --- a/test/delombok/src/lombok/delombok/TestSourceFiles.java +++ b/test/delombok/src/lombok/delombok/TestSourceFiles.java @@ -53,7 +53,7 @@ public class TestSourceFiles { public void testSources() throws Exception { File[] listFiles = BEFORE_FOLDER.listFiles(); for (File file : listFiles) { - ParseResult parseResult = parser.parseFile(file.toString()); + ParseResult parseResult = parser.parse(file.toString(), true); StringWriter writer = new StringWriter(); parseResult.print(writer); compare(file.getName(), readAfter(file), writer.toString()); @@ -71,6 +71,9 @@ public class TestSourceFiles { private void compare(String name, String expectedFile, String actualFile) { String[] expectedLines = expectedFile.split("(\\r?\\n)"); String[] actualLines = actualFile.split("(\\r?\\n)"); + if (actualLines[0].startsWith("// Generated by delombok at ")) { + actualLines[0] = ""; + } expectedLines = removeBlanks(expectedLines); actualLines = removeBlanks(actualLines); int size = Math.min(expectedLines.length, actualLines.length); @@ -78,7 +81,7 @@ public class TestSourceFiles { String expected = expectedLines[i]; String actual = actualLines[i]; if (!expected.equals(actual)) { - fail(String.format("Difference in line %s(%d):\n`%s`\n`%s`\n", name, i, expected, actual)); + fail(String.format("Difference in line %s(%d):\nExpected `%s`\nGot `%s`\n", name, i, expected, actual)); } } if (expectedLines.length > actualLines.length) { diff --git a/test/lombok/resource/after/CommentsInterspersed.java b/test/lombok/resource/after/CommentsInterspersed.java index ec5374c0..f3841606 100644 --- a/test/lombok/resource/after/CommentsInterspersed.java +++ b/test/lombok/resource/after/CommentsInterspersed.java @@ -1,26 +1,20 @@ -import lombok.Getter; - +/* cmt */ +/* cmt2 */ +/* cmt3 */ /*bla */ public class CommentsInterspersed { /** javadoc for field */ private int x; /* bla2 */ - @Getter() - private String test = "foo"; - //$NON-NLS-1$ + private String test = "foo"; //$NON-NLS-1$ /** Javadoc on method */ - public native void gwtTest(); - /*-{ + public native void gwtTest(); /*-{ javascript; }-*/ - public CommentsInterspersed() { - } - public String getTest() { - return this.test; + return test; } -} -//haha! +} //haha! diff --git a/test/lombok/resource/before/CommentsInterspersed.java b/test/lombok/resource/before/CommentsInterspersed.java index 2a32d309..455c680d 100644 --- a/test/lombok/resource/before/CommentsInterspersed.java +++ b/test/lombok/resource/before/CommentsInterspersed.java @@ -1,4 +1,4 @@ -import lombok.Getter; +import /* cmt */ lombok./* cmt2 */Getter /* cmt3 */ ; public /*bla */ class CommentsInterspersed { /** javadoc for field */ |