Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jcouv committed Sep 26, 2021
1 parent 91cc014 commit 9d4d245
Showing 1 changed file with 68 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3411,6 +3411,74 @@ public void LengthPattern_IsIncomplete()
);
}

[Fact]
public void LengthPattern_IsIncomplete_()
{
// TODO2
var src = @"
int[] a = null;
//_ = a is null or { Length: >= 0};
_ = a switch // 1
{
null => 0,
{ Length: > -1 and < 3 } => 1,
};
_ = a switch
{
null => 0,
{ Length: > -1 and < 3 } => 1,
{ Length: >= 3 } => 1,
};
";
var comp = CreateCompilation(src);
comp.VerifyDiagnostics(
// (4,7): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '{ Length: 3 }' is not covered.
// _ = a switch // 1
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("{ Length: 3 }").WithLocation(4, 7)
);
}

[Fact]
public void LengthPattern_IsIncomplete_2()
{
// TODO2
var src = @"
int[] a = null;
//_ = a is null or { Length: >= 0};
_ = a switch
{
null => 0,
{ Length: 0 } => 1,
{ Length: > 0 } => 1,
};
";
var comp = CreateCompilation(src);
comp.VerifyDiagnostics(
);
}

[Fact]
public void LengthPattern_IsIncomplete_3()
{
// TODO2
var src = @"
int[] a = null;
//_ = a is null or { Length: >= 0};
_ = a switch
{
null => 0,
{ Length: 0 } => 1,
{ Length: > 1 } => 1,
};
";
var comp = CreateCompilation(src);
comp.VerifyDiagnostics(
// (4,7): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '{ Length: 1 }' is not covered.
// _ = a switch
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("{ Length: 1 }").WithLocation(4, 7)
);
}

[Fact]
public void LengthPattern_Evaluation()
{
Expand Down

0 comments on commit 9d4d245

Please sign in to comment.