-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd1a20d
commit 79fef14
Showing
4 changed files
with
1,130 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
languages/csharp/src/test/java/de/jplag/csharp/CSharpTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package de.jplag.csharp; | ||
|
||
import de.jplag.testutils.LanguageModuleTest; | ||
import de.jplag.testutils.datacollector.TestDataCollector; | ||
import de.jplag.testutils.datacollector.TestSourceIgnoredLinesCollector; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static de.jplag.csharp.CSharpTokenType.ACCESSORS_BEGIN; | ||
import static de.jplag.csharp.CSharpTokenType.ACCESSORS_END; | ||
import static de.jplag.csharp.CSharpTokenType.ACCESSOR_BEGIN; | ||
import static de.jplag.csharp.CSharpTokenType.ACCESSOR_END; | ||
import static de.jplag.csharp.CSharpTokenType.ASSIGNMENT; | ||
import static de.jplag.csharp.CSharpTokenType.CLASS; | ||
import static de.jplag.csharp.CSharpTokenType.CLASS_BEGIN; | ||
import static de.jplag.csharp.CSharpTokenType.CLASS_END; | ||
import static de.jplag.csharp.CSharpTokenType.CONSTRUCTOR; | ||
import static de.jplag.csharp.CSharpTokenType.FIELD; | ||
import static de.jplag.csharp.CSharpTokenType.IF; | ||
import static de.jplag.csharp.CSharpTokenType.IF_BEGIN; | ||
import static de.jplag.csharp.CSharpTokenType.IF_END; | ||
import static de.jplag.csharp.CSharpTokenType.INVOCATION; | ||
import static de.jplag.csharp.CSharpTokenType.LOCAL_VARIABLE; | ||
import static de.jplag.csharp.CSharpTokenType.METHOD; | ||
import static de.jplag.csharp.CSharpTokenType.METHOD_BEGIN; | ||
import static de.jplag.csharp.CSharpTokenType.METHOD_END; | ||
import static de.jplag.csharp.CSharpTokenType.PROPERTY; | ||
import static de.jplag.csharp.CSharpTokenType.RETURN; | ||
|
||
public class CSharpTest extends LanguageModuleTest { | ||
public CSharpTest() { | ||
super(new CSharpLanguage(), CSharpTokenType.class); | ||
} | ||
|
||
@Override | ||
protected void collectTestData(TestDataCollector collector) { | ||
collector.testFile("TestClass.cs").testSourceCoverage().testTokenSequence(CLASS, CLASS_BEGIN, FIELD, CONSTRUCTOR, LOCAL_VARIABLE, METHOD, METHOD_BEGIN, IF, IF_BEGIN, | ||
INVOCATION, IF_END, IF_BEGIN, INVOCATION, IF_END, METHOD_END, PROPERTY, ACCESSORS_BEGIN, ACCESSOR_BEGIN, ACCESSOR_END, ACCESSOR_BEGIN, | ||
ACCESSOR_END, ACCESSORS_END, FIELD, PROPERTY, ACCESSORS_BEGIN, ACCESSOR_BEGIN, RETURN, ACCESSOR_END, ACCESSOR_BEGIN, ASSIGNMENT, | ||
ACCESSOR_END, ACCESSORS_END, CLASS_END); | ||
|
||
ArrayList<CSharpTokenType> tokens = new ArrayList<>(List.of(CSharpTokenType.values())); | ||
tokens.remove(CSharpTokenType.INTERFACE_BEGIN); | ||
tokens.remove(CSharpTokenType.INTERFACE_END); | ||
collector.testFile("AllInOneNoPreprocessor.cs")./*testSourceCoverage().*/testContainedTokens(tokens.toArray(CSharpTokenType[]::new)); | ||
} | ||
|
||
@Override | ||
protected void configureIgnoredLines(TestSourceIgnoredLinesCollector collector) { | ||
collector.ignoreMultipleLines("/*", "*/"); | ||
collector.ignoreLinesByPrefix("//"); | ||
collector.ignoreLinesByPrefix("{"); | ||
collector.ignoreLinesByPrefix("}"); | ||
|
||
collector.ignoreLinesByPrefix("extern"); | ||
collector.ignoreLinesByPrefix("using"); | ||
collector.ignoreLinesByPrefix("namespace"); | ||
collector.ignoreLinesByPrefix("base"); | ||
collector.ignoreLinesByPrefix("++"); | ||
|
||
collector.ignoreByCondition(line -> line.trim().matches("[a-zA-Z0-9]+:")); | ||
} | ||
} |
Oops, something went wrong.