提交 ef5c0c84 编写于 作者: T Ty Overby 提交者: GitHub

add end to end stack depth test (#16729)

* add end to end stack depth test

* add comment explaining test

* switch to verify diagnostics

* turn parallel build off

* check pointer size in addition to debug/release
上级 dee2f952
......@@ -145,6 +145,7 @@
<Compile Include="Emit\EmitMetadata.cs" />
<Compile Include="Emit\EmitMetadataTestBase.cs" />
<Compile Include="Attributes\EmitTestStrongNameProvider.cs" />
<Compile Include="Emit\EndToEndTests.cs" />
<Compile Include="Emit\EntryPointTests.cs" />
<Compile Include="Emit\NoPiaEmbedTypes.cs" />
<Compile Include="Emit\OptionalArgumentsTests.cs" />
......
using Roslyn.Test.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
using Microsoft.CodeAnalysis.Test.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Emit
{
public class EndToEndTests: EmitMetadataTestBase
{
// This test is a canary attempting to make sure that we don't regress the # of fluent calls that
// the compiler can handle.
[WorkItem(16669, "https://github.com/dotnet/roslyn/issues/16669")]
[Fact]
public void OverflowOnFluentCall()
{
int numberFluentCalls = 0;
#if DEBUG
bool isDebug = true;
#else
bool isDebug = false;
#endif
switch (IntPtr.Size * 8) {
case 32 when isDebug:
numberFluentCalls = 290;
break;
case 32 when !isDebug:
numberFluentCalls = 590;
break;
case 64 when isDebug:
numberFluentCalls = 110;
break;
case 64 when !isDebug:
numberFluentCalls = 310;
break;
default:
throw new Exception($"unexpected pointer size {IntPtr.Size}");
}
string MakeCode()
{
var builder = new StringBuilder();
builder.AppendLine(
@"class C {
C M(string x) { return this; }
void M2() {
new C()
");
for (int i = 0; i < numberFluentCalls; i++)
{
builder.AppendLine(@" .M(""test"")");
}
builder.AppendLine(
@" .M(""test"");
}
}");
return builder.ToString();
}
var source = MakeCode();
var thread = new System.Threading.Thread(() =>
{
var options = new CSharpCompilationOptions(outputKind: OutputKind.DynamicallyLinkedLibrary, concurrentBuild: false);
var compilation = CreateCompilationWithMscorlib(source, options: options);
compilation.VerifyDiagnostics();
compilation.EmitToArray();
}, 0);
thread.Start();
thread.Join();
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册