Skip to content

Commit e8a18e2

Browse files
authored
Add a few RegexGenerator tests for valid string arguments (#69221)
1 parent 2cc7fea commit e8a18e2

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/RegexGeneratorParserTests.cs

+27
Original file line numberDiff line numberDiff line change
@@ -748,5 +748,32 @@ partial class C
748748
private static partial Regex Valid();
749749
}", compile: true, additionalRefs: new[] { MetadataReference.CreateFromImage(referencedAssembly) }));
750750
}
751+
752+
[Fact]
753+
public async Task Valid_ConcatenatedLiteralsArgument()
754+
{
755+
Assert.Empty(await RegexGeneratorHelper.RunGenerator(@"
756+
using System.Text.RegularExpressions;
757+
758+
partial class C
759+
{
760+
[RegexGenerator(""ab"" + ""[cd]"")]
761+
public static partial Regex Valid();
762+
}
763+
", compile: true));
764+
}
765+
766+
[Fact]
767+
public async Task Valid_InterpolatedLiteralsArgument()
768+
{
769+
Assert.Empty(await RegexGeneratorHelper.RunGenerator(@"
770+
using System.Text.RegularExpressions;
771+
772+
partial class C
773+
{
774+
[RegexGenerator($""{""ab""}{""cd""}"")]
775+
public static partial Regex Valid();
776+
}", compile: true));
777+
}
751778
}
752779
}

0 commit comments

Comments
 (0)