Skip to content

Commit

Permalink
Add a test to invoke a method.
Browse files Browse the repository at this point in the history
  • Loading branch information
wasabii committed Jul 13, 2022
1 parent 7a1c653 commit 0989e7b
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/IKVM.Tests/IKVM.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
</PropertyGroup>

<ItemGroup>
<None Remove="Java\java\lang\ClassTests.java" />
<None Remove="JNI\JniTests.java" />
<None Remove="Runtime\Vfs\VfsTestResource.txt" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Java\java\lang\ClassTests.java" />
<EmbeddedResource Include="JNI\JniTests.java" />
<EmbeddedResource Include="Runtime\Vfs\VfsTestResource.txt" />
</ItemGroup>
Expand Down
37 changes: 37 additions & 0 deletions src/IKVM.Tests/Java/java/lang/ClassTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using IKVM.Tests.Util;

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace IKVM.Tests.Java.java.lang
{


[TestClass]
public class ClassTests
{

[TestMethod]
public void Can_get_method_and_invoke()
{
var s = new StreamReader(typeof(ClassTests).Assembly.GetManifestResourceStream("IKVM.Tests.Java.java.lang.ClassTests.java")).ReadToEnd();
var f = new InMemoryCodeUnit("ikvm.tests.java.lang.ClassTests", s);
var c = new InMemoryCompiler(new[] { f });
c.Compile();
var z = c.GetClass("ikvm.tests.java.lang.ClassTests");
if (z == null)
throw new Exception();

var m = z.getMethod("main", new global::java.lang.Class[] { typeof(string[]) });
m.invoke(null, new object[] { new string[] { "TEST" } });
}

}

}
11 changes: 11 additions & 0 deletions src/IKVM.Tests/Java/java/lang/ClassTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package ikvm.tests.java.lang;

public class ClassTests
{

public static void main(String[] args)
{

}

}

0 comments on commit 0989e7b

Please sign in to comment.