forked from nilproject/NiL.JS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOverloadedMethods.cs
68 lines (56 loc) · 1.77 KB
/
OverloadedMethods.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
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 sealed class OverloadedMethods
{
private class Class
{
public int Method()
{
return 0;
}
public int Method(int a, int b)
{
return 2;
}
public int Method(int a)
{
return 1;
}
}
[TestMethod]
public void OverloadedMethods_0()
{
var context = new Context();
var instance = new Class();
context.DefineVariable($"{nameof(instance)}").Assign(JSValue.Marshal(instance));
var result = context.Eval($"{nameof(instance)}.{nameof(instance.Method)}()");
Assert.AreEqual(0, result.Value);
}
[TestMethod]
public void OverloadedMethods_1()
{
var context = new Context();
var instance = new Class();
context.DefineVariable($"{nameof(instance)}").Assign(JSValue.Marshal(instance));
var result = context.Eval($"{nameof(instance)}.{nameof(instance.Method)}(1)");
Assert.AreEqual(1, result.Value);
}
[TestMethod]
public void OverloadedMethods_2()
{
var context = new Context();
var instance = new Class();
context.DefineVariable($"{nameof(instance)}").Assign(JSValue.Marshal(instance));
var result = context.Eval($"{nameof(instance)}.{nameof(instance.Method)}(1, 2)");
Assert.AreEqual(2, result.Value);
}
}
}