Ejemplo n.º 1
0
 def test_min_value(self):
     assert Ray.min(Ray(10), Ray(20)) == Ray(10)
     assert Ray.min(Ray(25), Ray(15)) == Ray(15)
     assert Ray.min(Ray(25), Ray(15), Ray(5)) == Ray(5)
Ejemplo n.º 2
0
 def test_max_value(self):
     assert Ray.max(Ray(10), Ray(20)) == Ray(20)
     assert Ray.max(Ray(25), Ray(15)) == Ray(25)
     assert Ray.max(Ray(25), Ray(15), Ray(40)) == Ray(40)
Ejemplo n.º 3
0
 def test_should_fail_to_divide_by_ints(self):
     with pytest.raises(ArithmeticError):
         Ray(4) / 2
Ejemplo n.º 4
0
 def test_should_instantiate_from_a_ray(self):
     assert Wad(
         Ray(10000000000000001010101010101)) == Wad(10000000000000001010)
     assert Wad(
         Ray(10000000000000001019999999999)) == Wad(10000000000000001019)
Ejemplo n.º 5
0
 def test_multiply_by_wad(self):
     assert Ray.from_number(2) * Wad.from_number(3) == Ray.from_number(6)
     assert Ray.from_number(2) * Wad(3) == Ray(6000000000)
     assert Ray(2) * Wad(3) == Ray(0)
     assert Ray(2) * Wad(999999999999999999) == Ray(1)
     assert Ray(2) * Wad(1000000000000000000) == Ray(2)
Ejemplo n.º 6
0
 def test_should_fail_to_multiply_by_float(self):
     with pytest.raises(ArithmeticError):
         Ray(2) * 3.0
Ejemplo n.º 7
0
 def test_should_support_negative_values(self):
     Ray(-1)
Ejemplo n.º 8
0
 def test_subtract_should_not_work_with_wads(self):
     with pytest.raises(ArithmeticError):
         Ray(10) - Wad(2)
Ejemplo n.º 9
0
 def test_should_fail_to_divide_by_rays(self):
     with pytest.raises(ArithmeticError):
         Wad(4) / Ray(2)
Ejemplo n.º 10
0
 def test_max_value_should_reject_comparison_with_rays(self):
     with pytest.raises(ArithmeticError):
         Wad.max(Wad(10), Ray(20))
     with pytest.raises(ArithmeticError):
         Wad.max(Wad(25), Ray(15))
Ejemplo n.º 11
0
 def test_subtract_should_not_work_with_rays(self):
     with pytest.raises(ArithmeticError):
         Wad(10) - Ray(2)
Ejemplo n.º 12
0
 def test_add_should_not_work_with_rays(self):
     with pytest.raises(ArithmeticError):
         Wad(1) + Ray(2)
Ejemplo n.º 13
0
 def test_max_value_should_reject_comparison_with_ints(self):
     with pytest.raises(ArithmeticError):
         Ray.max(Ray(10), 20)
     with pytest.raises(ArithmeticError):
         Ray.max(15, Ray(25))
Ejemplo n.º 14
0
 def test_add_should_not_work_with_ints(self):
     with pytest.raises(ArithmeticError):
         Ray(1) + 2
Ejemplo n.º 15
0
 def test_should_support_values_greater_than_uint256(self):
     Ray(2**256)
     Ray(2**256 + 1)
     Ray(2**512)
Ejemplo n.º 16
0
 def test_subtract(self):
     assert Ray(10) - Ray(2) == Ray(8)
     assert Ray(1) - Ray(2) == Ray(-1)
Ejemplo n.º 17
0
 def test_should_instantiate_from_a_ray(self):
     assert Ray(Ray(1)) == Ray(1)
Ejemplo n.º 18
0
 def test_multiply(self):
     assert Ray.from_number(2) * Ray.from_number(3) == Ray.from_number(6)
     assert Ray.from_number(2) * Ray(3) == Ray(6)
     assert Ray.from_number(2.5) * Ray(3) == Ray(7)
     assert Ray.from_number(2.99999) * Ray(3) == Ray(8)
Ejemplo n.º 19
0
 def test_should_instantiate_from_a_wad(self):
     assert Ray(
         Wad(10000000000000000000)) == Ray(10000000000000000000000000000)
Ejemplo n.º 20
0
 def test_multiply_by_int(self):
     assert Ray.from_number(2) * 3 == Ray.from_number(6)
     assert Ray.from_number(2) * 1 == Ray.from_number(2)
Ejemplo n.º 21
0
 def test_should_instantiate_from_an_int(self):
     assert Ray(10).value == 10
Ejemplo n.º 22
0
 def test_divide(self):
     assert Ray.from_number(4) / Ray.from_number(2) == Ray.from_number(2)
     assert Ray(4) / Ray.from_number(2) == Ray(2)
     assert Ray(3) / Ray.from_number(2) == Ray(1)
     assert Ray(39) / Ray.from_number(20) == Ray(1)
     assert Ray(40) / Ray.from_number(20) == Ray(2)
     assert Ray.from_number(0.2) / Ray.from_number(0.1) == Ray.from_number(
         2)
Ejemplo n.º 23
0
 def test_should_fail_to_instantiate_from_a_float(self):
     with pytest.raises(ArithmeticError):
         assert Ray(10.5)
Ejemplo n.º 24
0
 def test_should_compare_rays_with_each_other(self):
     assert Ray(1000) == Ray(1000)
     assert Ray(1000) != Ray(999)
     assert Ray(1000) > Ray(999)
     assert Ray(999) < Ray(1000)
     assert Ray(999) <= Ray(1000)
     assert Ray(1000) <= Ray(1000)
     assert Ray(1000) >= Ray(1000)
     assert Ray(1000) >= Ray(999)
Ejemplo n.º 25
0
 def test_should_have_nice_printable_representation(self):
     for ray in [Ray(1), Ray(100), Ray.from_number(2.5), Ray(-1)]:
         assert repr(ray) == f"Ray({ray.value})"
Ejemplo n.º 26
0
 def test_should_be_hashable(self):
     assert is_hashable(Ray(123))
Ejemplo n.º 27
0
 def test_add(self):
     assert Ray(1) + Ray(2) == Ray(3)
Ejemplo n.º 28
0
 def test_min_value_should_reject_comparison_with_wads(self):
     with pytest.raises(ArithmeticError):
         Ray.min(Ray(10), Wad(20))
     with pytest.raises(ArithmeticError):
         Ray.min(Wad(25), Ray(15))
Ejemplo n.º 29
0
 def test_min_value_should_reject_comparison_with_ints(self):
     with pytest.raises(ArithmeticError):
         Ray.min(Ray(10), 20)
     with pytest.raises(ArithmeticError):
         Ray.min(20, Ray(10))