Skip to content

Commit

Permalink
Add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lewing authored and kg committed Oct 13, 2020
1 parent b366e88 commit e1144dd
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ private static object InvokeMarshalObj()
return _marshalledObject;
}

private static object InvokeReturnMarshalObj()
{
return _marshalledObject;
}

internal static int _valOne, _valTwo;
private static void ManipulateObject(JSObject obj)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,73 @@ public static void CSObjectKeepIdentityAcrossCalls()
Assert.Same(HelperMarshal._object1, HelperMarshal._object2);
}

[Theory]
[InlineData(byte.MinValue)]
[InlineData(byte.MaxValue)]
[InlineData(SByte.MinValue)]
[InlineData(SByte.MaxValue)]
[InlineData(uint.MaxValue)]
[InlineData(uint.MinValue)]
[InlineData(int.MaxValue)]
[InlineData(int.MinValue)]
[InlineData(double.MaxValue)]
[InlineData(double.MinValue)]
public static void InvokeUnboxNumberString(object o)
{
HelperMarshal._marshalledObject = o;
HelperMarshal._object1 = HelperMarshal._object2 = null;
var value = Runtime.InvokeJS(@"
var obj = App.call_test_method (""InvokeReturnMarshalObj"");
var res = App.call_test_method (""InvokeObj1"", [ obj.toString() ]);
");

Assert.Equal(o.ToString().ToLower(), HelperMarshal._object1);
}

[Theory]
[InlineData(byte.MinValue, 0)]
[InlineData(byte.MaxValue, 255)]
[InlineData(SByte.MinValue, -128)]
[InlineData(SByte.MaxValue, 127)]
[InlineData(uint.MaxValue)]
[InlineData(uint.MinValue, 0)]
[InlineData(int.MaxValue)]
[InlineData(int.MinValue)]
[InlineData(double.MaxValue)]
[InlineData(double.MinValue)]
public static void InvokeUnboxNumber(object o, object expected = null)
{
HelperMarshal._marshalledObject = o;
HelperMarshal._object1 = HelperMarshal._object2 = null;
Runtime.InvokeJS(@"
var obj = App.call_test_method (""InvokeReturnMarshalObj"");
var res = App.call_test_method (""InvokeObj1"", [ obj ]);
");

Assert.Equal(expected ?? o, HelperMarshal._object1);
}

[Theory]
[InlineData(byte.MinValue, 0)]
[InlineData(byte.MaxValue, 255)]
[InlineData(SByte.MinValue, -128)]
[InlineData(SByte.MaxValue, 127)]
[InlineData(uint.MaxValue)]
[InlineData(uint.MinValue, 0)]
[InlineData(int.MaxValue)]
[InlineData(int.MinValue)]
[InlineData(double.MaxValue)]
[InlineData(double.MinValue)]
public static void InvokeUnboxStringNumber(object o, object expected = null)
{
HelperMarshal._marshalledObject = HelperMarshal._object1 = HelperMarshal._object2 = null;
Runtime.InvokeJS(String.Format (@"
var res = App.call_test_method (""InvokeObj1"", [ {0} ]);
", o));

Assert.Equal (expected ?? o, HelperMarshal._object1);
}

[Fact]
public static void JSInvokeInt()
{
Expand Down

0 comments on commit e1144dd

Please sign in to comment.