Merge branch '7.0.x' into pmd7-language-lifecycle
This commit is contained in:
@ -88,8 +88,8 @@
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -7,16 +7,16 @@ package net.sourceforge.pmd;
|
||||
import static net.sourceforge.pmd.lang.ast.test.TestUtilsKt.assertSize;
|
||||
import static net.sourceforge.pmd.lang.ast.test.TestUtilsKt.assertSuppressed;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.sourceforge.pmd.lang.ecmascript.ast.ASTFunctionNode;
|
||||
import net.sourceforge.pmd.lang.ecmascript.ast.EcmascriptParserTestBase;
|
||||
import net.sourceforge.pmd.lang.ecmascript.rule.AbstractEcmascriptRule;
|
||||
|
||||
public class ReportTest extends EcmascriptParserTestBase {
|
||||
class ReportTest extends EcmascriptParserTestBase {
|
||||
|
||||
@Test
|
||||
public void testExclusionsInReportWithNOPMDEcmascript() {
|
||||
void testExclusionsInReportWithNOPMDEcmascript() {
|
||||
Rule rule = new AbstractEcmascriptRule() {
|
||||
@Override
|
||||
public Object visit(ASTFunctionNode node, Object data) {
|
||||
|
@ -6,16 +6,16 @@ package net.sourceforge.pmd.cpd;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class AnyTokenizerForTypescriptTest extends CpdTextComparisonTest {
|
||||
class AnyTokenizerForTypescriptTest extends CpdTextComparisonTest {
|
||||
|
||||
public AnyTokenizerForTypescriptTest() {
|
||||
AnyTokenizerForTypescriptTest() {
|
||||
super(".ts");
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ public class AnyTokenizerForTypescriptTest extends CpdTextComparisonTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFile1() {
|
||||
void testFile1() {
|
||||
doTest("SampleTypeScript");
|
||||
}
|
||||
|
||||
|
@ -6,13 +6,13 @@ package net.sourceforge.pmd.cpd;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.sourceforge.pmd.cpd.test.CpdTextComparisonTest;
|
||||
|
||||
public class EcmascriptTokenizerTest extends CpdTextComparisonTest {
|
||||
class EcmascriptTokenizerTest extends CpdTextComparisonTest {
|
||||
|
||||
public EcmascriptTokenizerTest() {
|
||||
EcmascriptTokenizerTest() {
|
||||
super(".js");
|
||||
}
|
||||
|
||||
@ -27,17 +27,17 @@ public class EcmascriptTokenizerTest extends CpdTextComparisonTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimple() {
|
||||
void testSimple() {
|
||||
doTest("simple");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimplewithSemis() {
|
||||
void testSimplewithSemis() {
|
||||
doTest("simpleWithSemis");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreBetweenSpecialComments() {
|
||||
void testIgnoreBetweenSpecialComments() {
|
||||
doTest("specialComments");
|
||||
}
|
||||
|
||||
@ -45,27 +45,27 @@ public class EcmascriptTokenizerTest extends CpdTextComparisonTest {
|
||||
* See: https://sourceforge.net/p/pmd/bugs/1239/
|
||||
*/
|
||||
@Test
|
||||
public void parseStringNotAsMultiline() {
|
||||
void parseStringNotAsMultiline() {
|
||||
doTest("lineContinuations");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreSingleLineComments() {
|
||||
void testIgnoreSingleLineComments() {
|
||||
doTest("singleLineCommentIgnore");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIgnoreMultiLineComments() {
|
||||
void testIgnoreMultiLineComments() {
|
||||
doTest("multilineCommentIgnore");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTemplateStrings() {
|
||||
void testTemplateStrings() {
|
||||
doTest("templateStrings");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTabWidth() {
|
||||
void testTabWidth() {
|
||||
doTest("tabWidth");
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,12 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class ASTForInLoopTest extends EcmascriptParserTestBase {
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class ASTForInLoopTest extends EcmascriptParserTestBase {
|
||||
|
||||
/**
|
||||
* Note: for each loops are deprecated.
|
||||
@ -16,18 +18,18 @@ public class ASTForInLoopTest extends EcmascriptParserTestBase {
|
||||
* @see <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for_each...in">for each...in</a>
|
||||
*/
|
||||
@Test
|
||||
public void testForEachLoop() {
|
||||
void testForEachLoop() {
|
||||
ASTAstRoot node = js.parse("for each (var item in items) {}");
|
||||
ASTForInLoop loop = (ASTForInLoop) node.getChild(0);
|
||||
Assert.assertFalse(loop.isForOf());
|
||||
Assert.assertTrue(loop.isForEach());
|
||||
assertFalse(loop.isForOf());
|
||||
assertTrue(loop.isForEach());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testForOfLoop() {
|
||||
void testForOfLoop() {
|
||||
ASTAstRoot node = js.parse("for (var item of items) {}");
|
||||
ASTForInLoop loop = (ASTForInLoop) node.getChild(0);
|
||||
Assert.assertTrue(loop.isForOf());
|
||||
Assert.assertFalse(loop.isForEach());
|
||||
assertTrue(loop.isForOf());
|
||||
assertFalse(loop.isForEach());
|
||||
}
|
||||
}
|
||||
|
@ -4,27 +4,29 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class ASTFunctionNodeTest extends EcmascriptParserTestBase {
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class ASTFunctionNodeTest extends EcmascriptParserTestBase {
|
||||
|
||||
@Test
|
||||
public void testGetBody() {
|
||||
ASTAstRoot node = js.parse("function foo() { var a = 'a'; }");
|
||||
ASTFunctionNode fn = node.getFirstDescendantOfType(ASTFunctionNode.class);
|
||||
Assert.assertFalse(fn.isClosure());
|
||||
assertFalse(fn.isClosure());
|
||||
EcmascriptNode<?> body = fn.getBody();
|
||||
Assert.assertTrue(body instanceof ASTBlock);
|
||||
assertTrue(body instanceof ASTBlock);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetBodyFunctionClosureExpression() {
|
||||
void testGetBodyFunctionClosureExpression() {
|
||||
ASTAstRoot node = js.parse("(function(x) x*x)");
|
||||
ASTFunctionNode fn = node.getFirstDescendantOfType(ASTFunctionNode.class);
|
||||
Assert.assertTrue(fn.isClosure());
|
||||
assertTrue(fn.isClosure());
|
||||
EcmascriptNode<?> body = fn.getBody();
|
||||
Assert.assertTrue(body instanceof ASTBlock);
|
||||
Assert.assertTrue(body.getChild(0) instanceof ASTReturnStatement);
|
||||
assertTrue(body instanceof ASTBlock);
|
||||
assertTrue(body.getChild(0) instanceof ASTReturnStatement);
|
||||
}
|
||||
}
|
||||
|
@ -4,66 +4,71 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mozilla.javascript.ast.AstRoot;
|
||||
|
||||
/**
|
||||
* See the following bugs: #1141 ECMAScript: getFinallyBlock() is buggy. #1142
|
||||
* ECMAScript: getCatchClause() is buggy
|
||||
*/
|
||||
public class ASTTryStatementTest extends EcmascriptParserTestBase {
|
||||
class ASTTryStatementTest extends EcmascriptParserTestBase {
|
||||
|
||||
private ASTTryStatement getTryStmt(String js) {
|
||||
EcmascriptNode<AstRoot> node = this.js.parse(js);
|
||||
List<ASTTryStatement> trys = node.findDescendantsOfType(ASTTryStatement.class);
|
||||
Assert.assertEquals(1, trys.size());
|
||||
assertEquals(1, trys.size());
|
||||
ASTTryStatement tryStmt = trys.get(0);
|
||||
return tryStmt;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFinallyBlockOnly() {
|
||||
void testFinallyBlockOnly() {
|
||||
ASTTryStatement tryStmt = getTryStmt("function() { try { } finally { } }");
|
||||
Assert.assertNull(tryStmt.getCatchClause(0));
|
||||
Assert.assertFalse(tryStmt.hasCatch());
|
||||
Assert.assertEquals(0, tryStmt.getNumCatchClause());
|
||||
Assert.assertNotNull(tryStmt.getFinallyBlock());
|
||||
Assert.assertTrue(tryStmt.hasFinally());
|
||||
assertNull(tryStmt.getCatchClause(0));
|
||||
assertFalse(tryStmt.hasCatch());
|
||||
assertEquals(0, tryStmt.getNumCatchClause());
|
||||
assertNotNull(tryStmt.getFinallyBlock());
|
||||
assertTrue(tryStmt.hasFinally());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCatchBlockOnly() {
|
||||
void testCatchBlockOnly() {
|
||||
ASTTryStatement tryStmt = getTryStmt("function() { try { } catch (error) { } }");
|
||||
Assert.assertNotNull(tryStmt.getCatchClause(0));
|
||||
Assert.assertTrue(tryStmt.hasCatch());
|
||||
Assert.assertEquals(1, tryStmt.getNumCatchClause());
|
||||
Assert.assertNull(tryStmt.getFinallyBlock());
|
||||
Assert.assertFalse(tryStmt.hasFinally());
|
||||
assertNotNull(tryStmt.getCatchClause(0));
|
||||
assertTrue(tryStmt.hasCatch());
|
||||
assertEquals(1, tryStmt.getNumCatchClause());
|
||||
assertNull(tryStmt.getFinallyBlock());
|
||||
assertFalse(tryStmt.hasFinally());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCatchAndFinallyBlock() {
|
||||
void testCatchAndFinallyBlock() {
|
||||
ASTTryStatement tryStmt = getTryStmt("function() { try { } catch (error) { } finally { } }");
|
||||
Assert.assertNotNull(tryStmt.getCatchClause(0));
|
||||
Assert.assertTrue(tryStmt.hasCatch());
|
||||
Assert.assertEquals(1, tryStmt.getNumCatchClause());
|
||||
Assert.assertNotNull(tryStmt.getFinallyBlock());
|
||||
Assert.assertTrue(tryStmt.hasFinally());
|
||||
assertNotNull(tryStmt.getCatchClause(0));
|
||||
assertTrue(tryStmt.hasCatch());
|
||||
assertEquals(1, tryStmt.getNumCatchClause());
|
||||
assertNotNull(tryStmt.getFinallyBlock());
|
||||
assertTrue(tryStmt.hasFinally());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleCatchAndFinallyBlock() {
|
||||
void testMultipleCatchAndFinallyBlock() {
|
||||
ASTTryStatement tryStmt = getTryStmt(
|
||||
"function() { " + "try { } " + "catch (error if error instanceof BadError) { } "
|
||||
+ "catch (error2 if error2 instanceof OtherError) { } " + "finally { } }");
|
||||
Assert.assertNotNull(tryStmt.getCatchClause(0));
|
||||
Assert.assertNotNull(tryStmt.getCatchClause(1));
|
||||
Assert.assertTrue(tryStmt.hasCatch());
|
||||
Assert.assertEquals(2, tryStmt.getNumCatchClause());
|
||||
Assert.assertNotNull(tryStmt.getFinallyBlock());
|
||||
Assert.assertTrue(tryStmt.hasFinally());
|
||||
assertNotNull(tryStmt.getCatchClause(0));
|
||||
assertNotNull(tryStmt.getCatchClause(1));
|
||||
assertTrue(tryStmt.hasCatch());
|
||||
assertEquals(2, tryStmt.getNumCatchClause());
|
||||
assertNotNull(tryStmt.getFinallyBlock());
|
||||
assertTrue(tryStmt.hasFinally());
|
||||
}
|
||||
}
|
||||
|
@ -5,20 +5,22 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class ASTVariableDeclarationTest extends EcmascriptParserTestBase {
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class ASTVariableDeclarationTest extends EcmascriptParserTestBase {
|
||||
|
||||
@Test
|
||||
public void testLet() {
|
||||
void testLet() {
|
||||
ASTAstRoot node = js.parse("let x = 1;");
|
||||
ASTVariableDeclaration varDecl = (ASTVariableDeclaration) node.getChild(0);
|
||||
Assert.assertTrue(varDecl.isLet());
|
||||
assertTrue(varDecl.isLet());
|
||||
|
||||
ASTVariableInitializer varInit = (ASTVariableInitializer) varDecl.getChild(0);
|
||||
ASTName name = (ASTName) varInit.getChild(0);
|
||||
Assert.assertEquals("x", name.getImage());
|
||||
assertEquals("x", name.getImage());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,15 +4,16 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.mozilla.javascript.ast.AstRoot;
|
||||
|
||||
import net.sourceforge.pmd.PMD;
|
||||
@ -20,13 +21,13 @@ import net.sourceforge.pmd.Report;
|
||||
import net.sourceforge.pmd.lang.ast.Node;
|
||||
import net.sourceforge.pmd.lang.ecmascript.rule.AbstractEcmascriptRule;
|
||||
|
||||
public class EcmascriptParserTest extends EcmascriptParserTestBase {
|
||||
class EcmascriptParserTest extends EcmascriptParserTestBase {
|
||||
|
||||
/**
|
||||
* https://sourceforge.net/p/pmd/bugs/1043/
|
||||
*/
|
||||
@Test
|
||||
public void testLineNumbers() {
|
||||
void testLineNumbers() {
|
||||
final String SOURCE_CODE = "function a() {" + PMD.EOL + " alert('hello');" + PMD.EOL + "}" + PMD.EOL;
|
||||
EcmascriptNode<AstRoot> node = js.parse(SOURCE_CODE);
|
||||
assertEquals(1, node.getBeginLine());
|
||||
@ -51,7 +52,7 @@ public class EcmascriptParserTest extends EcmascriptParserTestBase {
|
||||
* https://sourceforge.net/p/pmd/bugs/1149/
|
||||
*/
|
||||
@Test
|
||||
public void testLineNumbersWithinEcmascriptRules() {
|
||||
void testLineNumbersWithinEcmascriptRules() {
|
||||
String source =
|
||||
"function f(x){\n"
|
||||
+ " if (x) {\n"
|
||||
@ -72,7 +73,7 @@ public class EcmascriptParserTest extends EcmascriptParserTestBase {
|
||||
rule.setLanguage(js.getLanguage());
|
||||
Report report = js.executeRule(rule, source);
|
||||
|
||||
assertEquals("Expecting 2 violations", 2, report.getViolations().size());
|
||||
assertEquals(2, report.getViolations().size(), "Expecting 2 violations");
|
||||
assertEquals("Scope from 2 to 4", report.getViolations().get(0).getDescription());
|
||||
assertEquals("Scope from 4 to 6", report.getViolations().get(1).getDescription());
|
||||
}
|
||||
@ -81,7 +82,7 @@ public class EcmascriptParserTest extends EcmascriptParserTestBase {
|
||||
* Test bug https://sourceforge.net/p/pmd/bugs/1118/
|
||||
*/
|
||||
@Test
|
||||
public void testArrayAccess() {
|
||||
void testArrayAccess() {
|
||||
EcmascriptNode<AstRoot> node = js.parse("function a() { b['a'] = 1; c[1] = 2; }");
|
||||
List<ASTElementGet> arrays = node.findDescendantsOfType(ASTElementGet.class);
|
||||
assertEquals("b", arrays.get(0).getTarget().getImage());
|
||||
@ -95,7 +96,7 @@ public class EcmascriptParserTest extends EcmascriptParserTestBase {
|
||||
* getRight()
|
||||
*/
|
||||
@Test
|
||||
public void testArrayMethod() {
|
||||
void testArrayMethod() {
|
||||
EcmascriptNode<AstRoot> rootNode = js.parse(
|
||||
"function test(){\n" + " a(); // OK\n" + " b.c(); // OK\n" + " d[0](); // OK\n"
|
||||
+ " e[0].f(); // OK\n" + " y.z[0](); // FAIL ==> java.lang.NullPointerException\n" + "}");
|
||||
@ -130,7 +131,7 @@ public class EcmascriptParserTest extends EcmascriptParserTestBase {
|
||||
* valid statements!
|
||||
*/
|
||||
@Test
|
||||
public void testCaseAsIdentifier() {
|
||||
void testCaseAsIdentifier() {
|
||||
ASTAstRoot rootNode = js.parse("function f(a){\n" + " a.case.flag = 1;\n" + " return;\n" + "}");
|
||||
ASTBlock block = rootNode.getFirstDescendantOfType(ASTBlock.class);
|
||||
assertFalse(block.getChild(0) instanceof ASTEmptyExpression);
|
||||
@ -143,7 +144,7 @@ public class EcmascriptParserTest extends EcmascriptParserTestBase {
|
||||
* not implemented) with ECMAscript
|
||||
*/
|
||||
@Test
|
||||
public void testSuppressionComment() {
|
||||
void testSuppressionComment() {
|
||||
ASTAstRoot root = js.parse("function(x) {\n"
|
||||
+ "x = x; //NOPMD I know what I'm doing\n"
|
||||
+ "}\n");
|
||||
@ -160,7 +161,7 @@ public class EcmascriptParserTest extends EcmascriptParserTestBase {
|
||||
* #1191 Ecmascript fails to parse "void(0)"
|
||||
*/
|
||||
@Test
|
||||
public void testVoidKeyword() {
|
||||
void testVoidKeyword() {
|
||||
ASTAstRoot rootNode = js.parse("function f(matchFn, fieldval, n){\n"
|
||||
+ " return (matchFn)?(matcharray = eval(matchFn+\"('\"+fieldval+\"','\"+n.id+\"')\")):void(0);\n"
|
||||
+ "}\n");
|
||||
@ -172,7 +173,7 @@ public class EcmascriptParserTest extends EcmascriptParserTestBase {
|
||||
* #1192 Ecmascript fails to parse this operator " ^= "
|
||||
*/
|
||||
@Test
|
||||
public void testXorAssignment() {
|
||||
void testXorAssignment() {
|
||||
ASTAstRoot rootNode = js.parse("function f() { var x = 2; x ^= 2; x &= 2; x |= 2; "
|
||||
+ "x &&= true; x ||= false; x *= 2; x /= 2; x %= 2; x += 2; x -= 2; "
|
||||
+ "x <<= 2; x >>= 2; x >>>= 2; }");
|
||||
@ -181,7 +182,7 @@ public class EcmascriptParserTest extends EcmascriptParserTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnicodeCjk() {
|
||||
void testUnicodeCjk() {
|
||||
// the first is u+4F60
|
||||
js.parse("import { Test } from 'test2'\n"
|
||||
+ "define('element', class extends Test {\n"
|
||||
@ -193,8 +194,9 @@ public class EcmascriptParserTest extends EcmascriptParserTestBase {
|
||||
/**
|
||||
* [javascript] Failing with OutOfMemoryError parsing a Javascript file #2081
|
||||
*/
|
||||
@Test(timeout = 5000L)
|
||||
public void shouldNotFailWithOutOfMemory() {
|
||||
@Test
|
||||
@Timeout(5)
|
||||
void shouldNotFailWithOutOfMemory() {
|
||||
ASTAstRoot rootNode = js.parse("(``\n);");
|
||||
assertNotNull(rootNode);
|
||||
}
|
||||
|
@ -5,14 +5,14 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import net.sourceforge.pmd.lang.ast.test.BaseParsingHelper;
|
||||
import net.sourceforge.pmd.lang.ast.test.BaseTreeDumpTest;
|
||||
import net.sourceforge.pmd.lang.ast.test.NodePrintersKt;
|
||||
|
||||
public class JsTreeDumpTest extends BaseTreeDumpTest {
|
||||
public JsTreeDumpTest() {
|
||||
class JsTreeDumpTest extends BaseTreeDumpTest {
|
||||
JsTreeDumpTest() {
|
||||
super(NodePrintersKt.getSimpleNodePrinter(), ".js");
|
||||
}
|
||||
|
||||
@ -22,27 +22,27 @@ public class JsTreeDumpTest extends BaseTreeDumpTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void simpleJavascriptFile() {
|
||||
void simpleJavascriptFile() {
|
||||
doTest("SimpleJavascriptFile");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void jquerySelector() {
|
||||
void jquerySelector() {
|
||||
doTest("jquery-selector");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decorators() {
|
||||
void decorators() {
|
||||
doTest("decorators");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void templateStrings() {
|
||||
void templateStrings() {
|
||||
doTest("templateStrings");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void issue3948() {
|
||||
void issue3948() {
|
||||
// https://github.com/pmd/pmd/issues/3948
|
||||
doTest("issue3948");
|
||||
}
|
||||
|
@ -4,38 +4,42 @@
|
||||
|
||||
package net.sourceforge.pmd.lang.ecmascript.ast;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TrailingCommaTest extends EcmascriptParserTestBase {
|
||||
|
||||
@Rule
|
||||
public DefaultLocale defaultLocale = new DefaultLocale();
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class TrailingCommaTest extends EcmascriptParserTestBase {
|
||||
|
||||
@Test
|
||||
public void testTrailingCommaDefaultLocale() {
|
||||
void testTrailingCommaDefaultLocale() {
|
||||
testTrailingComma();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTrailingCommaFrFr() {
|
||||
defaultLocale.set(Locale.FRANCE);
|
||||
testTrailingComma();
|
||||
void testTrailingCommaFrFr() {
|
||||
runWithLocale(Locale.FRANCE, () -> testTrailingComma());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTrailingCommaRootLocale() {
|
||||
defaultLocale.set(Locale.ROOT);
|
||||
testTrailingComma();
|
||||
void testTrailingCommaRootLocale() {
|
||||
runWithLocale(Locale.ROOT, () -> testTrailingComma());
|
||||
}
|
||||
|
||||
public void testTrailingComma() {
|
||||
private void testTrailingComma() {
|
||||
ASTAstRoot node = js.parse("x = {a : 1, };\n");
|
||||
ASTObjectLiteral fn = node.getFirstDescendantOfType(ASTObjectLiteral.class);
|
||||
Assert.assertTrue(fn.isTrailingComma());
|
||||
assertTrue(fn.isTrailingComma());
|
||||
}
|
||||
|
||||
private void runWithLocale(Locale locale, Runnable runnable) {
|
||||
Locale prev = Locale.getDefault();
|
||||
try {
|
||||
Locale.setDefault(locale);
|
||||
runnable.run();
|
||||
} finally {
|
||||
Locale.setDefault(prev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.ecmascript.rule.bestpractices;
|
||||
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
public class AvoidWithStatementTest extends PmdRuleTst {
|
||||
class AvoidWithStatementTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.ecmascript.rule.bestpractices;
|
||||
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
public class ConsistentReturnTest extends PmdRuleTst {
|
||||
class ConsistentReturnTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.ecmascript.rule.bestpractices;
|
||||
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
public class GlobalVariableTest extends PmdRuleTst {
|
||||
class GlobalVariableTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.ecmascript.rule.bestpractices;
|
||||
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
public class ScopeForInVariableTest extends PmdRuleTst {
|
||||
class ScopeForInVariableTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.ecmascript.rule.bestpractices;
|
||||
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
public class UseBaseWithParseIntTest extends PmdRuleTst {
|
||||
class UseBaseWithParseIntTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.ecmascript.rule.codestyle;
|
||||
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
public class AssignmentInOperandTest extends PmdRuleTst {
|
||||
class AssignmentInOperandTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.ecmascript.rule.codestyle;
|
||||
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
public class ForLoopsMustUseBracesTest extends PmdRuleTst {
|
||||
class ForLoopsMustUseBracesTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.ecmascript.rule.codestyle;
|
||||
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
public class IfElseStmtsMustUseBracesTest extends PmdRuleTst {
|
||||
class IfElseStmtsMustUseBracesTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.ecmascript.rule.codestyle;
|
||||
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
public class IfStmtsMustUseBracesTest extends PmdRuleTst {
|
||||
class IfStmtsMustUseBracesTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.ecmascript.rule.codestyle;
|
||||
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
public class NoElseReturnTest extends PmdRuleTst {
|
||||
class NoElseReturnTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.ecmascript.rule.codestyle;
|
||||
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
public class UnnecessaryBlockTest extends PmdRuleTst {
|
||||
class UnnecessaryBlockTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.ecmascript.rule.codestyle;
|
||||
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
public class UnnecessaryParenthesesTest extends PmdRuleTst {
|
||||
class UnnecessaryParenthesesTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.ecmascript.rule.codestyle;
|
||||
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
public class UnreachableCodeTest extends PmdRuleTst {
|
||||
class UnreachableCodeTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.ecmascript.rule.codestyle;
|
||||
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
public class WhileLoopsMustUseBracesTest extends PmdRuleTst {
|
||||
class WhileLoopsMustUseBracesTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.ecmascript.rule.errorprone;
|
||||
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
public class AvoidTrailingCommaTest extends PmdRuleTst {
|
||||
class AvoidTrailingCommaTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.ecmascript.rule.errorprone;
|
||||
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
public class EqualComparisonTest extends PmdRuleTst {
|
||||
class EqualComparisonTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
||||
|
@ -6,6 +6,6 @@ package net.sourceforge.pmd.lang.ecmascript.rule.errorprone;
|
||||
|
||||
import net.sourceforge.pmd.testframework.PmdRuleTst;
|
||||
|
||||
public class InnaccurateNumericLiteralTest extends PmdRuleTst {
|
||||
class InnaccurateNumericLiteralTest extends PmdRuleTst {
|
||||
// no additional unit tests
|
||||
}
|
||||
|
Reference in New Issue
Block a user