Skip to content

Commit 7e408a0

Browse files
authored
Fix outerloop NonBacktracking test throwing argument exception (#66693)
1 parent a73eb7b commit 7e408a0

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.KnownPattern.Tests.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1431,11 +1431,20 @@ public async Task PatternsDataSet_ConstructRegexForAll_NonBacktracking()
14311431
{
14321432
foreach (DataSetExpression exp in s_patternsDataSet.Value)
14331433
{
1434+
if ((exp.Options & (RegexOptions.ECMAScript | RegexOptions.RightToLeft)) != 0)
1435+
{
1436+
// Unsupported options with NonBacktracking
1437+
continue;
1438+
}
1439+
14341440
try
14351441
{
14361442
await RegexHelpers.GetRegexAsync(RegexEngine.NonBacktracking, exp.Pattern, exp.Options);
14371443
}
1438-
catch (Exception e) when (e.Message.Contains(nameof(RegexOptions.NonBacktracking))) { }
1444+
catch (NotSupportedException e) when (e.Message.Contains(nameof(RegexOptions.NonBacktracking)))
1445+
{
1446+
// Unsupported patterns
1447+
}
14391448
}
14401449
}
14411450

0 commit comments

Comments
 (0)