|
@@ -100,6 +100,22 @@ namespace Jint.Tests.Runtime
|
|
Assert.Equal("Class2.Object", engine.Evaluate("Class2.Print(() => '');"));
|
|
Assert.Equal("Class2.Object", engine.Evaluate("Class2.Print(() => '');"));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ [Fact]
|
|
|
|
+ public void ShouldMatchCorrectConstructors()
|
|
|
|
+ {
|
|
|
|
+ Engine engine = new Engine();
|
|
|
|
+ engine.SetValue("MyClass", TypeReference.CreateTypeReference(engine, typeof(Class3)));
|
|
|
|
+
|
|
|
|
+ engine.Execute(@"
|
|
|
|
+ const a = new MyClass();
|
|
|
|
+ a.Print(1); // Works
|
|
|
|
+ a.Print([1, 2]); // Works
|
|
|
|
+
|
|
|
|
+ const b = new MyClass(1); // Works
|
|
|
|
+ const c = new MyClass([1, 2]); // Throws 'an object must implement IConvertible' exception
|
|
|
|
+ ");
|
|
|
|
+ }
|
|
|
|
+
|
|
private struct Class1
|
|
private struct Class1
|
|
{
|
|
{
|
|
public static string Print(ExpandoObject eo) => nameof(Class1) + "." + nameof(ExpandoObject);
|
|
public static string Print(ExpandoObject eo) => nameof(Class1) + "." + nameof(ExpandoObject);
|
|
@@ -114,5 +130,18 @@ namespace Jint.Tests.Runtime
|
|
public static string Print(int i) => nameof(Class2) + "." + nameof(Int32);
|
|
public static string Print(int i) => nameof(Class2) + "." + nameof(Int32);
|
|
public static string Print(object o) => nameof(Class2) + "." + nameof(Object);
|
|
public static string Print(object o) => nameof(Class2) + "." + nameof(Object);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public class Class3
|
|
|
|
+ {
|
|
|
|
+ public Class3() { }
|
|
|
|
+
|
|
|
|
+ public Class3(int a) => Console.WriteLine("Class1(int a): " + a);
|
|
|
|
+
|
|
|
|
+ public Class3(object a) => Console.WriteLine("Class1(object a): " + a);
|
|
|
|
+
|
|
|
|
+ public void Print(int a) => Console.WriteLine("Print(int a): " + a);
|
|
|
|
+
|
|
|
|
+ public void Print(object a) => Console.WriteLine("Print(object a): " + a);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|