# Path: app/src/main/python/chaquopy/test/test_utils.py
# class FilterWarningsCase(TestCase):
# 
#     def setUp(self):
#         super().setUp()
#         self.cw = catch_warnings()
#         self.cw.__enter__()
#         filterwarnings("error")
# 
#     def tearDown(self):
#         self.cw.__exit__(None, None, None)
#         super().tearDown()


from java import cast, jarray, jboolean, jbyte, jchar, jclass, jdouble, jfloat, jint, jlong, jshort
from .test_utils import FilterWarningsCase
from com.chaquo.python import TestOverload as TO
        from java.lang import Integer
        self.assertEqual("int... null", obj.resolve_ID(cast(jarray(jint), None)))
        self.assertEqual("double... null", obj.resolve_ID(cast(jarray(jdouble), None)))
        with self.inapplicable:
            obj.resolve_ID(None, None)
        self.assertEqual("int 42", obj.resolve_ID(42))
        self.assertEqual("double 42.0", obj.resolve_ID(42.0))
        self.assertEqual("double... [1.0, 2.0]", obj.resolve_ID(jarray(jdouble)([1, 2])))
        self.assertEqual("double... [1.0, 2.0]", obj.resolve_ID(1.0, 2.0))
        self.assertEqual("double... [1.0, 2.0]", obj.resolve_ID(1, 2.0))
        self.assertEqual("double... [1.0, 2.0]", obj.resolve_ID(1.0, 2))

        Long = jclass("java.lang.Long")
        with self.ambiguous:
            obj.resolve_I_Long()        # Neither int nor Long are more specific.
        with self.ambiguous:
            obj.resolve_I_Long(None)    # Neither int[] nor Long[] are more specific.
        self.assertEqual("Long... [null, null]", obj.resolve_I_Long(None, None))
        with self.ambiguous:
            obj.resolve_I_Long(42)
        with self.inapplicable:
            obj.resolve_I_Long(42.0)
        self.assertEqual("int... [42]", obj.resolve_I_Long(jint(42)))
        self.assertEqual("Long... [42]", obj.resolve_I_Long(jlong(42)))
        self.assertEqual("Long... [42]", obj.resolve_I_Long(Long(42)))

        Number = jclass("java.lang.Number")
        # Long[] is more specific than Number[].
        self.assertEqual("Long... []", obj.resolve_Number_Long())
        self.assertEqual("Long... [42]", obj.resolve_Number_Long(42))
        self.assertEqual("Long... null", obj.resolve_Number_Long(None))

# Path: app/src/main/python/chaquopy/test/test_utils.py
# class FilterWarningsCase(TestCase):
# 
#     def setUp(self):
#         super().setUp()
#         self.cw = catch_warnings()
#         self.cw.__enter__()
#         filterwarnings("error")
# 
#     def tearDown(self):
#         self.cw.__exit__(None, None, None)
#         super().tearDown()


# Path: app/src/main/python/chaquopy/test/test_overload.py
from java import cast, jarray, jboolean, jbyte, jchar, jclass, jdouble, jfloat, jint, jlong, jshort
from .test_utils import FilterWarningsCase
from com.chaquo.python import TestOverload as TO
        from java.lang import Integer

        self.assertEqual("int... null", obj.resolve_ID(cast(jarray(jint), None)))
        self.assertEqual("double... null", obj.resolve_ID(cast(jarray(jdouble), None)))
        with self.inapplicable:
            obj.resolve_ID(None, None)
        self.assertEqual("int 42", obj.resolve_ID(42))
        self.assertEqual("double 42.0", obj.resolve_ID(42.0))
        self.assertEqual("double... [1.0, 2.0]", obj.resolve_ID(jarray(jdouble)([1, 2])))
        self.assertEqual("double... [1.0, 2.0]", obj.resolve_ID(1.0, 2.0))
        self.assertEqual("double... [1.0, 2.0]", obj.resolve_ID(1, 2.0))
        self.assertEqual("double... [1.0, 2.0]", obj.resolve_ID(1.0, 2))

        Long = jclass("java.lang.Long")
        with self.ambiguous:
            obj.resolve_I_Long()        # Neither int nor Long are more specific.
        with self.ambiguous:
            obj.resolve_I_Long(None)    # Neither int[] nor Long[] are more specific.
        self.assertEqual("Long... [null, null]", obj.resolve_I_Long(None, None))
        with self.ambiguous:
            obj.resolve_I_Long(42)
        with self.inapplicable:
            obj.resolve_I_Long(42.0)
        self.assertEqual("int... [42]", obj.resolve_I_Long(jint(42)))
        self.assertEqual("Long... [42]", obj.resolve_I_Long(jlong(42)))
        self.assertEqual("Long... [42]", obj.resolve_I_Long(Long(42)))

        Number = jclass("java.lang.Number")
        # Long[] is more specific than Number[].
        self.assertEqual("Long... []", obj.resolve_Number_Long())
        self.assertEqual("Long... [42]", obj.resolve_Number_Long(42))
        self.assertEqual("Long... null", obj.resolve_Number_Long(None))

        self.assertEqual("Long... [null]", obj.resolve_Number_Long([None]))