Пример #1
0
 def test_float_to_int_unqualified_field(self) -> None:
     with self.assertRaises(TypeError):
         numerical(  # type: ignore
             req_int_val=5,
             req_float_val=math.pi,
             int_val=math.pi
         )
Пример #2
0
 def test_float_to_int_list(self) -> None:
     with self.assertRaises(TypeError):
         numerical(
             req_int_val=5,
             req_float_val=math.pi,
             int_list=[math.pi, math.e],  # type: ignore
         )
Пример #3
0
 def test_float_to_int_unqualified_field(self) -> None:
     with self.assertRaises(TypeError):
         numerical(
             float_val=math.pi,
             # pyre-fixme[6]: Expected `Optional[int]` for 3rd param but got `float`.
             int_val=math.pi,
         )
Пример #4
0
 def test_float_to_int_list(self) -> None:
     with self.assertRaises(TypeError):
         numerical(
             req_int_val=5,
             req_float_val=math.pi,
             int_list=[math.pi, math.e],  # type: ignore
         )
Пример #5
0
 def test_float_to_int_list(self) -> None:
     with self.assertRaises(TypeError):
         numerical(
             req_int_val=5,
             req_float_val=math.pi,
             # pyre-fixme[6]: Expected `Optional[typing.Sequence[int]]` for 3rd
             #  param but got `List[float]`.
             int_list=[math.pi, math.e],
         )
Пример #6
0
 def test_int_to_float(self) -> None:
     x = numerical(req_int_val=5,
                   req_float_val=5,
                   float_val=5,
                   float_list=[1, 5, 6])
     x(req_float_val=10)
     x(float_val=10)
     x(float_list=[6, 7, 8])
Пример #7
0
 def test_float_to_int_required_field(self) -> None:
     with self.assertRaises(TypeError):
         # pyre-fixme[6]: Expected `Optional[int]` for 1st param but got `float`.
         numerical(req_int_val=math.pi, req_float_val=math.pi)
Пример #8
0
 def test_int_to_i64(self) -> None:
     large = 2**63 - 1
     numerical(req_int_val=5, req_float_val=5, i64_val=int(large))
     too_large = 2**65 - 1
     with self.assertRaises(OverflowError):
         numerical(req_int_val=5, req_float_val=5, i64_val=int(too_large))
Пример #9
0
    def test_overflow(self) -> None:
        with self.assertRaises(OverflowError):
            numerical(req_float_val=5, req_int_val=2**63 - 1)

        with self.assertRaises(OverflowError):
            numerical(req_float_val=5, req_int_val=2, int_list=[5, 2**32])
Пример #10
0
 def test_float_to_int_required_field(self) -> None:
     with self.assertRaises(TypeError):
         numerical(req_int_val=math.pi, req_float_val=math.pi)  # type: ignore
Пример #11
0
 def test_float_to_int_unqualified_field(self) -> None:
     with self.assertRaises(TypeError):
         numerical(  # type: ignore
             req_int_val=5, req_float_val=math.pi, int_val=math.pi
         )
Пример #12
0
 def test_float_to_int_required_field(self) -> None:
     with self.assertRaises(TypeError):
         numerical(req_int_val=math.pi, req_float_val=math.pi)  # type: ignore
Пример #13
0
 def test_int_to_float(self) -> None:
     x = numerical(req_int_val=5, req_float_val=5, float_val=5, float_list=[1, 5, 6])
     x(req_float_val=10)
     x(float_val=10)
     x(float_list=[6, 7, 8])
Пример #14
0
    def test_overflow(self) -> None:
        with self.assertRaises(OverflowError):
            numerical(req_float_val=5, req_int_val=2 ** 63 - 1)

        with self.assertRaises(OverflowError):
            numerical(req_float_val=5, req_int_val=2, int_list=[5, 2 ** 32])