提交 30f54fb1 编写于 作者: J Jared Parsons

Emit test wokr

上级 75463028
......@@ -63,7 +63,6 @@ public static void Main()
// Diagnostic(ErrorCode.WRN_UseSwitchInsteadOfAttribute).WithArguments(@"/keyfile", "AssemblyKeyFile"),
// Diagnostic(ErrorCode.WRN_UseSwitchInsteadOfAttribute).WithArguments(@"/keycontainer", "AssemblyKeyName")
var c = CreateStandardCompilation(source,
references: new[] { SystemRef },
options: TestOptions.ReleaseDll.WithStrongNameProvider(new DesktopStrongNameProvider()));
c.VerifyDiagnostics(
......@@ -1735,15 +1734,15 @@ void TestET()
}
";
var comp1 = CreateStandardCompilation(source1, options: TestOptions.ReleaseDll.WithStrongNameProvider(s_defaultDesktopProvider), assemblyName: "asm1");
var comp1 = CreateCompilationWithMscorlib45(source1, options: TestOptions.ReleaseDll.WithStrongNameProvider(s_defaultDesktopProvider), assemblyName: "asm1");
comp1.VerifyDiagnostics();
var ref1 = new CSharpCompilationReference(comp1);
var comp2 = CreateStandardCompilation(source2, new[] { ref1 }, options: TestOptions.ReleaseDll.WithStrongNameProvider(s_defaultDesktopProvider), assemblyName: "asm2");
var comp2 = CreateCompilationWithMscorlib45(source2, new[] { ref1 }, options: TestOptions.ReleaseDll.WithStrongNameProvider(s_defaultDesktopProvider), assemblyName: "asm2");
comp2.VerifyDiagnostics();
var ref2 = new CSharpCompilationReference(comp2);
var comp3 = CreateStandardCompilation(source3, new[] { SystemCoreRef, ref1, ref2 }, options: TestOptions.ReleaseDll.WithStrongNameProvider(s_defaultDesktopProvider), assemblyName: "asm3");
var comp3 = CreateCompilationWithMscorlib45(source3, new[] { SystemCoreRef, ref1, ref2 }, options: TestOptions.ReleaseDll.WithStrongNameProvider(s_defaultDesktopProvider), assemblyName: "asm3");
comp3.VerifyDiagnostics();
// Note: calls B.M, not A.M, since asm1 is not accessible.
......@@ -1852,19 +1851,19 @@ void TestET()
}
";
var comp1 = CreateStandardCompilation(source1, options: TestOptions.ReleaseDll.WithStrongNameProvider(s_defaultDesktopProvider), assemblyName: "asm1");
var comp1 = CreateCompilationWithMscorlib45(source1, options: TestOptions.ReleaseDll.WithStrongNameProvider(s_defaultDesktopProvider), assemblyName: "asm1");
comp1.VerifyDiagnostics();
var ref1 = new CSharpCompilationReference(comp1);
var comp2 = CreateStandardCompilation(source2, new[] { ref1 }, options: TestOptions.ReleaseDll.WithStrongNameProvider(s_defaultDesktopProvider), assemblyName: "asm2");
var comp2 = CreateCompilationWithMscorlib45(source2, new[] { ref1 }, options: TestOptions.ReleaseDll.WithStrongNameProvider(s_defaultDesktopProvider), assemblyName: "asm2");
comp2.VerifyDiagnostics();
var ref2 = new CSharpCompilationReference(comp2);
var comp3 = CreateStandardCompilation(source3, new[] { ref1, ref2 }, options: TestOptions.ReleaseDll.WithStrongNameProvider(s_defaultDesktopProvider), assemblyName: "asm3");
var comp3 = CreateCompilationWithMscorlib45(source3, new[] { ref1, ref2 }, options: TestOptions.ReleaseDll.WithStrongNameProvider(s_defaultDesktopProvider), assemblyName: "asm3");
comp3.VerifyDiagnostics();
var ref3 = new CSharpCompilationReference(comp3);
var comp4 = CreateStandardCompilation(source4, new[] { SystemCoreRef, ref1, ref2, ref3 }, options: TestOptions.ReleaseDll.WithStrongNameProvider(s_defaultDesktopProvider), assemblyName: "asm4");
var comp4 = CreateCompilationWithMscorlib45(source4, new[] { SystemCoreRef, ref1, ref2, ref3 }, options: TestOptions.ReleaseDll.WithStrongNameProvider(s_defaultDesktopProvider), assemblyName: "asm4");
comp4.VerifyDiagnostics();
// Note: calls C.M, not A.M, since asm2 is not accessible (stops search).
......@@ -2014,7 +2013,6 @@ void Test()
";
var comp1 = CreateStandardCompilation(source1,
new[] { SystemCoreRef },
options: TestOptions.ReleaseDll.WithStrongNameProvider(s_defaultDesktopProvider),
assemblyName: "asm1");
......@@ -2024,7 +2022,7 @@ void Test()
var ref2 = CompileIL(source2, prependDefaultHeader: false);
var comp3 = CreateStandardCompilation(source3,
new[] { SystemCoreRef, ref1, ref2 },
new[] { ref1, ref2 },
options: TestOptions.ReleaseDll.WithStrongNameProvider(s_defaultDesktopProvider),
assemblyName: "asm3");
......
......@@ -1006,7 +1006,7 @@ static string ToStr(this object arg)
}
}";
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { SystemCoreRef }, expectedOutput: "NULL#System.Int32[]");
var comp = CompileStandardAndVerify(source, expectedOutput: "NULL#System.Int32[]");
comp.VerifyIL("C.Test", @"
{
// Code size 37 (0x25)
......@@ -1050,7 +1050,7 @@ static void Test(dynamic x)
}
}";
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { SystemCoreRef, CSharpRef }, expectedOutput: "NULL#System.Int32[]");
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { CSharpRef }, expectedOutput: "NULL#System.Int32[]");
comp.VerifyIL("C.Test", @"
{
// Code size 355 (0x163)
......@@ -1196,7 +1196,7 @@ static void Test(dynamic x)
}
}";
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { SystemCoreRef, CSharpRef }, expectedOutput: "NULL#y");
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { CSharpRef }, expectedOutput: "NULL#y");
}
[Fact]
......@@ -1219,7 +1219,7 @@ static void Test(string s, dynamic ds)
}
}";
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { SystemCoreRef, CSharpRef }, expectedOutput: "NULL#-1");
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { CSharpRef }, expectedOutput: "NULL#-1");
}
[Fact]
......@@ -1243,7 +1243,7 @@ static void Test(int[] x, dynamic i)
}
}";
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { SystemCoreRef, CSharpRef }, expectedOutput: "NULL#y");
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { CSharpRef }, expectedOutput: "NULL#y");
}
[Fact]
......@@ -1267,7 +1267,7 @@ static void Test(dynamic x)
}
}";
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { SystemCoreRef, CSharpRef }, expectedOutput: "NULL#3");
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { CSharpRef }, expectedOutput: "NULL#3");
}
[Fact]
......@@ -1291,7 +1291,7 @@ static void Test(dynamic x)
}
}";
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { SystemCoreRef, CSharpRef }, expectedOutput: "NULL#3");
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { CSharpRef }, expectedOutput: "NULL#3");
}
[Fact]
......@@ -1509,7 +1509,7 @@ public static class C1
}
";
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { SystemCoreRef, CSharpRef }, expectedOutput: "");
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { CSharpRef }, expectedOutput: "");
comp.VerifyIL("C.Main", @"
{
// Code size 82 (0x52)
......@@ -1627,7 +1627,7 @@ public static class C1
}
}";
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { SystemCoreRef, CSharpRef }, expectedOutput: @"3
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { CSharpRef }, expectedOutput: @"3
1");
comp.VerifyIL("C.Main", @"
{
......@@ -2633,7 +2633,7 @@ static void Main(string[] args)
}
}
";
var comp = CompileStandardAndVerify(source, additionalRefs: new MetadataReference[] { SystemCoreRef, CSharpRef }, expectedOutput: @"False
var comp = CompileStandardAndVerify(source, additionalRefs: new MetadataReference[] { CSharpRef }, expectedOutput: @"False
True
False
False");
......@@ -2692,7 +2692,7 @@ static void Main(string[] args)
}
}
";
var comp = CompileStandardAndVerify(source, additionalRefs: new MetadataReference[] { SystemCoreRef, CSharpRef }, expectedOutput: @"False
var comp = CompileStandardAndVerify(source, additionalRefs: new MetadataReference[] { CSharpRef }, expectedOutput: @"False
True
False
False");
......@@ -3194,7 +3194,7 @@ public static void CheckT<T>(this T x)
}
";
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { SystemCoreRef, CSharpRef }, expectedOutput: @"System.Nullable`1[System.Int64]");
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { CSharpRef }, expectedOutput: @"System.Nullable`1[System.Int64]");
comp.VerifyIL("Test.Test0<T>(T)", @"
{
// Code size 21 (0x15)
......@@ -3240,7 +3240,7 @@ public static void CheckT<T>(this T x)
}
";
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { SystemCoreRef, CSharpRef }, expectedOutput: @"System.Nullable`1[System.Int64]");
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { CSharpRef }, expectedOutput: @"System.Nullable`1[System.Int64]");
comp.VerifyIL("Test.Test0<T>(ref T)", @"
{
// Code size 46 (0x2e)
......@@ -3294,7 +3294,7 @@ static void Main()
}
";
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { SystemCoreRef, CSharpRef }, expectedOutput: @"");
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { CSharpRef }, expectedOutput: @"");
comp.VerifyIL("Test.Test0<T>(T)", @"
{
// Code size 27 (0x1b)
......@@ -3365,7 +3365,7 @@ interface I1
";
var comp = CreateCompilationWithMscorlib45(source, references: new[] { SystemCoreRef, CSharpRef });
var comp = CreateCompilationWithMscorlib45(source, references: new[] { CSharpRef });
base.CompileAndVerify(comp);
}
......@@ -3414,7 +3414,7 @@ interface I1
int CallAsync(int x);
}
";
var comp = CreateCompilationWithMscorlib45(source, references: new[] { SystemCoreRef, CSharpRef }, options: TestOptions.ReleaseExe);
var comp = CreateCompilationWithMscorlib45(source, references: new[] { CSharpRef }, options: TestOptions.ReleaseExe);
base.CompileAndVerify(comp, expectedOutput: "420");
}
......@@ -4093,7 +4093,7 @@ static bool Test4(ref C1 c)
}
}
";
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { SystemCoreRef, CSharpRef }, expectedOutput: @" >
var comp = CompileStandardAndVerify(source, additionalRefs: new[] { CSharpRef }, expectedOutput: @" >
False
False
<
......
......@@ -1539,7 +1539,7 @@ public void Next()
}
}
";
CompileStandardAndVerify(text, additionalRefs: new MetadataReference[] { CSharpRef, SystemCoreRef }, expectedOutput: @"Initialize
CompileStandardAndVerify(text, additionalRefs: new MetadataReference[] { CSharpRef }, expectedOutput: @"Initialize
Done
Next
Done
......@@ -1614,7 +1614,7 @@ static void Main(string[] args)
}
}
";
var comp = CompileStandardAndVerify(text, additionalRefs: new[] { LinqAssemblyRef }, expectedOutput: @"1
var comp = CompileStandardAndVerify(text, expectedOutput: @"1
2
3");
}
......@@ -1650,7 +1650,7 @@ private static IEnumerable<string> fun()
}
}
";
var comp = CompileStandardAndVerify(text, additionalRefs: new[] { LinqAssemblyRef }, expectedOutput: @"1
var comp = CompileStandardAndVerify(text, expectedOutput: @"1
2
3");
}
......@@ -1674,7 +1674,7 @@ static void Main(string[] args)
}
}
";
CompileStandardAndVerify(text, additionalRefs: new[] { SystemCoreRef }, expectedOutput: @"1
CompileStandardAndVerify(text, expectedOutput: @"1
4
9
16");
......@@ -1699,7 +1699,7 @@ static void Main(string[] args)
}
";
var comp = CompileStandardAndVerify(text, additionalRefs: new[] { SystemCoreRef }, expectedOutput: @"1
var comp = CompileStandardAndVerify(text, expectedOutput: @"1
4
9
16");
......
......@@ -690,7 +690,7 @@ static class Extensions
public static void M(this S s, int x, int y) { Console.Write(3); }
}
";
var compVerifier = CompileStandardAndVerify(text, options: TestOptions.UnsafeReleaseExe, additionalRefs: new[] { LinqAssemblyRef }, expectedOutput: @"123", verify: Verification.Fails);
var compVerifier = CompileStandardAndVerify(text, options: TestOptions.UnsafeReleaseExe, expectedOutput: @"123", verify: Verification.Fails);
compVerifier.VerifyIL("S.Main", @"
{
......@@ -712,7 +712,7 @@ .maxstack 3
}
");
compVerifier = CompileStandardAndVerify(text, options: TestOptions.UnsafeReleaseExe, additionalRefs: new[] { LinqAssemblyRef }, expectedOutput: @"123", verify: Verification.Fails);
compVerifier = CompileStandardAndVerify(text, options: TestOptions.UnsafeReleaseExe, expectedOutput: @"123", verify: Verification.Fails);
compVerifier.VerifyIL("S.Main", @"
{
......@@ -766,7 +766,7 @@ static class Extensions
public static void M(this S s, int x, int y) { Console.Write(3); }
}
";
var compVerifier = CompileStandardAndVerify(text, options: TestOptions.UnsafeReleaseExe, additionalRefs: new[] { LinqAssemblyRef }, expectedOutput: @"123", verify: Verification.Fails);
var compVerifier = CompileStandardAndVerify(text, options: TestOptions.UnsafeReleaseExe, expectedOutput: @"123", verify: Verification.Fails);
compVerifier.VerifyIL("S.Test(ref S*)", @"
{
......@@ -789,7 +789,7 @@ .maxstack 3
}
");
compVerifier = CompileStandardAndVerify(text, options: TestOptions.UnsafeReleaseExe, additionalRefs: new[] { LinqAssemblyRef }, expectedOutput: @"123", verify: Verification.Fails);
compVerifier = CompileStandardAndVerify(text, options: TestOptions.UnsafeReleaseExe, expectedOutput: @"123", verify: Verification.Fails);
compVerifier.VerifyIL("S.Test(ref S*)", @"
{
......@@ -9154,7 +9154,7 @@ static void Main()
}
";
var verifier = CompileStandardAndVerify(text, new[] { SystemCoreRef }, options: TestOptions.UnsafeReleaseExe, verify: Verification.Fails, expectedOutput: @"
var verifier = CompileStandardAndVerify(text, options: TestOptions.UnsafeReleaseExe, verify: Verification.Fails, expectedOutput: @"
2
2");
......@@ -9206,7 +9206,7 @@ public struct S2
}
";
var verifier = CompileStandardAndVerify(text, new[] { SystemCoreRef }, options: TestOptions.UnsafeReleaseDll.WithConcurrentBuild(false), verify: Verification.Passes);
var verifier = CompileStandardAndVerify(text, options: TestOptions.UnsafeReleaseDll.WithConcurrentBuild(false), verify: Verification.Passes);
}
[Fact, WorkItem(531327, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/531327")]
......@@ -9230,7 +9230,7 @@ unsafe struct S1
";
var verifier = CompileStandardAndVerify(text, new[] { SystemCoreRef }, options: TestOptions.UnsafeReleaseDll.WithConcurrentBuild(false), verify: Verification.Fails);
var verifier = CompileStandardAndVerify(text, options: TestOptions.UnsafeReleaseDll.WithConcurrentBuild(false), verify: Verification.Fails);
}
[Fact, WorkItem(748530, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/748530")]
......
......@@ -3211,7 +3211,7 @@ private static void AssertInstrumented(CompilationVerifier verifier, string qual
Assert.True(expected == instrumented, $"Method '{qualifiedMethodName}' should {(expected ? "be" : "not be")} instrumented. Actual IL:{Environment.NewLine}{il}");
}
private CompilationVerifier CompileAndVerify(string source, string expectedOutput = null, CompilationOptions options = null, Verification verify = Verification.Passes)
private CompilationVerifier CompileAndVerify(string source, string expectedOutput = null, CSharpCompilationOptions options = null, Verification verify = Verification.Passes)
{
return base.CompileStandardAndVerify(source, expectedOutput: expectedOutput, additionalRefs: s_refs, options: (options ?? TestOptions.ReleaseExe).WithDeterministic(true), emitOptions: EmitOptions.Default.WithInstrumentationKinds(ImmutableArray.Create(InstrumentationKind.TestCoverage)), verify: verify);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册