示例#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)
示例#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)
示例#3
0
 def test_should_fail_to_divide_by_ints(self):
     with pytest.raises(ArithmeticError):
         Ray(4) / 2
示例#4
0
 def test_should_instantiate_from_a_ray(self):
     assert Wad(
         Ray(10000000000000001010101010101)) == Wad(10000000000000001010)
     assert Wad(
         Ray(10000000000000001019999999999)) == Wad(10000000000000001019)
示例#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)
示例#6
0
 def test_should_fail_to_multiply_by_float(self):
     with pytest.raises(ArithmeticError):
         Ray(2) * 3.0
示例#7
0
 def test_should_support_negative_values(self):
     Ray(-1)
示例#8
0
 def test_subtract_should_not_work_with_wads(self):
     with pytest.raises(ArithmeticError):
         Ray(10) - Wad(2)
示例#9
0
 def test_should_fail_to_divide_by_rays(self):
     with pytest.raises(ArithmeticError):
         Wad(4) / Ray(2)
示例#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))
示例#11
0
 def test_subtract_should_not_work_with_rays(self):
     with pytest.raises(ArithmeticError):
         Wad(10) - Ray(2)
示例#12
0
 def test_add_should_not_work_with_rays(self):
     with pytest.raises(ArithmeticError):
         Wad(1) + Ray(2)
示例#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))
示例#14
0
 def test_add_should_not_work_with_ints(self):
     with pytest.raises(ArithmeticError):
         Ray(1) + 2
示例#15
0
 def test_should_support_values_greater_than_uint256(self):
     Ray(2**256)
     Ray(2**256 + 1)
     Ray(2**512)
示例#16
0
 def test_subtract(self):
     assert Ray(10) - Ray(2) == Ray(8)
     assert Ray(1) - Ray(2) == Ray(-1)
示例#17
0
 def test_should_instantiate_from_a_ray(self):
     assert Ray(Ray(1)) == Ray(1)
示例#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)
示例#19
0
 def test_should_instantiate_from_a_wad(self):
     assert Ray(
         Wad(10000000000000000000)) == Ray(10000000000000000000000000000)
示例#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)
示例#21
0
 def test_should_instantiate_from_an_int(self):
     assert Ray(10).value == 10
示例#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)
示例#23
0
 def test_should_fail_to_instantiate_from_a_float(self):
     with pytest.raises(ArithmeticError):
         assert Ray(10.5)
示例#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)
示例#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})"
示例#26
0
 def test_should_be_hashable(self):
     assert is_hashable(Ray(123))
示例#27
0
 def test_add(self):
     assert Ray(1) + Ray(2) == Ray(3)
示例#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))
示例#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))