From 81614bdc793191d2927800d3af85aeacb3ef6b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Kon=C3=AD=C4=8Dek?= Date: Sun, 30 Sep 2018 14:58:51 +0200 Subject: [PATCH] Adding more tests --- ...ompletionListTagCompletionProviderTests.cs | 23 ++- .../TypeInferrer/TypeInferrerTests.cs | 167 +++++++++++++++++- 2 files changed, 187 insertions(+), 3 deletions(-) diff --git a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/EnumAndCompletionListTagCompletionProviderTests.cs b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/EnumAndCompletionListTagCompletionProviderTests.cs index 949f2f82376..2ed12545d9d 100644 --- a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/EnumAndCompletionListTagCompletionProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/EnumAndCompletionListTagCompletionProviderTests.cs @@ -166,7 +166,7 @@ enum Colors [WorkItem(827897, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/827897")] [Fact, Trait(Traits.Feature, Traits.Features.Completion)] - public async Task InYieldReturn() + public async Task InYieldReturnInMethod() { var markup = @"using System; @@ -182,6 +182,27 @@ IEnumerable M() await VerifyItemExistsAsync(markup, "DayOfWeek"); } + [WorkItem(30235, "https://github.com/dotnet/roslyn/issues/30235")] + [Fact, Trait(Traits.Feature, Traits.Features.Completion)] + public async Task InYieldReturnInLocalFunction() + { + var markup = +@"using System; +using System.Collections.Generic; + +class Program +{ + void M() + { + IEnumerable F() + { + yield return $$ + } + } +}"; + await VerifyItemExistsAsync(markup, "DayOfWeek"); + } + [WorkItem(827897, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/827897")] [Fact, Trait(Traits.Feature, Traits.Features.Completion)] public async Task InAsyncMethodReturnStatement() diff --git a/src/EditorFeatures/CSharpTest/TypeInferrer/TypeInferrerTests.cs b/src/EditorFeatures/CSharpTest/TypeInferrer/TypeInferrerTests.cs index 8cd1d17f347..e3e35ecb2da 100644 --- a/src/EditorFeatures/CSharpTest/TypeInferrer/TypeInferrerTests.cs +++ b/src/EditorFeatures/CSharpTest/TypeInferrer/TypeInferrerTests.cs @@ -674,6 +674,26 @@ static void Main(string[] args) await TestAsync(text, "global::System.Int32"); } + [Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)] + public async Task TestReturnInConstructor() + { + await TestInClassAsync( +@"C() +{ + return [|Goo()|]; +}", "void"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)] + public async Task TestReturnInDestructor() + { + await TestInClassAsync( +@"~C() +{ + return [|Goo()|]; +}", "void"); + } + [Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)] public async Task TestReturnInMethod() { @@ -702,10 +722,30 @@ public async Task TestReturnInVoidMethod() } [Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)] - public async Task TestReturnInGetter() + public async Task TestReturnInOperator() + { + await TestInClassAsync( +@"public static C operator ++(C c) +{ + return [|Goo()|]; +}", "global::C"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)] + public async Task TestReturnInConversionOperator() + { + await TestInClassAsync( +@"public static implicit operator int(C c) +{ + return [|Goo()|]; +}", "global::System.Int32"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)] + public async Task TestReturnInPropertyGetter() { await TestInClassAsync( -@"int Property +@"int P { get { @@ -714,6 +754,73 @@ public async Task TestReturnInGetter() }", "global::System.Int32"); } + [Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)] + public async Task TestReturnInPropertySetter() + { + await TestInClassAsync( +@"int P +{ + set + { + return [|Goo()|]; + } +}", "void"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)] + public async Task TestReturnInIndexerGetter() + { + await TestInClassAsync( +@"int this[int i] +{ + get + { + return [|Goo()|]; + } +}", "global::System.Int32"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)] + public async Task TestReturnInIndexerSetter() + { + await TestInClassAsync( +@"int this[int i] +{ + set + { + return [|Goo()|]; + } +}", "void"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)] + public async Task TestReturnInEventAdder() + { + await TestInClassAsync( +@"event System.EventHandler E +{ + add + { + return [|Goo()|]; + } + remove { } +}", "void"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)] + public async Task TestReturnInEventRemover() + { + await TestInClassAsync( +@"event System.EventHandler E +{ + add { } + remove + { + return [|Goo()|]; + } +}", "void"); + } + [Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)] public async Task TestReturnInLocalFunction() { @@ -747,6 +854,13 @@ public async Task TestExpressionBodiedConstructor() @"C() => [|Goo()|];", "void"); } + [Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)] + public async Task TestExpressionBodiedDestructor() + { + await TestInClassAsync( +@"~C() => [|Goo()|];", "void"); + } + [Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)] public async Task TestExpressionBodiedMethod() { @@ -769,6 +883,20 @@ public async Task TestExpressionBodiedVoidMethod() @"void M() => [|Goo()|];", "void"); } + [Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)] + public async Task TestExpressionBodiedOperator() + { + await TestInClassAsync( +@"public static C operator ++(C c) => [|Goo()|];", "global::C"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)] + public async Task TestExpressionBodiedConversionOperator() + { + await TestInClassAsync( +@"public static implicit operator int(C c) => [|Goo()|];", "global::System.Int32"); + } + [Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)] public async Task TestExpressionBodiedProperty() { @@ -776,6 +904,13 @@ public async Task TestExpressionBodiedProperty() @"int P => [|Goo()|];", "global::System.Int32"); } + [Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)] + public async Task TestExpressionBodiedIndexer() + { + await TestInClassAsync( +@"int this[int i] => [|Goo()|];", "global::System.Int32"); + } + [Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)] public async Task TestExpressionBodiedPropertyGetter() { @@ -790,6 +925,34 @@ public async Task TestExpressionBodiedPropertySetter() @"int P { set => [|Goo()|]; }", "void"); } + [Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)] + public async Task TestExpressionBodiedIndexerGetter() + { + await TestInClassAsync( +@"int this[int i] { get => [|Goo()|]; }", "global::System.Int32"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)] + public async Task TestExpressionBodiedIndexerSetter() + { + await TestInClassAsync( +@"int this[int i] { set => [|Goo()|]; }", "void"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)] + public async Task TestExpressionBodiedEventAdder() + { + await TestInClassAsync( +@"event System.EventHandler E { add => [|Goo()|]; remove { } }", "void"); + } + + [Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)] + public async Task TestExpressionBodiedEventRemover() + { + await TestInClassAsync( +@"event System.EventHandler E { add { } remove => [|Goo()|]; }", "void"); + } + [Fact, Trait(Traits.Feature, Traits.Features.TypeInferenceService)] public async Task TestExpressionBodiedLocalFunction() { -- GitLab