Skip to content

Commit

Permalink
Consolidate test Span sources
Browse files Browse the repository at this point in the history
  • Loading branch information
jjonescz committed Jul 8, 2024
1 parent 19b5e96 commit 2af53b7
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 313 deletions.
2 changes: 1 addition & 1 deletion src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11742,7 +11742,7 @@ static void Main()
}
}";

var comp = CreateCompilation(new[] { SpanSource, source }, options: TestOptions.UnsafeReleaseExe);
var comp = CreateCompilation(new[] { TestSources.Span, source }, options: TestOptions.UnsafeReleaseExe);
verify(comp);

comp = CreateCompilation(new[] { source }, options: TestOptions.UnsafeReleaseExe, targetFramework: TargetFramework.Net70);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3120,7 +3120,7 @@ void M(in System.Span<int> e, int result)
Predecessors: [B2]
Statements (0)
";
VerifyFlowGraphAndDiagnosticsForTest<BlockSyntax>(source + SpanSource, expectedFlowGraph, expectedDiagnostics, TestOptions.ReleaseDll.WithAllowUnsafe(true));
VerifyFlowGraphAndDiagnosticsForTest<BlockSyntax>(source + TestSources.Span, expectedFlowGraph, expectedDiagnostics, TestOptions.ReleaseDll.WithAllowUnsafe(true));
}

[CompilerTrait(CompilerFeature.IOperation, CompilerFeature.Dataflow)]
Expand Down Expand Up @@ -3209,7 +3209,7 @@ void M(in System.Span<int> e, int result)
Predecessors: [B2]
Statements (0)
";
VerifyFlowGraphAndDiagnosticsForTest<BlockSyntax>(source + SpanSource, expectedFlowGraph, expectedDiagnostics, TestOptions.ReleaseDll.WithAllowUnsafe(true));
VerifyFlowGraphAndDiagnosticsForTest<BlockSyntax>(source + TestSources.Span, expectedFlowGraph, expectedDiagnostics, TestOptions.ReleaseDll.WithAllowUnsafe(true));
}

[CompilerTrait(CompilerFeature.IOperation, CompilerFeature.Dataflow)]
Expand Down Expand Up @@ -3298,7 +3298,7 @@ void M(in System.ReadOnlySpan<int> e, int result)
Predecessors: [B2]
Statements (0)
";
VerifyFlowGraphAndDiagnosticsForTest<BlockSyntax>(source + SpanSource, expectedFlowGraph, expectedDiagnostics, TestOptions.ReleaseDll.WithAllowUnsafe(true));
VerifyFlowGraphAndDiagnosticsForTest<BlockSyntax>(source + TestSources.Span, expectedFlowGraph, expectedDiagnostics, TestOptions.ReleaseDll.WithAllowUnsafe(true));
}

[CompilerTrait(CompilerFeature.IOperation, CompilerFeature.Dataflow)]
Expand Down Expand Up @@ -3387,7 +3387,7 @@ void M(in System.ReadOnlySpan<int> e, int result)
Predecessors: [B2]
Statements (0)
";
VerifyFlowGraphAndDiagnosticsForTest<BlockSyntax>(source + SpanSource, expectedFlowGraph, expectedDiagnostics, TestOptions.ReleaseDll.WithAllowUnsafe(true));
VerifyFlowGraphAndDiagnosticsForTest<BlockSyntax>(source + TestSources.Span, expectedFlowGraph, expectedDiagnostics, TestOptions.ReleaseDll.WithAllowUnsafe(true));
}

[CompilerTrait(CompilerFeature.IOperation, CompilerFeature.Dataflow)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142546,7 +142546,7 @@ public class B : IEquatable<(B?, B?)>
public bool Equals((B?, B?) l) => false;
}
";
var spanRef = CreateCompilation(SpanSource, options: TestOptions.UnsafeReleaseDll)
var spanRef = CreateCompilation(TestSources.Span, options: TestOptions.UnsafeReleaseDll)
.EmitToImageReference();
var comp = CreateCompilation(def + @"
class C
Expand Down
8 changes: 4 additions & 4 deletions src/Compilers/CSharp/Test/Semantic/Semantics/RefFieldTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1483,7 +1483,7 @@ unsafe void M()
}
";

var spanReference = CreateCompilation(SpanSource, options: TestOptions.UnsafeReleaseDll);
var spanReference = CreateCompilation(TestSources.Span, options: TestOptions.UnsafeReleaseDll);
var comp = CreateCompilation(source, references: new[] { spanReference.EmitToImageReference() }, options: TestOptions.UnsafeReleaseDll, targetFramework: TargetFramework.Net70);
comp.VerifyEmitDiagnostics(
// (16,29): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('S2')
Expand Down Expand Up @@ -1539,7 +1539,7 @@ unsafe C M2()
}
";

var spanReference = CreateCompilation(SpanSource, options: TestOptions.UnsafeReleaseDll);
var spanReference = CreateCompilation(TestSources.Span, options: TestOptions.UnsafeReleaseDll);
var comp = CreateCompilation(source, references: new[] { spanReference.EmitToImageReference() }, options: TestOptions.UnsafeReleaseDll, targetFramework: TargetFramework.Net70);
comp.VerifyEmitDiagnostics(
// (16,18): error CS0208: Cannot take the address of, get the size of, or declare a pointer to a managed type ('S2')
Expand Down Expand Up @@ -1591,7 +1591,7 @@ unsafe void M()
}
";

var spanReference = CreateCompilation(SpanSource, options: TestOptions.UnsafeReleaseDll);
var spanReference = CreateCompilation(TestSources.Span, options: TestOptions.UnsafeReleaseDll);
var comp = CreateCompilation(source, references: new[] { spanReference.EmitToImageReference() }, options: TestOptions.UnsafeReleaseDll, targetFramework: TargetFramework.Net70);
comp.VerifyEmitDiagnostics(
// (16,29): warning CS8500: This takes the address of, gets the size of, or declares a pointer to a managed type ('S2')
Expand Down Expand Up @@ -1647,7 +1647,7 @@ unsafe void M()
}
";

var spanReference = CreateCompilation(SpanSource, options: TestOptions.UnsafeReleaseDll);
var spanReference = CreateCompilation(TestSources.Span, options: TestOptions.UnsafeReleaseDll);
var comp = CreateCompilation(source, references: new[] { spanReference.EmitToImageReference() }, options: TestOptions.UnsafeReleaseDll, targetFramework: TargetFramework.Net70);
comp.VerifyEmitDiagnostics(
// (16,19): warning CS8500: This takes the address of, gets the size of, or declares a pointer to a managed type ('S2')
Expand Down
Loading

0 comments on commit 2af53b7

Please sign in to comment.