Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
gregli-msft committed Mar 6, 2025
1 parent d287205 commit ea86e02
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions docs/regular-expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Lookahead and lookbehind assertions cannot contain submatches or unlimited quant
| Feature | Description |
|---------|---------|
| Dot | `.`, matches everything except `\r` and `\n` unless **MatchOptions.DotAll** is used. |
| Character class | `[abc]` list of characters, `[a-fA-f0-9]` range of characters, `[^a-z]` everything but these characters. Character classes cannot be nested, subtracted, or intersected, and the same character cannot appear twice in the character class (except for a hyphen). |
| Character class | `[abc]` list of characters, `[a-fA-f0-9]` range of characters, `[^a-z]` everything but these characters. Character classes cannot be nested, subtracted, or intersected, and many punctuation marks may not appear twice in a row (`@@`, `%%`, `!!`, etc). |
| Word characters | `\w` and `\W` using the Unicode definition of letters `[\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Pc}\p{Lm}]`. `\W` cannot be used in a negative character class.|
| Digit characters | `\d` includes the digits `0` to`9` and `\p{Nd}`, `\D` matches everything except characters matched by `\d`. `\D` cannot be used in a negative character class.|
| Space characters | `\s` includes spacing characters `[ \r\n\t\f\x0B\x85\p{Z}]`, `\S` which matches everything except characters matched by `\s`, `\r` carriage return, `\n` newline, `\t` tab, `\f` form feed. `\S` cannot be used in a negative character class.|
Expand Down Expand Up @@ -103,8 +103,8 @@ Unicode character categories supported by `\p{}` and `\P{}`:
| Lazy zero or one | `??` matches 0 or 1 times, with as *small* a match as possible. |
| Lazy zero or more | `*?` matches 0 or more times, with as *small* a match as possible. |
| Lazy one or more | `+?` matches 1 or more times, with as *small* a match as possible. |
| Lazy at least n | `{n,}?` matches at least *n* times, with as *small* a match as possible. For example, `a{3,}` will match the first three characters in `aaaaa`. |
| Lazy between n and m | `{n,m}?` matches between *n* and *m* times, with as *small* a match as possible. For example, `a{1,3}` will match the first character of `aaaaa`. |
| Lazy at least n | `{n,}?` matches at least *n* times, with as *small* a match as possible. For example, `a{3,}?` will match only the first three characters in `aaaaa`. |
| Lazy between n and m | `{n,m}?` matches between *n* and *m* times, with as *small* a match as possible. For example, `a{1,3}?` will match only the first character of `aaaaa`. |
| Exact n | `{n}` matches *n* times, exactly. For example, `a{3}` will match exactly 3 characters of `aaaaa`. |

Possessive quantifiers are not supported.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,25 +136,25 @@ public static Dictionary<string, bool> ParseSetupString(string setup)
return settings;
}

public void AddDir(Dictionary<string, bool> setup, Dictionary<string, bool> requiredSetup, string directory = "")
public void AddDir(Dictionary<string, bool> setup, string directory = "")
{
directory = GetFullPath(directory, TestRoot);
var allFiles = Directory.EnumerateFiles(directory);

AddFile(setup, requiredSetup, allFiles);
AddFile(setup, allFiles);
}

public void AddFile(Dictionary<string, bool> setup, Dictionary<string, bool> requiredSetup, params string[] files)
public void AddFile(Dictionary<string, bool> setup, params string[] files)
{
var x = (IEnumerable<string>)files;
AddFile(setup, requiredSetup, x);
AddFile(setup, x);
}

public void AddFile(Dictionary<string, bool> setup, Dictionary<string, bool> requiredSetup, IEnumerable<string> files)
public void AddFile(Dictionary<string, bool> setup, IEnumerable<string> files)
{
foreach (var file in files)
{
AddFile(setup, requiredSetup, file);
AddFile(setup, file);
}
}

Expand All @@ -181,7 +181,7 @@ private static bool TryParseDirective(string line, string directive, out string
}
}

public void AddFile(Dictionary<string, bool> setup, Dictionary<string, bool> requiredSetup, string thisFile)
public void AddFile(Dictionary<string, bool> setup, string thisFile, Dictionary<string, bool> requiredSetup = null)
{
thisFile = GetFullPath(thisFile, TestRoot);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public override IEnumerable<object[]> GetData(MethodInfo testMethod)

if (file.EndsWith(".txt", StringComparison.InvariantCultureIgnoreCase))
{
parser.AddFile(_setup, _requiredSetup, file);
parser.AddFile(_setup, file, _requiredSetup);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ public void TestErrorOverride3()
private static void AddFile(TestRunner runner, string filename)
{
var test1 = GetFullPath(filename, TxtFileDataAttribute.GetDefaultTestDir("TestRunnerTests"));
runner.AddFile(TestRunner.ParseSetupString(string.Empty), null, test1);
runner.AddFile(TestRunner.ParseSetupString(string.Empty), test1);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public void RunOne()
var runner = new InterpreterRunner();
var testRunner = new TestRunner(runner);

testRunner.AddFile(new Dictionary<string, bool>(), null, path);
testRunner.AddFile(new Dictionary<string, bool>(), path);

// We can filter to just cases we want, set line above
if (line > 0)
Expand Down Expand Up @@ -272,7 +272,7 @@ private void RunMutationTestFile(string file, Features features, string setup)

var testRunner = new TestRunner(runner);

testRunner.AddFile(TestRunner.ParseSetupString(setup), null, path);
testRunner.AddFile(TestRunner.ParseSetupString(setup), path);

if (testRunner.Tests.Count > 0 && testRunner.Tests[0].SetupHandlerName.Contains("MutationFunctionsTestSetup"))
{
Expand Down Expand Up @@ -333,7 +333,7 @@ public void ScanNotYetReadyForTxtParseErrors()
var runner = new TestRunner();

// Verify this runs without throwing an exception.
runner.AddDir(new Dictionary<string, bool>(), null, path);
runner.AddDir(new Dictionary<string, bool>(), path);

// Ensure that we actually found tests and not pointed to an empty directory
Assert.True(runner.Tests.Count > 10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ internal static FormulaValue Match(string subject, string pattern, string flags,
break;
}

Dictionary<string, NamedValue> fields = new();
Dictionary<string, NamedValue> fields = new ();

var sc = NativeMethods.pcre2_get_startchar_32(md);
fields.Add(STARTMATCH, new NamedValue(STARTMATCH, NumberValue.New((double)sc + 1)));
Expand Down

0 comments on commit ea86e02

Please sign in to comment.