提交 f2d4b9dc 编写于 作者: J Jared Parsons

Test uses of async as type / context keyword

上级 8e8b54e7
......@@ -58,7 +58,7 @@ Code:
- [ ] Unsafe code
- [ ] LINQ
- [ ] constructors, properties, indexers, events, operators, and destructors.
- [ ] Async
- [X] Async
- [X] Var
Misc:
......
......@@ -3838,5 +3838,98 @@ static void Main()
expectedOutput: "dog-42");
}
}
[CompilerTrait(CompilerFeature.LocalFunctions, CompilerFeature.Async)]
public sealed class AsyncTests : CSharpTestBase
{
[Fact]
public void RealTypeAsReturn()
{
var source = @"
using System;
class async
{
public override string ToString() => ""dog"";
}
class Program
{
static void Main()
{
async f() => new async();
Console.WriteLine(f());
}
}";
CompileAndVerify(
source,
parseOptions: DefaultParseOptions,
expectedOutput: "dog");
}
[Fact]
public void RealTypeParameterAsReturn()
{
var source = @"
using System;
class test
{
public override string ToString() => ""dog"";
}
class Program
{
static void Test<async>(async x)
{
async f() => x;
Console.WriteLine(f());
}
static void Main()
{
Test(new test());
}
}";
CompileAndVerify(
source,
parseOptions: DefaultParseOptions,
expectedOutput: "dog");
}
[Fact]
public void ManyMeaningsType()
{
var source = @"
using System;
using System.Threading;
using System.Threading.Tasks;
class async
{
public override string ToString() => ""async"";
}
class Program
{
static void Main()
{
async Task<async> Test(Task<async> t)
{
async local = await t;
Console.WriteLine(local);
return local;
}
Test(Task.FromResult<async>(new async())).Wait();
}
}";
var comp = CreateCompilationWithMscorlib46(source, parseOptions: DefaultParseOptions, options: TestOptions.DebugExe);
CompileAndVerify(
comp,
expectedOutput: "async");
}
}
}
}
......@@ -328,6 +328,23 @@ public static SyntaxTree ParseWithRoundTripCheck(string text, CSharpParseOptions
return CreateCompilation(source, refs, options, assemblyName);
}
public static CSharpCompilation CreateCompilationWithMscorlib46(
string source,
IEnumerable<MetadataReference> references = null,
CSharpCompilationOptions options = null,
CSharpParseOptions parseOptions = null,
string sourceFileName = "",
string assemblyName = "")
{
return CreateCompilationWithMscorlib46(
new[] { source },
references,
options,
parseOptions,
sourceFileName,
assemblyName);
}
public static CSharpCompilation CreateCompilationWithMscorlib46(
string[] sources,
IEnumerable<MetadataReference> references = null,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册