From a015835756fdb0e90b7aba16b16d526a2d123fa6 Mon Sep 17 00:00:00 2001 From: Sashko <908526+oleksandr-shvets@users.noreply.github.com> Date: Wed, 21 Feb 2024 23:06:20 +0200 Subject: [PATCH] Update UnnecessaryBlockTest.java --- .../rule/codestyle/UnnecessaryBlockTest.java | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/rule/codestyle/UnnecessaryBlockTest.java b/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/rule/codestyle/UnnecessaryBlockTest.java index 53c6ceb9c4..1ef8340778 100644 --- a/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/rule/codestyle/UnnecessaryBlockTest.java +++ b/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/rule/codestyle/UnnecessaryBlockTest.java @@ -1,11 +1,32 @@ -/** - * BSD-style license; for more info see http://pmd.sourceforge.net/license.html - */ - package net.sourceforge.pmd.lang.ecmascript.rule.codestyle; import net.sourceforge.pmd.testframework.PmdRuleTst; -class UnnecessaryBlockTest extends PmdRuleTst { - // no additional unit tests +public class UnnecessaryBlockTest extends PmdRuleTst { + @Override + public void setUp() { + // Set up any required configurations or resources before running the tests + } + + + public void testUnnecessaryBlockInImportStatement() { + String code = "import { foo } from 'bar';\n" + + "{\n" + + " // Unnecessary block\n" + + "}\n"; + + // Assert that the PMD rule does not flag the unnecessary block within import statement + addSourceCodeTest(code, 0); + } + + public void testUnnecessaryBlockInDestructuringAssignment() { + String code = "const { a, b } = obj;\n" + + "{\n" + + " // Unnecessary block\n" + + "}\n"; + + // Assert that the PMD rule does not flag the unnecessary block within destructuring assignment + addSourceCodeTest(code, 0); + } + }