Skip to content

Commit

Permalink
Add a test for array component tyep resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
jmao-denver committed May 21, 2024
1 parent 50d9dce commit 995619e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/test/java/org/jpy/fixtures/CyclicReferenceChild1.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,11 @@ public static CyclicReferenceChild1 of(int x) {
public int get_x() {
return this.x;
}

public CyclicReferenceChild2[] getChild2s() {
CyclicReferenceChild2[] child2s = new CyclicReferenceChild2[2];
child2s[0] = new CyclicReferenceChild2();
child2s[1] = new CyclicReferenceChild2();
return child2s;
}
}
3 changes: 3 additions & 0 deletions src/test/java/org/jpy/fixtures/CyclicReferenceChild2.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@
*/
@SuppressWarnings("UnusedDeclaration")
public class CyclicReferenceChild2 extends CyclicReferenceParent {
public String getName() {
return "Child2: " + this.toString();
}
}
8 changes: 8 additions & 0 deletions src/test/python/jpy_gettype_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ def test_cyclic_reference(self):
self.assertEqual(10, j_child1.y)
self.assertEqual(100, j_child1.z)

def test_component_type_resolution(self):
j_child1_class = jpy.get_type("org.jpy.fixtures.CyclicReferenceChild1")
j_child1 = j_child1_class.of(8)
j_child2s = j_child1.getChild2s()
self.assertIn("[Lorg.jpy.fixtures.CyclicReferenceChild2;", repr(type(j_child2s)))
for j_child2 in j_child2s:
self.assertTrue(j_child2.getName().startswith("Child2"))


if __name__ == '__main__':
print('\nRunning ' + __file__)
Expand Down

0 comments on commit 995619e

Please sign in to comment.