# 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 jarray, jboolean, jbyte, jchar, jclass, jdouble, jfloat, jint, jlong, jshort, jvoid
from java.chaquopy import jni_sig
from .test_utils import FilterWarningsCase
import math
                    cls(val)
                self.assertEqual("{}({})".format(cls.__name__,
                                                 math.copysign(1, val) * float("inf")),
                                 str(cls(val, truncate=True)))

        with self.assertRaisesRegex(TypeError, "a float or integer is required"):
            cls("42")
        with self.assertRaisesRegex(TypeError, "a float or integer is required"):
            cls(True)

    def test_char(self):
        self.assertEqual("jchar('x')", str(jchar("x")))

        zhong_j = jchar("中")
        zhong_j_u = "jchar('中')"
        self.assertEqual(zhong_j_u, str(zhong_j))

        with self.assertRaisesRegex((TypeError, ValueError),
                                    r"(expected a character|only single character).*length 2"):
            jchar("ab")
        with self.assertRaisesRegex(TypeError, "non-BMP"):
            jchar("\U00010000")

    def test_array(self):
        list_bool = [True, False]
        for jarray_Z in [jarray(jboolean)(list_bool), jarray("Z")(list_bool)]:
            self.assertEqual("jarray('Z')", type(jarray_Z).__name__)
            self.assertEqual("jarray('Z')({!r})".format(list_bool), str(jarray_Z))

        list_list_bool = [[True, False], [False, True]]

# 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_signatures.py
from java import jarray, jboolean, jbyte, jchar, jclass, jdouble, jfloat, jint, jlong, jshort, jvoid
from java.chaquopy import jni_sig
from .test_utils import FilterWarningsCase
import math

                    cls(val)
                self.assertEqual("{}({})".format(cls.__name__,
                                                 math.copysign(1, val) * float("inf")),
                                 str(cls(val, truncate=True)))

        with self.assertRaisesRegex(TypeError, "a float or integer is required"):
            cls("42")
        with self.assertRaisesRegex(TypeError, "a float or integer is required"):
            cls(True)

    def test_char(self):
        self.assertEqual("jchar('x')", str(jchar("x")))

        zhong_j = jchar("中")
        zhong_j_u = "jchar('中')"
        self.assertEqual(zhong_j_u, str(zhong_j))

        with self.assertRaisesRegex((TypeError, ValueError),
                                    r"(expected a character|only single character).*length 2"):
            jchar("ab")
        with self.assertRaisesRegex(TypeError, "non-BMP"):
            jchar("\U00010000")

    def test_array(self):
        list_bool = [True, False]
        for jarray_Z in [jarray(jboolean)(list_bool), jarray("Z")(list_bool)]:
            self.assertEqual("jarray('Z')", type(jarray_Z).__name__)
            self.assertEqual("jarray('Z')({!r})".format(list_bool), str(jarray_Z))

        list_list_bool = [[True, False], [False, True]]

        jarray_jarray_Z = jarray(jarray(jboolean))(list_list_bool)