From 2cb045707ee9d3234b12e095964ba164fdd6ea0f Mon Sep 17 00:00:00 2001 From: emmanue1 Date: Mon, 29 Jul 2019 10:48:00 +0200 Subject: [PATCH] Update unit tests --- .../jd/core/v1/JavaFragmentToTokenTest.java | 228 +++++++++--------- .../core/v1/JavaSyntaxToJavaSourceTest.java | 8 +- .../core/v1/LayoutFragmentProcessorTest.java | 16 +- .../java/org/jd/core/v1/WriteTokenTest.java | 50 ++-- 4 files changed, 151 insertions(+), 151 deletions(-) diff --git a/src/test/java/org/jd/core/v1/JavaFragmentToTokenTest.java b/src/test/java/org/jd/core/v1/JavaFragmentToTokenTest.java index 96554796..ff185694 100644 --- a/src/test/java/org/jd/core/v1/JavaFragmentToTokenTest.java +++ b/src/test/java/org/jd/core/v1/JavaFragmentToTokenTest.java @@ -70,7 +70,7 @@ public void testIfReturn_0() throws Exception { printSource(source); - Assert.assertTrue(source.matches(PatternMaker.make("[ 4: 0]", "i = 1;"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 4: 0 */", "i = 1;"))); } @Test @@ -93,9 +93,9 @@ public void testIfReturn_1_3() throws Exception { printSource(source); - Assert.assertTrue(source.matches(PatternMaker.make("[ 1: 1]", "if (args == null)"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 2: 0]", "return;"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 3: 3]", "int i = 1;"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 1: 1 */", "if (args == null)"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 2: 0 */", "return;"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 3: 3 */", "int i = 1;"))); } @Test @@ -118,9 +118,9 @@ public void testIfReturn_1_4() throws Exception { printSource(source); - Assert.assertTrue(source.matches(PatternMaker.make("[ 1: 1]", "if (args == null)"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 2: 0]", "return;"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 4: 4]", "int i = 1;"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 1: 1 */", "if (args == null)"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 2: 0 */", "return;"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 4: 4 */", "int i = 1;"))); } @Test @@ -141,7 +141,7 @@ public void testIfAssignation_0() throws Exception { printSource(source); - Assert.assertTrue(source.matches(PatternMaker.make("[ 4: 0]", "i = 1;"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 4: 0 */", "i = 1;"))); } @Test @@ -164,9 +164,9 @@ public void testIfAssignation_1_2_3() throws Exception { printSource(source); - Assert.assertTrue(source.matches(PatternMaker.make("[ 1: 1]", "if (args == null)"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 2: 2]", "i = 0;"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 3: 3]", "i = 1;"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 1: 1 */", "if (args == null)"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 2: 2 */", "i = 0;"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 3: 3 */", "i = 1;"))); Assert.assertTrue(source.indexOf('{') == -1); } @@ -190,10 +190,10 @@ public void testIfAssignation_1_3_5() throws Exception { printSource(source); - Assert.assertTrue(source.matches(PatternMaker.make("[ 1: 1]", "if (args == null)"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 2: 0]", "{"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 3: 3]", "i = 0;"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 5: 5]", "i = 1;"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 1: 1 */", "if (args == null)"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 2: 0 */", "{"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 3: 3 */", "i = 0;"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 5: 5 */", "i = 1;"))); } @Test @@ -214,7 +214,7 @@ public void testClassAndFieldDeclarationWithoutImports_0() throws Exception { printSource(source); - Assert.assertTrue(source.matches(PatternMaker.make("[ 4: 0]", "protected int a"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 4: 0 */", "protected int a"))); } @Test @@ -235,7 +235,7 @@ public void testClassAndFieldDeclaration_0() throws Exception { printSource(source); - Assert.assertTrue(source.matches(PatternMaker.make("[ 7: 0]", "protected int a"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 7: 0 */", "protected int a"))); } @Test @@ -258,8 +258,8 @@ public void testClassAndFieldDeclaration_1() throws Exception { printSource(source); - Assert.assertTrue(source.indexOf("[ 1: 1] package org.jd.core.v1.service.writer;") != -1); - Assert.assertTrue(source.indexOf("[ 2: 0] -->") != -1); + Assert.assertTrue(source.indexOf("/* 1: 1 */ package org.jd.core.v1.service.writer;") != -1); + Assert.assertTrue(source.indexOf("/* 2: 0 */ -->") != -1); } @Test @@ -282,8 +282,8 @@ public void testClassAndFieldDeclaration_2() throws Exception { printSource(source); - Assert.assertTrue(source.indexOf("[ 1: 0] package org.jd.core.v1.service.writer;") != -1); - Assert.assertTrue(source.matches(PatternMaker.make("[ 2: 2]", "protected int a"))); + Assert.assertTrue(source.indexOf("/* 1: 0 */ package org.jd.core.v1.service.writer;") != -1); + Assert.assertTrue(source.matches(PatternMaker.make("/* 2: 2 */", "protected int a"))); } @Test @@ -306,10 +306,10 @@ public void testClassAndFieldDeclaration_3() throws Exception { printSource(source); - Assert.assertTrue(source.indexOf("[ 1: 0] package org.jd.core.v1.service.writer;") != -1); - Assert.assertTrue(source.matches(PatternMaker.make("[ 2: 0]", "public class TokenWriterTest"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 3: 3]", "protected int a"))); - Assert.assertTrue(source.indexOf("[ 4: 0] } -->") != -1); + Assert.assertTrue(source.indexOf("/* 1: 0 */ package org.jd.core.v1.service.writer;") != -1); + Assert.assertTrue(source.matches(PatternMaker.make("/* 2: 0 */", "public class TokenWriterTest"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 3: 3 */", "protected int a"))); + Assert.assertTrue(source.indexOf("/* 4: 0 */ } -->") != -1); } @Test @@ -332,10 +332,10 @@ public void testClassAndFieldDeclaration_4() throws Exception { printSource(source); - Assert.assertTrue(source.indexOf("[ 1: 0] package org.jd.core.v1.service.writer;") != -1); - Assert.assertTrue(source.matches(PatternMaker.make("[ 3: 0]", "public class TokenWriterTest"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 4: 4]", "protected int a"))); - Assert.assertTrue(source.indexOf("[ 5: 0] } -->") != -1); + Assert.assertTrue(source.indexOf("/* 1: 0 */ package org.jd.core.v1.service.writer;") != -1); + Assert.assertTrue(source.matches(PatternMaker.make("/* 3: 0 */", "public class TokenWriterTest"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 4: 4 */", "protected int a"))); + Assert.assertTrue(source.indexOf("/* 5: 0 */ } -->") != -1); } @Test @@ -358,9 +358,9 @@ public void testClassAndFieldDeclaration_5() throws Exception { printSource(source); - Assert.assertTrue(source.indexOf("[ 1: 0] package org.jd.core.v1.service.writer;") != -1); - Assert.assertTrue(source.matches(PatternMaker.make("[ 4: 0]", "public class TokenWriterTest"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 5: 5]", "protected int a"))); + Assert.assertTrue(source.indexOf("/* 1: 0 */ package org.jd.core.v1.service.writer;") != -1); + Assert.assertTrue(source.matches(PatternMaker.make("/* 4: 0 */", "public class TokenWriterTest"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 5: 5 */", "protected int a"))); } @Test @@ -383,10 +383,10 @@ public void testClassAndFieldDeclaration_6() throws Exception { printSource(source); - Assert.assertTrue(source.indexOf("[ 1: 0] package org.jd.core.v1.service.writer;") != -1); - Assert.assertTrue(source.matches(PatternMaker.make("[ 3: 0]", "import org.junit.Assert"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 5: 0]", "public class TokenWriterTest"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 6: 6]", "protected int a"))); + Assert.assertTrue(source.indexOf("/* 1: 0 */ package org.jd.core.v1.service.writer;") != -1); + Assert.assertTrue(source.matches(PatternMaker.make("/* 3: 0 */", "import org.junit.Assert"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 5: 0 */", "public class TokenWriterTest"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 6: 6 */", "protected int a"))); } @Test @@ -407,11 +407,11 @@ public void testClassAndFieldDeclaration_7() throws Exception { printSource(source); - Assert.assertTrue(source.indexOf("[ 1: 0] package org.jd.core.v1.service.writer;") != -1); - Assert.assertTrue(source.matches(PatternMaker.make("[ 3: 0]", "import java.util.ArrayList"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 4: 0]", "import org.junit.Assert"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 6: 0]", "public class TokenWriterTest"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 7: 7]", "protected int a"))); + Assert.assertTrue(source.indexOf("/* 1: 0 */ package org.jd.core.v1.service.writer;") != -1); + Assert.assertTrue(source.matches(PatternMaker.make("/* 3: 0 */", "import java.util.ArrayList"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 4: 0 */", "import org.junit.Assert"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 6: 0 */", "public class TokenWriterTest"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 7: 7 */", "protected int a"))); } @Test @@ -434,11 +434,11 @@ public void testClassAndFieldDeclaration_8() throws Exception { printSource(source); - Assert.assertTrue(source.indexOf("[ 1: 0] package org.jd.core.v1.service.writer;") != -1); - Assert.assertTrue(source.matches(PatternMaker.make("[ 3: 0]", "import java.util.ArrayList"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 4: 0]", "import org.junit.Assert"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 6: 0]", "public class TokenWriterTest"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 8: 8]", "protected int a"))); + Assert.assertTrue(source.indexOf("/* 1: 0 */ package org.jd.core.v1.service.writer;") != -1); + Assert.assertTrue(source.matches(PatternMaker.make("/* 3: 0 */", "import java.util.ArrayList"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 4: 0 */", "import org.junit.Assert"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 6: 0 */", "public class TokenWriterTest"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 8: 8 */", "protected int a"))); } @Test @@ -461,11 +461,11 @@ public void testClassAndFieldDeclaration_9() throws Exception { printSource(source); - Assert.assertTrue(source.indexOf("[ 1: 0] package org.jd.core.v1.service.writer;") != -1); - Assert.assertTrue(source.matches(PatternMaker.make("[ 3: 0]", "import java.util.ArrayList"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 4: 0]", "import org.junit.Assert"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 6: 0]", "public class TokenWriterTest"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 9: 9]", "protected int a"))); + Assert.assertTrue(source.indexOf("/* 1: 0 */ package org.jd.core.v1.service.writer;") != -1); + Assert.assertTrue(source.matches(PatternMaker.make("/* 3: 0 */", "import java.util.ArrayList"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 4: 0 */", "import org.junit.Assert"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 6: 0 */", "public class TokenWriterTest"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 9: 9 */", "protected int a"))); } @Test @@ -489,11 +489,11 @@ public void testClassAndFieldDeclaration_10() throws Exception { printSource(source); - Assert.assertTrue(source.indexOf("[ 1: 0] package org.jd.core.v1.service.writer;") != -1); - Assert.assertTrue(source.matches(PatternMaker.make("[ 3: 0]", "import java.util.ArrayList"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 4: 0]", "import org.junit.Assert"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 6: 0]", "public class TokenWriterTest"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 10: 10]", "protected int a"))); + Assert.assertTrue(source.indexOf("/* 1: 0 */ package org.jd.core.v1.service.writer;") != -1); + Assert.assertTrue(source.matches(PatternMaker.make("/* 3: 0 */", "import java.util.ArrayList"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 4: 0 */", "import org.junit.Assert"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 6: 0 */", "public class TokenWriterTest"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 10: 10 */", "protected int a"))); } @Test @@ -516,9 +516,9 @@ public void testClassAndMethodDeclaration_3() throws Exception { printSource(source); - Assert.assertTrue(source.indexOf("[ 1: 0] package org.jd.core.v1.service.writer;") != -1); - Assert.assertTrue(source.matches(PatternMaker.make("[ 2: 0]", "public TokenWriterTest"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 3: 3]", "super(i);"))); + Assert.assertTrue(source.indexOf("/* 1: 0 */ package org.jd.core.v1.service.writer;") != -1); + Assert.assertTrue(source.matches(PatternMaker.make("/* 2: 0 */", "public TokenWriterTest"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 3: 3 */", "super(i);"))); } @Test @@ -541,9 +541,9 @@ public void testClassAndMethodDeclaration_4() throws Exception { printSource(source); - Assert.assertTrue(source.indexOf("[ 1: 0] package org.jd.core.v1.service.writer;") != -1); - Assert.assertTrue(source.matches(PatternMaker.make("[ 2: 0]", "public class TokenWriterTest"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 3: 0]", "public TokenWriterTest", "(int i)"))); + Assert.assertTrue(source.indexOf("/* 1: 0 */ package org.jd.core.v1.service.writer;") != -1); + Assert.assertTrue(source.matches(PatternMaker.make("/* 2: 0 */", "public class TokenWriterTest"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 3: 0 */", "public TokenWriterTest", "(int i)"))); } @Test @@ -564,11 +564,11 @@ public void testClassAndMethodDeclaration_8() throws Exception { printSource(source); - Assert.assertTrue(source.indexOf("[ 1: 0] package org.jd.core.v1.service.writer;") != -1); - Assert.assertTrue(source.matches(PatternMaker.make("[ 3: 0]", "import java.util.ArrayList"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 4: 0]", "import org.junit.Assert"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 6: 0]", "public class TokenWriterTest"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 7: 0]", "public TokenWriterTest", "(int i)"))); + Assert.assertTrue(source.indexOf("/* 1: 0 */ package org.jd.core.v1.service.writer;") != -1); + Assert.assertTrue(source.matches(PatternMaker.make("/* 3: 0 */", "import java.util.ArrayList"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 4: 0 */", "import org.junit.Assert"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 6: 0 */", "public class TokenWriterTest"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 7: 0 */", "public TokenWriterTest", "(int i)"))); } @Test @@ -591,11 +591,11 @@ public void testClassAndMethodDeclaration_9() throws Exception { printSource(source); - Assert.assertTrue(source.indexOf("[ 1: 0] package org.jd.core.v1.service.writer;") != -1); - Assert.assertTrue(source.matches(PatternMaker.make("[ 3: 0]", "import java.util.ArrayList"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 4: 0]", "import org.junit.Assert"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 6: 0]", "public class TokenWriterTest"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 8: 0]", "public TokenWriterTest", "(int i)"))); + Assert.assertTrue(source.indexOf("/* 1: 0 */ package org.jd.core.v1.service.writer;") != -1); + Assert.assertTrue(source.matches(PatternMaker.make("/* 3: 0 */", "import java.util.ArrayList"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 4: 0 */", "import org.junit.Assert"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 6: 0 */", "public class TokenWriterTest"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 8: 0 */", "public TokenWriterTest", "(int i)"))); } @Test @@ -619,14 +619,14 @@ public void testClassAndMethodDeclaration_10() throws Exception { printSource(source); - Assert.assertTrue(source.matches(PatternMaker.make("[ 1: 0]", "package org.jd.core.v1.service.writer;"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 3: 0]", "import java.util.ArrayList"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 4: 0]", "import org.junit.Assert"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 6: 0]", "public class TokenWriterTest"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 7: 0]", "extends Test"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 8: 0]", "implements Serializable"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 9: 0]", "public TokenWriterTest"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 10: 10]", "super"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 1: 0 */", "package org.jd.core.v1.service.writer;"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 3: 0 */", "import java.util.ArrayList"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 4: 0 */", "import org.junit.Assert"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 6: 0 */", "public class TokenWriterTest"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 7: 0 */", "extends Test"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 8: 0 */", "implements Serializable"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 9: 0 */", "public TokenWriterTest"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 10: 10 */", "super"))); } @Test @@ -650,14 +650,14 @@ public void testClassAndMethodDeclaration_11() throws Exception { printSource(source); - Assert.assertTrue(source.matches(PatternMaker.make("[ 1: 0]", "package org.jd.core.v1.service.writer;"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 3: 0]", "import java.util.ArrayList"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 4: 0]", "import org.junit.Assert"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 6: 0]", "public class TokenWriterTest"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 7: 0]", "extends Test"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 8: 0]", "implements Serializable"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 10: 0]", "public TokenWriterTest"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 11: 11]", "super"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 1: 0 */", "package org.jd.core.v1.service.writer;"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 3: 0 */", "import java.util.ArrayList"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 4: 0 */", "import org.junit.Assert"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 6: 0 */", "public class TokenWriterTest"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 7: 0 */", "extends Test"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 8: 0 */", "implements Serializable"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 10: 0 */", "public TokenWriterTest"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 11: 11 */", "super"))); } @Test @@ -681,14 +681,14 @@ public void testClassAndMethodDeclaration_12() throws Exception { printSource(source); - Assert.assertTrue(source.matches(PatternMaker.make("[ 1: 0]", "package org.jd.core.v1.service.writer;"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 3: 0]", "import java.util.ArrayList"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 4: 0]", "import org.junit.Assert"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 7: 0]", "public class TokenWriterTest"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 8: 0]", "extends Test"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 9: 0]", "implements Serializable"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 11: 0]", "public TokenWriterTest"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 12: 12]", "super"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 1: 0 */", "package org.jd.core.v1.service.writer;"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 3: 0 */", "import java.util.ArrayList"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 4: 0 */", "import org.junit.Assert"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 7: 0 */", "public class TokenWriterTest"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 8: 0 */", "extends Test"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 9: 0 */", "implements Serializable"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 11: 0 */", "public TokenWriterTest"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 12: 12 */", "super"))); } @Test @@ -712,14 +712,14 @@ public void testClassAndMethodDeclaration_14() throws Exception { printSource(source); - Assert.assertTrue(source.matches(PatternMaker.make("[ 1: 0]", "package org.jd.core.v1.service.writer;"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 3: 0]", "import java.util.ArrayList"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 4: 0]", "import org.junit.Assert"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 9: 0]", "public class TokenWriterTest"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 10: 0]", "extends Test"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 11: 0]", "implements Serializable"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 13: 0]", "public TokenWriterTest"))); - Assert.assertTrue(source.matches(PatternMaker.make("[ 14: 14]", "super"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 1: 0 */", "package org.jd.core.v1.service.writer;"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 3: 0 */", "import java.util.ArrayList"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 4: 0 */", "import org.junit.Assert"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 9: 0 */", "public class TokenWriterTest"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 10: 0 */", "extends Test"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 11: 0 */", "implements Serializable"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 13: 0 */", "public TokenWriterTest"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 14: 14 */", "super"))); } @Test @@ -740,7 +740,7 @@ public void testLayout() throws Exception { printSource(source); - Assert.assertTrue(source.matches(PatternMaker.make("[ 22: 22]", "System", "println", "(i);"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 22: 22 */", "System", "println", "(i);"))); } @Test @@ -761,7 +761,7 @@ public void testLayoutWithoutLineNumber() throws Exception { printSource(source); - Assert.assertTrue(source.matches(PatternMaker.make("[ 15: 0]", "public Object", "nextElement"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 15: 0 */", "public Object", "nextElement"))); } @Test @@ -784,7 +784,7 @@ public void testLayoutWithStretchedfFragments_2() throws Exception { printSource(source); - Assert.assertTrue(source.indexOf("[ 44: 44]") != -1); + Assert.assertTrue(source.indexOf("/* 44: 44 */") != -1); } @Test @@ -807,7 +807,7 @@ public void testLayoutWithStretchedfFragments_3() throws Exception { printSource(source); - Assert.assertTrue(source.indexOf("[ 66: 66]") != -1); + Assert.assertTrue(source.indexOf("/* 66: 66 */") != -1); } @Test @@ -830,7 +830,7 @@ public void testMoveDown() throws Exception { printSource(source); - Assert.assertTrue(source.matches(PatternMaker.make("[ 7: 0]", "public static void main"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 7: 0 */", "public static void main"))); } @Test @@ -853,7 +853,7 @@ public void testLinkedBlocks_16() throws Exception { printSource(source); - Assert.assertTrue(source.matches(PatternMaker.make("[ 16: 16]", "i = 4;"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 16: 16 */", "i = 4;"))); } @Test @@ -876,7 +876,7 @@ public void testLinkedBlocks_22() throws Exception { printSource(source); - Assert.assertTrue(source.matches(PatternMaker.make("[ 22: 22]", "i = 4;"))); + Assert.assertTrue(source.matches(PatternMaker.make("/* 22: 22 */", "i = 4;"))); } /** @@ -1362,7 +1362,7 @@ public Message createSimpleMessage(int factor) { new DeclarationToken(DeclarationToken.METHOD, "org/jd/core/v1/service/test/TokenWriterTest", "main", "([Ljava/lang/String;)V"), TextToken.LEFTROUNDBRACKET, new ReferenceToken(ReferenceToken.TYPE, "java/lang/String", "String", null, "org/jd/core/v1/service/test/TokenWriterTest"), - new TextToken("[] args)") + new TextToken("/*] args)") )); StartBodyFragment startMainMethodBody = JavaFragmentFactory.addStartMethodBody(fragments); @@ -1637,7 +1637,7 @@ public Message createMessageToTestMoveDown() { new DeclarationToken(DeclarationToken.METHOD, "org/jd/core/v1/service/test/TokenWriterTest", "main", "([Ljava/lang/String;)V"), TextToken.LEFTROUNDBRACKET, new ReferenceToken(ReferenceToken.TYPE, "java/lang/String", "String", null, "org/jd/core/v1/service/test/TokenWriterTest"), - new TextToken("[] args)") + new TextToken("/*] args)") )); StartBodyFragment startMainMethodBody = JavaFragmentFactory.addStartMethodBody(fragments); @@ -1737,7 +1737,7 @@ public Message createMessageToTestLinkedBlocks(int lineNumber1, int lineNumber2, new DeclarationToken(DeclarationToken.METHOD, "org/jd/core/v1/service/test/TokenWriterTest", "main", "([Ljava/lang/String;)V"), TextToken.LEFTROUNDBRACKET, new ReferenceToken(ReferenceToken.TYPE, "java/lang/String", "String", null, "org/jd/core/v1/service/test/TokenWriterTest"), - new TextToken("[] args)") + new TextToken("/*] args)") )); StartBodyFragment startMainMethodBody = JavaFragmentFactory.addStartMethodBody(fragments); diff --git a/src/test/java/org/jd/core/v1/JavaSyntaxToJavaSourceTest.java b/src/test/java/org/jd/core/v1/JavaSyntaxToJavaSourceTest.java index 24a78a42..8098fd0e 100644 --- a/src/test/java/org/jd/core/v1/JavaSyntaxToJavaSourceTest.java +++ b/src/test/java/org/jd/core/v1/JavaSyntaxToJavaSourceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2019 Emmanuel Dupuy. + * Copyright (c) 2008, 2019 Emmanuel Dupuy. * This project is distributed under the GPLv3 license. * This is a Copyleft license that gives the user the right to use, * copy and modify the code freely for non-commercial purposes. @@ -160,7 +160,7 @@ public void testClassDeclaration() throws Exception { System.out.print(source); System.out.println("- - - - - - - - "); - Assert.assertTrue(source.indexOf("[ 22: 22]") != -1); + Assert.assertTrue(source.indexOf("/* 22: 22 */") != -1); Assert.assertTrue(source.indexOf("java.lang.System") == -1); } @@ -186,7 +186,7 @@ public void testInterfaceDeclaration() throws Exception { message.setHeader("loader", new NopLoader()); message.setHeader("printer", printer); message.setHeader("maxLineNumber", 0); - message.setHeader("majorVersion", 0); + message.setHeader("majorVersion", 49); message.setHeader("minorVersion", 0); fragmenter.process(message); @@ -200,7 +200,7 @@ public void testInterfaceDeclaration() throws Exception { System.out.print(source); System.out.println("- - - - - - - - "); - Assert.assertTrue(source.indexOf("[ 1: 0] package org.jd.core.v1.service.test;") != -1); + Assert.assertTrue(source.indexOf("/* 1: 0 */ package org.jd.core.v1.service.test;") != -1); Assert.assertTrue(source.indexOf("interface InterfaceTest") != -1); Assert.assertTrue(source.indexOf("extends List") != -1); Assert.assertTrue(source.indexOf(";\n" + - "[ 4: 0] import static org.junit.Assert.*;\n" + - "[ 5: 0] \n" + - "[ 6: 0] public class WriteTokenTest {\n" + - "[ 7: 0] public static void main(String[] args) {\n" + - "[ 8: 8] if (args == null)\n" + - "[ 9: 0] return;\n" + - "[ 10: 10] int i = call(\n" + - "[ 11: 11] \"aaaa\",\n" + - "[ 12: 12] b,\n" + - "[ 13: 13] new Enumeration() {\n" + - "[ 14: 0] public boolean hasMoreElements() {\n" + - "[ 15: 15] return false;\n" + - "[ 16: 0] }\n" + - "[ 17: 0] public Object nextElement() {\n" + - "[ 18: 18] return null;\n" + - "[ 19: 0] }\n" + - "[ 20: 0] },\n" + - "[ 21: 21] c);\n" + - "[ 22: 22] System.out.println(i);\n" + - "[ 23: 0] }\n" + - "[ 24: 0] }\n"; + "/* 1: 0 */ package org.jd.core.v1.service.test;\n" + + "/* 2: 0 */ \n" + + "/* 3: 0 */ import java.util.ArrayList;\n" + + "/* 4: 0 */ import static org.junit.Assert.*;\n" + + "/* 5: 0 */ \n" + + "/* 6: 0 */ public class WriteTokenTest {\n" + + "/* 7: 0 */ public static void main(String[] args) {\n" + + "/* 8: 8 */ if (args == null)\n" + + "/* 9: 0 */ return;\n" + + "/* 10: 10 */ int i = call(\n" + + "/* 11: 11 */ \"aaaa\",\n" + + "/* 12: 12 */ b,\n" + + "/* 13: 13 */ new Enumeration() {\n" + + "/* 14: 0 */ public boolean hasMoreElements() {\n" + + "/* 15: 15 */ return false;\n" + + "/* 16: 0 */ }\n" + + "/* 17: 0 */ public Object nextElement() {\n" + + "/* 18: 18 */ return null;\n" + + "/* 19: 0 */ }\n" + + "/* 20: 0 */ },\n" + + "/* 21: 21 */ c);\n" + + "/* 22: 22 */ System.out.println(i);\n" + + "/* 23: 0 */ }\n" + + "/* 24: 0 */ }\n"; Assert.assertEquals(expected, source); }