This repository was archived by the owner on Dec 19, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests to verify flexibility of await keyword.
Added sample files to evaluate accuracy of generated code for the await keyword. Also added a line mapping test to ensure that we're mapping the keyword correctly.
- Loading branch information
1 parent
50314ca
commit 4cfef3c
Showing
5 changed files
with
292 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Await.DesignTime.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
namespace TestOutput | ||
{ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
public class Await | ||
{ | ||
private static object @__o; | ||
#line 1 "Await.cshtml" | ||
|
||
public async Task<string> Foo() | ||
{ | ||
return "Bar"; | ||
} | ||
|
||
#line default | ||
#line hidden | ||
private void @__RazorDesignTimeHelpers__() | ||
{ | ||
#pragma warning disable 219 | ||
#pragma warning restore 219 | ||
} | ||
#line hidden | ||
public Await() | ||
{ | ||
} | ||
|
||
public override async Task ExecuteAsync() | ||
{ | ||
#line 1 "------------------------------------------" | ||
__o = await Foo(); | ||
|
||
#line default | ||
#line hidden | ||
#line 1 "------------------------------------------" | ||
__o = await Foo(); | ||
|
||
#line default | ||
#line hidden | ||
#line 12 "Await.cshtml" | ||
await Foo(); | ||
|
||
#line default | ||
#line hidden | ||
|
||
#line 13 "Await.cshtml" | ||
|
||
|
||
#line default | ||
#line hidden | ||
|
||
#line 1 "------------------------------------------" | ||
__o = await Foo(); | ||
|
||
#line default | ||
#line hidden | ||
#line 13 "Await.cshtml" | ||
|
||
|
||
#line default | ||
#line hidden | ||
|
||
#line 1 "------------------------------------------" | ||
__o = await; | ||
|
||
#line default | ||
#line hidden | ||
#line 1 "------------------------------------------" | ||
__o = await Foo(1, 2); | ||
|
||
#line default | ||
#line hidden | ||
#line 1 "------------------------------------------" | ||
__o = await Foo("bob", true); | ||
|
||
#line default | ||
#line hidden | ||
#line 21 "Await.cshtml" | ||
await Foo(something, hello: "world"); | ||
|
||
#line default | ||
#line hidden | ||
|
||
#line 22 "Await.cshtml" | ||
|
||
|
||
#line default | ||
#line hidden | ||
|
||
#line 1 "------------------------------------------" | ||
__o = await Foo(boolValue: false); | ||
|
||
#line default | ||
#line hidden | ||
#line 22 "Await.cshtml" | ||
|
||
|
||
#line default | ||
#line hidden | ||
|
||
#line 1 "------------------------------------------" | ||
__o = await ("wrrronggg"); | ||
|
||
#line default | ||
#line hidden | ||
} | ||
} | ||
} |
129 changes: 129 additions & 0 deletions
129
test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Output/Await.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
namespace TestOutput | ||
{ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
public class Await | ||
{ | ||
#line 1 "Await.cshtml" | ||
|
||
public async Task<string> Foo() | ||
{ | ||
return "Bar"; | ||
} | ||
|
||
#line default | ||
#line hidden | ||
#line hidden | ||
public Await() | ||
{ | ||
} | ||
|
||
public override async Task ExecuteAsync() | ||
{ | ||
WriteLiteral("\r\n<section>\r\n <h1>Basic Asynchronous Expression Test</h1>\r\n <p>Basic Asynch" + | ||
"ronous Expression: "); | ||
Write( | ||
#line 10 "Await.cshtml" | ||
await Foo() | ||
|
||
#line default | ||
#line hidden | ||
); | ||
|
||
WriteLiteral("</p>\r\n <p>Basic Asynchronous Template: "); | ||
Write( | ||
#line 11 "Await.cshtml" | ||
await Foo() | ||
|
||
#line default | ||
#line hidden | ||
); | ||
|
||
WriteLiteral("</p>\r\n <p>Basic Asynchronous Statement: "); | ||
#line 12 "Await.cshtml" | ||
await Foo(); | ||
|
||
#line default | ||
#line hidden | ||
|
||
WriteLiteral("</p>\r\n <p>Basic Asynchronous Statement Nested: <b>"); | ||
Write( | ||
#line 13 "Await.cshtml" | ||
await Foo() | ||
|
||
#line default | ||
#line hidden | ||
); | ||
|
||
WriteLiteral("</b> "); | ||
#line 13 "Await.cshtml" | ||
|
||
|
||
#line default | ||
#line hidden | ||
|
||
WriteLiteral("</p>\r\n <p>Basic Incomplete Asynchronous Statement: "); | ||
Write( | ||
#line 14 "Await.cshtml" | ||
await | ||
|
||
#line default | ||
#line hidden | ||
); | ||
|
||
WriteLiteral("</p>\r\n</section>\r\n\r\n<section>\r\n <h1>Advanced Asynchronous Expression Test</h1>" + | ||
"\r\n <p>Advanced Asynchronous Expression: "); | ||
Write( | ||
#line 19 "Await.cshtml" | ||
await Foo(1, 2) | ||
|
||
#line default | ||
#line hidden | ||
); | ||
|
||
WriteLiteral("</p>\r\n <p>Advanced Asynchronous Template: "); | ||
Write( | ||
#line 20 "Await.cshtml" | ||
await Foo("bob", true) | ||
|
||
#line default | ||
#line hidden | ||
); | ||
|
||
WriteLiteral("</p>\r\n <p>Advanced Asynchronous Statement: "); | ||
#line 21 "Await.cshtml" | ||
await Foo(something, hello: "world"); | ||
|
||
#line default | ||
#line hidden | ||
|
||
WriteLiteral("</p>\r\n <p>Advanced Asynchronous Statement Nested: <b>"); | ||
Write( | ||
#line 22 "Await.cshtml" | ||
await Foo(boolValue: false) | ||
|
||
#line default | ||
#line hidden | ||
); | ||
|
||
WriteLiteral("</b> "); | ||
#line 22 "Await.cshtml" | ||
|
||
|
||
#line default | ||
#line hidden | ||
|
||
WriteLiteral("</p>\r\n <p>Advanced Incomplete Asynchronous Statement: "); | ||
Write( | ||
#line 23 "Await.cshtml" | ||
await ("wrrronggg") | ||
|
||
#line default | ||
#line hidden | ||
); | ||
|
||
WriteLiteral("</p>\r\n</section>"); | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
test/Microsoft.AspNet.Razor.Test/TestFiles/CodeGenerator/CS/Source/Await.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@functions { | ||
public async Task<string> Foo() | ||
{ | ||
return "Bar"; | ||
} | ||
} | ||
|
||
<section> | ||
<h1>Basic Asynchronous Expression Test</h1> | ||
<p>Basic Asynchronous Expression: @await Foo()</p> | ||
<p>Basic Asynchronous Template: @(await Foo())</p> | ||
<p>Basic Asynchronous Statement: @{ await Foo(); }</p> | ||
<p>Basic Asynchronous Statement Nested: @{ <b>@await Foo()</b> }</p> | ||
<p>Basic Incomplete Asynchronous Statement: @await</p> | ||
</section> | ||
|
||
<section> | ||
<h1>Advanced Asynchronous Expression Test</h1> | ||
<p>Advanced Asynchronous Expression: @await Foo(1, 2)</p> | ||
<p>Advanced Asynchronous Template: @(await Foo("bob", true))</p> | ||
<p>Advanced Asynchronous Statement: @{ await Foo(something, hello: "world"); }</p> | ||
<p>Advanced Asynchronous Statement Nested: @{ <b>@await Foo(boolValue: false)</b> }</p> | ||
<p>Advanced Incomplete Asynchronous Statement: @await ("wrrronggg")</p> | ||
</section> |