Exemple #1
0
 def test_float_to_int_unqualified_field(self) -> None:
     with self.assertRaises(TypeError):
         numerical(
             float_val=math.pi,
             # pyre-ignore[6]: for test
             int_val=math.pi,
         )
Exemple #2
0
 def test_float_to_int_list(self) -> None:
     with self.assertRaises(TypeError):
         numerical(
             int_val=5,
             float_val=math.pi,
             # pyre-ignore[6]: for test
             int_list=[math.pi, math.e],
         )
Exemple #3
0
 def test_float_to_int_required_field(self) -> None:
     with self.assertRaises(TypeError):
         # pyre-ignore[6]: for test
         numerical(int_val=math.pi, float_val=math.pi)
Exemple #4
0
 def test_int_to_i64(self) -> None:
     large = 2**63 - 1
     numerical(int_val=5, float_val=5, i64_val=int(large))
     too_large = 2**65 - 1
     with self.assertRaises(OverflowError):
         numerical(int_val=5, float_val=5, i64_val=int(too_large))
Exemple #5
0
 def test_int_to_float(self) -> None:
     x = numerical(int_val=5, float_val=5, float_list=[1, 5, 6])
     x(float_val=10)
     x(float_list=[6, 7, 8])
Exemple #6
0
    def test_overflow(self) -> None:
        with self.assertRaises(OverflowError):
            numerical(float_val=5, int_val=2**63 - 1)

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