public void TestQuantifierConversion()
 {
     Assert.AreEqual("\\w+", Sublime3Format.CompileRegex("\\w++"));
     Assert.AreEqual("\\w*", Sublime3Format.CompileRegex("\\w**"));
     Assert.AreEqual("[A-Z]*", Sublime3Format.CompileRegex("[A-Z]*+"));
     Assert.AreEqual("[A-Z]*", Sublime3Format.CompileRegex("[A-Z]+*"));
 }
        public void TestCharacterClassBug()
        {
            Assert.AreEqual("(<!)(DOCTYPE)\\s+([\\w:_][\\w\\d-.:_]*)", Sublime3Format.CompileRegex("(<!)(DOCTYPE)\\s+([:a-zA-Z_][:a-zA-Z0-9_.-]*)"));
            Assert.AreEqual("[\\w\\d-_]+", Sublime3Format.CompileRegex("[-_a-zA-Z0-9]+"));
            Assert.AreEqual("\\[(\\\\]|[^\\]])*\\]", Sublime3Format.CompileRegex("\\[(\\\\]|[^\\]])*\\]"));

            Assert.AreEqual("[\\p{Lu}]", Sublime3Format.CompileRegex("[\\p{Lu}]"));
        }
 public void TestPosixBracketExpressionsInCharacterClass()
 {
     Assert.AreEqual("[\\w\\d_]", Sublime3Format.CompileRegex("[_[:alnum:]]"));
     Assert.AreEqual("[\\w_]", Sublime3Format.CompileRegex("[_[:alpha:]]"));
     Assert.AreEqual("[\\d_]", Sublime3Format.CompileRegex("[_[:digit:]]"));
     Assert.AreEqual("[_a-z]", Sublime3Format.CompileRegex("[_[:lower:]]"));
     Assert.AreEqual("[A-Z_]", Sublime3Format.CompileRegex("[_[:upper:]]"));
     Assert.AreEqual("[\\dA-F_a-f]", Sublime3Format.CompileRegex("[_[:xdigit:]]"));
 }
 public void TestPOSIXBracketExpressions()
 {
     Assert.AreEqual("[\\w\\d]", Sublime3Format.CompileRegex("[:alnum:]"));
     Assert.AreEqual("[\\w]", Sublime3Format.CompileRegex("[:alpha:]"));
     Assert.AreEqual("[\\t ]", Sublime3Format.CompileRegex("[:blank:]"));
     Assert.AreEqual("[\\d]", Sublime3Format.CompileRegex("[:digit:]"));
     Assert.AreEqual("[\\S]", Sublime3Format.CompileRegex("[:graph:]"));
     Assert.AreEqual("[a-z]", Sublime3Format.CompileRegex("[:lower:]"));
     Assert.AreEqual("[\\S ]", Sublime3Format.CompileRegex("[:print:]"));
     Assert.AreEqual("[\\s]", Sublime3Format.CompileRegex("[:space:]"));
     Assert.AreEqual("[A-Z]", Sublime3Format.CompileRegex("[:upper:]"));
     Assert.AreEqual("[\\dA-Fa-f]", Sublime3Format.CompileRegex("[:xdigit:]"));
 }
示例#5
0
 Regex ReadSetting(string settingName)
 {
     foreach (var setting in SyntaxHighlightingService.GetSettings(scope))
     {
         PObject val;
         if (setting.TryGetSetting(settingName, out val))
         {
             try {
                 return(new Regex(Sublime3Format.CompileRegex(((PString)val).Value)));
             } catch (Exception e) {
                 LoggingService.LogError("Error while parsing " + settingName + ": " + val, e);
             }
         }
     }
     return(null);
 }
 public void TestMarkdownBugs()
 {
     Assert.AreEqual(@"a*", Sublime3Format.CompileRegex(@"a?+"));
 }
 public void TestGroupNameCorrection()
 {
     Assert.AreEqual("(?<id_id2>[\\w_]*)", Sublime3Format.CompileRegex("(?<id-id2>[A-Z_a-z]*)"));
 }
 public void TestGroupReplacement()
 {
     Assert.AreEqual("(?<id>[\\w_]*)\\s*\\k<id>", Sublime3Format.CompileRegex("(?<id>[A-Z_a-z]*)\\s*\\g<id>"));
 }
 public void TestComment()
 {
     Assert.AreEqual("test ", Sublime3Format.CompileRegex("test # comment"));
 }
 public void TestEscapeBug()
 {
     Assert.AreEqual("\\[", Sublime3Format.CompileRegex("\\["));
 }
 public void TestEscapes()
 {
     Assert.AreEqual("[\\t]", Sublime3Format.CompileRegex("[\\t]"));
     Assert.AreEqual("[,\\[\\]{}]", Sublime3Format.CompileRegex("[,\\[\\]{},]"));
 }
 public void TestMinusCHar()
 {
     Assert.AreEqual("[-:?]", Sublime3Format.CompileRegex("[?:-]"));
     Assert.AreEqual("[+-]", Sublime3Format.CompileRegex("[+-]"));
 }
 public void TestCharConversion()
 {
     Assert.AreEqual("[.]", Sublime3Format.CompileRegex("[.]"));
 }
 public void TestNestedCharacterClasses()
 {
     Assert.AreEqual("[\\da-z]", Sublime3Format.CompileRegex("[a-z[0-9]]"));
 }
 public void TestBug60055()
 {
     Assert.AreEqual("\\*=|(?<!\\()/=|%=|\\+=|\\-=", Sublime3Format.CompileRegex("\\*=|(?<!\\()/=|%=|\\+=|\\-="));
     Assert.AreEqual("(?<=[!(+,=?\\[])", Sublime3Format.CompileRegex("(?<=[=(,\\[?+!])"));
 }
 public void TestCharacterProperties()
 {
     Assert.AreEqual("[0-9a-fA-F]", Sublime3Format.CompileRegex("\\p{XDigit}"));
 }
 public void TestGroupNameCorrection_Case2()
 {
     Assert.AreEqual("(?<interface_name>\\k<type_name>\\s*\\.\\s*)?", Sublime3Format.CompileRegex("(?<interface-name>\\g<type-name>\\s*\\.\\s*)?"));
 }
示例#18
0
 public void TestBug589495()
 {
     Assert.AreEqual("(\\$?\\$)[%*+<?@^]", Sublime3Format.CompileRegex("(\\$?\\$)[@%<?^+*]"));
 }