Skip to content

Commit

Permalink
Fill out all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
333fred committed Dec 21, 2022
1 parent f3905fa commit f936bbc
Show file tree
Hide file tree
Showing 3 changed files with 627 additions and 52 deletions.
36 changes: 34 additions & 2 deletions src/Compilers/Test/Core/CommonTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using System.Text;
using System.Xml.Linq;
using Microsoft.CodeAnalysis.CodeGen;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE;
using Microsoft.CodeAnalysis.Emit;
using Microsoft.CodeAnalysis.Operations;
Expand Down Expand Up @@ -302,9 +303,33 @@ protected CSharp.CSharpCompilation CreateCSharpCompilation(
IEnumerable<MetadataReference> referencedAssemblies = null,
IEnumerable<Compilation> referencedCompilations = null)
{
return CreateCSharpCompilation(assemblyName, assemblyIdentity: null, code, parseOptions, compilationOptions, referencedAssemblies, referencedCompilations);
}

protected CSharp.CSharpCompilation CreateCSharpCompilation(
AssemblyIdentity assemblyIdentity,
string code,
CSharp.CSharpParseOptions parseOptions = null,
CSharp.CSharpCompilationOptions compilationOptions = null,
IEnumerable<MetadataReference> referencedAssemblies = null,
IEnumerable<Compilation> referencedCompilations = null)
{
return CreateCSharpCompilation(assemblyName: null, assemblyIdentity, code, parseOptions, compilationOptions, referencedAssemblies, referencedCompilations);
}

private CSharp.CSharpCompilation CreateCSharpCompilation(
string assemblyName,
AssemblyIdentity assemblyIdentity,
string code,
CSharp.CSharpParseOptions parseOptions = null,
CSharp.CSharpCompilationOptions compilationOptions = null,
IEnumerable<MetadataReference> referencedAssemblies = null,
IEnumerable<Compilation> referencedCompilations = null)
{
Debug.Assert(assemblyName == null || assemblyIdentity == null || assemblyIdentity.Name == assemblyName);
if (assemblyName == null)
{
assemblyName = GetUniqueName();
assemblyName = assemblyIdentity?.Name ?? GetUniqueName();
}

if (parseOptions == null)
Expand Down Expand Up @@ -336,7 +361,14 @@ protected CSharp.CSharpCompilation CreateCSharpCompilation(

var tree = CSharp.SyntaxFactory.ParseSyntaxTree(SourceText.From(code, encoding: null, SourceHashAlgorithms.Default), options: parseOptions);

return CSharp.CSharpCompilation.Create(assemblyName, new[] { tree }, references, compilationOptions);
var compilation = CSharp.CSharpCompilation.Create(assemblyName, new[] { tree }, references, compilationOptions);

if (assemblyIdentity != null)
{
((SourceAssemblySymbol)compilation.Assembly).lazyAssemblyIdentity = assemblyIdentity;
}

return compilation;
}

protected VisualBasic.VisualBasicCompilation CreateVisualBasicCompilation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ Friend Module CompilationUtils
actualLine = actualReader.ReadLine()
End While

Assert.Equal(expectedPooledBuilder.ToStringAndFree(), actualPooledBuilder.ToStringAndFree())
AssertEx.Equal(expectedPooledBuilder.ToStringAndFree(), actualPooledBuilder.ToStringAndFree())
End Sub

' There are certain cases where multiple distinct errors are
Expand Down
Loading

0 comments on commit f936bbc

Please sign in to comment.