未验证 提交 324e9a79 编写于 作者: S Sam Harwell 提交者: GitHub

Merge pull request #43522 from sharwell/brace-completion

Add tests for pattern brace completion
......@@ -363,6 +363,100 @@ void M()
CheckReturn(session.Session, 12, expectedAfterReturn);
}
[WpfFact, Trait(Traits.Feature, Traits.Features.AutomaticCompletion)]
public void RecursivePattern_Nested()
{
var code = @"
class C
{
void M()
{
_ = this is { Name: $$ }
}
}";
var expectedBeforeReturn = @"
class C
{
void M()
{
_ = this is { Name: { } }
}
}";
var expectedAfterReturn = @"
class C
{
void M()
{
_ = this is { Name:
{
} }
}
}";
using var session = CreateSession(code);
Assert.NotNull(session);
CheckStart(session.Session);
CheckText(session.Session, expectedBeforeReturn);
CheckReturn(session.Session, 16, expectedAfterReturn);
}
[WpfFact, Trait(Traits.Feature, Traits.Features.AutomaticCompletion)]
public void RecursivePattern_Parentheses1()
{
var code = @"
class C
{
void M()
{
_ = this is { Name: $$ }
}
}";
var expected = @"
class C
{
void M()
{
_ = this is { Name: () }
}
}";
using var session = CreateSession(TestWorkspace.CreateCSharp(code), '(', ')');
Assert.NotNull(session);
CheckStart(session.Session);
CheckText(session.Session, expected);
}
[WpfFact, Trait(Traits.Feature, Traits.Features.AutomaticCompletion)]
public void RecursivePattern_Parentheses2()
{
var code = @"
class C
{
void M()
{
_ = this is { Name: { Length: (> 3) and $$ } }
}
}";
var expected = @"
class C
{
void M()
{
_ = this is { Name: { Length: (> 3) and () } }
}
}";
using var session = CreateSession(TestWorkspace.CreateCSharp(code), '(', ')');
Assert.NotNull(session);
CheckStart(session.Session);
CheckText(session.Session, expected);
}
[WpfFact, Trait(Traits.Feature, Traits.Features.AutomaticCompletion)]
public void RecursivePattern_FollowedByInvocation()
{
......
......@@ -14,6 +14,7 @@
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.BraceCompletion;
using Microsoft.VisualStudio.Text.Operations;
using Roslyn.Test.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.Editor.UnitTests.AutomaticCompletion
......@@ -87,7 +88,7 @@ internal void CheckReturn(IBraceCompletionSession session, int indentation, stri
if (result != null)
{
Assert.Equal(result, session.SubjectBuffer.CurrentSnapshot.GetText());
AssertEx.EqualOrDiff(result, session.SubjectBuffer.CurrentSnapshot.GetText());
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册