Skip to content

Commit

Permalink
Fix existing test cases by optimizing result
Browse files Browse the repository at this point in the history
  • Loading branch information
tats-u committed Apr 20, 2024
1 parent 8418566 commit d72cc70
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 32 deletions.
26 changes: 8 additions & 18 deletions src/Compilers/CSharp/Test/Semantic/Semantics/InterpolationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3653,13 +3653,11 @@ public void TargetTypedInterpolationHoles(string expression)

var verifier = CompileAndVerify(new[] { source, interpolatedStringBuilder }, expectedOutput: @"
value:1
value:2
value:
value:");
value:2");

verifier.VerifyIL("<top-level-statements-entry-point>", @"
{
// Code size 81 (0x51)
// Code size 65 (0x41)
.maxstack 3
.locals init (bool V_0, //b
object V_1,
Expand All @@ -3668,7 +3666,7 @@ .locals init (bool V_0, //b
IL_0001: stloc.0
IL_0002: ldloca.s V_2
IL_0004: ldc.i4.0
IL_0005: ldc.i4.4
IL_0005: ldc.i4.2
IL_0006: call ""System.Runtime.CompilerServices.DefaultInterpolatedStringHandler..ctor(int, int)""
IL_000b: ldloc.0
IL_000c: brfalse.s IL_0017
Expand All @@ -3690,15 +3688,9 @@ .locals init (bool V_0, //b
IL_002e: ldnull
IL_002f: call ""void System.Runtime.CompilerServices.DefaultInterpolatedStringHandler.AppendFormatted(object)""
IL_0034: ldloca.s V_2
IL_0036: ldnull
IL_0037: call ""void System.Runtime.CompilerServices.DefaultInterpolatedStringHandler.AppendFormatted(string)""
IL_003c: ldloca.s V_2
IL_003e: ldnull
IL_003f: call ""void System.Runtime.CompilerServices.DefaultInterpolatedStringHandler.AppendFormatted(string)""
IL_0044: ldloca.s V_2
IL_0046: call ""string System.Runtime.CompilerServices.DefaultInterpolatedStringHandler.ToStringAndClear()""
IL_004b: call ""void System.Console.WriteLine(string)""
IL_0050: ret
IL_0036: call ""string System.Runtime.CompilerServices.DefaultInterpolatedStringHandler.ToStringAndClear()""
IL_003b: call ""void System.Console.WriteLine(string)""
IL_0040: ret
}
");
}
Expand Down Expand Up @@ -16163,11 +16155,9 @@ public void InterpolatedStringsAddedUnderObjectAddition2(string expression)
CompileAndVerify(comp, expectedOutput: @"
(
value:1
),
[
),[
value:2
],
{
],{
value:3
}
");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2057,13 +2057,11 @@ public void TargetTypedInterpolationHoles(string expression)

var verifier = CompileAndVerify(new[] { source, interpolatedStringBuilder }, expectedOutput: @"
value:1
value:2
value:
value:");
value:2");

verifier.VerifyIL("<top-level-statements-entry-point>", @"
{
// Code size 81 (0x51)
// Code size 65 (0x41)
.maxstack 3
.locals init (bool V_0, //b
object V_1,
Expand All @@ -2072,7 +2070,7 @@ .locals init (bool V_0, //b
IL_0001: stloc.0
IL_0002: ldloca.s V_2
IL_0004: ldc.i4.0
IL_0005: ldc.i4.4
IL_0005: ldc.i4.2
IL_0006: call ""System.Runtime.CompilerServices.DefaultInterpolatedStringHandler..ctor(int, int)""
IL_000b: ldloc.0
IL_000c: brfalse.s IL_0017
Expand All @@ -2094,15 +2092,9 @@ .locals init (bool V_0, //b
IL_002e: ldnull
IL_002f: call ""void System.Runtime.CompilerServices.DefaultInterpolatedStringHandler.AppendFormatted(object)""
IL_0034: ldloca.s V_2
IL_0036: ldnull
IL_0037: call ""void System.Runtime.CompilerServices.DefaultInterpolatedStringHandler.AppendFormatted(string)""
IL_003c: ldloca.s V_2
IL_003e: ldnull
IL_003f: call ""void System.Runtime.CompilerServices.DefaultInterpolatedStringHandler.AppendFormatted(string)""
IL_0044: ldloca.s V_2
IL_0046: call ""string System.Runtime.CompilerServices.DefaultInterpolatedStringHandler.ToStringAndClear()""
IL_004b: call ""void System.Console.WriteLine(string)""
IL_0050: ret
IL_0036: call ""string System.Runtime.CompilerServices.DefaultInterpolatedStringHandler.ToStringAndClear()""
IL_003b: call ""void System.Console.WriteLine(string)""
IL_0040: ret
}
");
}
Expand Down

0 comments on commit d72cc70

Please sign in to comment.