-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea0aa5c
commit e1a173b
Showing
2 changed files
with
45 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using NiL.JS; | ||
using NiL.JS.BaseLibrary; | ||
using NiL.JS.Core; | ||
using NiL.JS.Extensions; | ||
|
||
namespace Tests.Fuzz | ||
{ | ||
[TestClass] | ||
public sealed class Bug_299 | ||
{ | ||
[TestMethod] | ||
public async Task Promise_299() | ||
{ | ||
var script = Script.Parse( | ||
@" | ||
export default class Test { | ||
async run(params) { | ||
return params; | ||
} | ||
} | ||
" | ||
); | ||
var context = new GlobalContext(); | ||
var module = new Module($"main.js", script, context); | ||
module.Run(); | ||
|
||
var ctor = module.Exports.Default.As<Function>(); | ||
var instance = ctor.Construct(new Arguments()); | ||
var run = instance.GetProperty("run").As<Function>(); | ||
|
||
var param = JSON.parse("{}"); | ||
var result = run.MakeDelegate<Func<JSValue, JSValue>>()(param); | ||
if (result.Value is Promise promise) | ||
{ | ||
result = await promise.Task; | ||
} | ||
|
||
Assert.AreEqual(param, result); | ||
} | ||
} | ||
} |