Skip to content

Commit 1e54c4b

Browse files
committed
Add down-the-middle testing of the jclass function
1 parent 141a3ed commit 1e54c4b

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

tests/test_types.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from scyjava import numeric_bounds, to_java
1+
from scyjava import jclass, jimport, numeric_bounds, to_java
2+
from scyjava.config import Mode, mode
23

34

45
class TestTypes(object):
@@ -30,3 +31,22 @@ def test_numeric_bounds(self):
3031
type(v_double)
3132
)
3233
assert (None, None) == numeric_bounds(type(v_bigdec))
34+
35+
def test_jclass(self):
36+
if mode == Mode.JEP:
37+
# JEP does not support the jclass function.
38+
return
39+
40+
# A. Name of a class to look up -- e.g. "java.lang.String" -> String.class
41+
a_cls = jclass("java.lang.String")
42+
assert a_cls.getName() == "java.lang.String"
43+
44+
# B. A static-style class reference -- String -> String.class
45+
String = jimport("java.lang.String")
46+
b_cls = jclass(String)
47+
assert b_cls.getName() == "java.lang.String"
48+
49+
# C. A Java object -- String("hello") -> "hello".getClass()
50+
v_str = to_java("gubernatorial")
51+
c_cls = jclass(v_str)
52+
assert c_cls.getName() == "java.lang.String"

0 commit comments

Comments
 (0)