More fixes - some tests simply moved to java module

This commit is contained in:
Andreas Dangel
2014-10-05 18:46:34 +02:00
parent 5c548570f6
commit 563a41afd7
8 changed files with 234 additions and 175 deletions

View File

@ -0,0 +1,36 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import net.sourceforge.pmd.lang.LanguageRegistry;
import net.sourceforge.pmd.lang.ecmascript.EcmascriptLanguageModule;
import net.sourceforge.pmd.lang.ecmascript.ast.ASTFunctionNode;
import net.sourceforge.pmd.lang.ecmascript.rule.AbstractEcmascriptRule;
import net.sourceforge.pmd.lang.ecmascript.rule.EcmascriptRuleViolationFactory;
import net.sourceforge.pmd.testframework.RuleTst;
import org.junit.Test;
public class ReportTest extends RuleTst {
@Test
public void testExclusionsInReportWithNOPMDEcmascript() throws Exception {
Report rpt = new Report();
Rule rule = new AbstractEcmascriptRule() {
@Override
public Object visit(ASTFunctionNode node, Object data) {
EcmascriptRuleViolationFactory.INSTANCE.addViolation((RuleContext)data, this, node, "Test", null);
return super.visit(node, data);
}
};
String code = "function(x) // NOPMD test suppress\n"
+ "{ x = 1; }";
runTestFromString(code, rule, rpt, LanguageRegistry.getLanguage(EcmascriptLanguageModule.NAME).getDefaultVersion());
assertTrue(rpt.isEmpty());
assertEquals(1, rpt.getSuppressedRuleViolations().size());
}
}