forked from CoreASM/coreasm.core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ModularityPlugin: capture quotes directly in pattern
- rename usePattern etc to includePattern, compile only once - add unit test
- Loading branch information
Showing
2 changed files
with
53 additions
and
9 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
42 changes: 42 additions & 0 deletions
42
org.coreasm.engine/test/org/coreasm/engine/test/plugins/modularity/ModularityRegexTest.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,42 @@ | ||
package org.coreasm.engine.test.plugins.modularity; | ||
|
||
import org.coreasm.engine.plugins.modularity.ModularityPlugin; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import org.junit.Test; | ||
|
||
import java.util.regex.Matcher; | ||
|
||
public class ModularityRegexTest { | ||
|
||
@Test | ||
public void testRegex() { | ||
String[] testLines = new String[]{ | ||
"include a", | ||
"include a.b", | ||
"include ..\\a.b", | ||
"include ../a.b", | ||
|
||
// quoted | ||
"include \"a.b\"", | ||
"include \"..\\a.b\"", | ||
"include \"../a.b\"", | ||
|
||
// with white spaces | ||
"\tinclude a", | ||
"include\ta", | ||
"include a\t", | ||
|
||
// with comment at the end | ||
"include a // foo", | ||
"include a /* foo */" | ||
}; | ||
|
||
for (String line : testLines) { | ||
Matcher includeMatcher = ModularityPlugin.includePattern.matcher(line); | ||
|
||
assertTrue(line, includeMatcher.find()); | ||
} | ||
} | ||
} |