Skip to content

Commit

Permalink
Add test for sequence point for deconstruction (#21809)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcouv authored Aug 30, 2017
1 parent eec7d64 commit ad062ce
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/Compilers/CSharp/Test/Emit/PDB/PDBTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit ad062ce

Please sign in to comment.