1 2from overload_numeric import * 3import math 4 5nums = Nums() 6limits = Limits() 7 8 9def check(got, expected): 10 if got != expected: 11 raise RuntimeError("got: " + got + " expected: " + expected) 12 13check(nums.over(0), "signed char") 14check(nums.over(0.0), "float") 15 16check(nums.over(limits.schar_min()), "signed char") 17check(nums.over(limits.schar_max()), "signed char") 18 19check(nums.over(limits.schar_min() - 1), "short") 20check(nums.over(limits.schar_max() + 1), "short") 21check(nums.over(limits.shrt_min()), "short") 22check(nums.over(limits.shrt_max()), "short") 23 24check(nums.over(limits.shrt_min() - 1), "int") 25check(nums.over(limits.shrt_max() + 1), "int") 26check(nums.over(limits.int_min()), "int") 27check(nums.over(limits.int_max()), "int") 28 29check(nums.over(limits.flt_min()), "float") 30check(nums.over(limits.flt_max()), "float") 31 32check(nums.over(limits.flt_max() * 10), "double") 33check(nums.over(-limits.flt_max() * 10), "double") 34check(nums.over(limits.dbl_max()), "double") 35check(nums.over(-limits.dbl_max()), "double") 36 37check(nums.over(float("inf")), "float") 38check(nums.over(float("-inf")), "float") 39check(nums.over(float("nan")), "float") 40 41# Just check if the following are accepted without exceptions being thrown 42nums.doublebounce(float("inf")) 43nums.doublebounce(float("-inf")) 44nums.doublebounce(float("nan")) 45