提交 8f2f736e 编写于 作者: C Cyrus Najmabadi

Add test

上级 51d64610
......@@ -264,16 +264,26 @@ void Goo(S s)
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseIndexOperator)]
public async Task TestUserDefinedTypeWithNoIndexIndexer()
{
await TestMissingAsync(
await TestInRegularAndScript1Async(
@"
namespace System { public struct Index { } }
struct S { public int Length { get; } public int this[int i] { get; } }
struct S { public int Count { get; } public int this[int i] { get; } }
class C
{
void Goo(S s)
{
var v = s[[||]s.Count - 2];
}
}",
@"
namespace System { public struct Index { } }
struct S { public int Count { get; } public int this[int i] { get; } }
class C
{
void Goo(S s)
{
var v = s[^2];
}
}", parameters: s_testParameters);
}
......@@ -500,6 +510,32 @@ void Goo(List<int> s)
}", parseOptions: s_parseOptions);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseIndexOperator)]
public async Task TestSimple_NoIndexIndexer_SupportsIntIndexer_Set()
{
await TestAsync(
@"
using System.Collections.Generic;
namespace System { public struct Index { } }
class C
{
void Goo(List<int> s)
{
s[[||]s.Count - 1] = 1;
}
}",
@"
using System.Collections.Generic;
namespace System { public struct Index { } }
class C
{
void Goo(List<int> s)
{
s[^1] = 1;
}
}", parseOptions: s_parseOptions);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseIndexOperator)]
public async Task NotOnConstructedIndexer()
{
......
......@@ -144,6 +144,21 @@ void Goo(string s)
}", parseOptions: s_parseOptions);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseRangeOperator)]
public async Task TestNotWithoutSubtraction()
{
await TestMissingInRegularAndScriptAsync(
@"
namespace System { public struct Range { } }
class C
{
void Goo(string s)
{
var v = s.Substring([||]1, 2);
}
}", new TestParameters(parseOptions: s_parseOptions));
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseRangeOperator)]
public async Task TestNonStringType()
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册