提交 ad062ce1 编写于 作者: J Julien Couvreur 提交者: GitHub

Add test for sequence point for deconstruction (#21809)

上级 eec7d64b
......@@ -6861,6 +6861,52 @@ public void SyntaxOffset_TupleDeconstruction()
</symbols>");
}
[Fact]
public void TestDeconstruction()
{
var source = @"
public class C
{
public static (int, int) F() => (1, 2);
public static void Main()
{
int x, y;
(x, y) = F();
System.Console.WriteLine(x + y);
}
}
";
var c = CreateStandardCompilation(source, new[] { ValueTupleRef, SystemRuntimeFacadeRef }, options: TestOptions.DebugDll);
var v = CompileAndVerify(c);
v.VerifyIL("C.Main", @"
{
// Code size 29 (0x1d)
.maxstack 2
.locals init (int V_0, //x
int V_1) //y
// sequence point: {
IL_0000: nop
// sequence point: (x, y) = F();
IL_0001: call ""(int, int) C.F()""
IL_0006: dup
IL_0007: ldfld ""int System.ValueTuple<int, int>.Item1""
IL_000c: stloc.0
IL_000d: ldfld ""int System.ValueTuple<int, int>.Item2""
IL_0012: stloc.1
// sequence point: System.Console.WriteLine(x + y);
IL_0013: ldloc.0
IL_0014: ldloc.1
IL_0015: add
IL_0016: call ""void System.Console.WriteLine(int)""
IL_001b: nop
// sequence point: }
IL_001c: ret
}
", sequencePoints: "C.Main", source: source);
}
[Fact]
public void SyntaxOffset_TupleParenthesized()
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册