forked from nilproject/NiL.JS
-
Notifications
You must be signed in to change notification settings - Fork 0
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
c531f94
commit 770358a
Showing
3 changed files
with
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using NiL.JS.Core; | ||
|
||
namespace FunctionalTests | ||
{ | ||
[TestClass] | ||
public class FunctionsToDelegateWrapping | ||
{ | ||
[TestMethod] | ||
public void TryToAddFunctionIntoListOfDelegates_Marshal() | ||
{ | ||
var context = new Context(); | ||
var list = new List<Func<string, string>>(); | ||
context.DefineVariable("list").Assign(JSValue.Marshal(list)); | ||
|
||
context.Eval("list.push(x => 'hi ' + x)"); // IList marshaled as NativeList with array-like interface | ||
|
||
Assert.AreEqual("hi Test", list[0]("Test")); | ||
} | ||
|
||
[TestMethod] | ||
public void TryToAddFunctionIntoListOfDelegates_Wrap() | ||
{ | ||
var context = new Context(); | ||
var list = new List<Func<string, string>>(); | ||
context.DefineVariable("list").Assign(JSValue.Wrap(list)); | ||
|
||
context.Eval("list.Add(x => 'hi ' + x)"); | ||
|
||
Assert.AreEqual("hi Test", list[0]("Test")); | ||
} | ||
} | ||
} |
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,26 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using NiL.JS.BaseLibrary; | ||
using NiL.JS.Core; | ||
|
||
namespace FunctionalTests | ||
{ | ||
[TestClass] | ||
public class Interop | ||
{ | ||
[TestMethod] | ||
public void CreateInstanceOfGenericType() | ||
{ | ||
var context = new Context(); | ||
context.DefineConstructor(typeof(List<>)); | ||
|
||
var result = context.Eval("new (List(Number))()").Value; | ||
|
||
Assert.AreSame(typeof(List<Number>), result.GetType()); | ||
} | ||
} | ||
} |