def test_python_only_i64(): def return_true(): return True def return_false(): return False def return_non_zero(): return 3 def return_string(): return "string" # I64 datatype creation from boolean forms assert I64Value(True).value == 1 assert I64Value(return_true()).value == 1 assert I64Value(not return_false()).value == 1 assert I64Value(I64Value(True)).value == 1 assert I64Value(I64Value(True).value).value == 1 assert I64Value(I64Value(return_true())).value == 1 assert I64Value(False).value == 0 assert I64Value(return_false()).value == 0 assert I64Value(not return_true()).value == 0 assert I64Value(I64Value(False)).value == 0 assert I64Value(I64Value(False).value).value == 0 assert I64Value(I64Value(return_false())).value == 0 # I64 datatype creation from numeric forms assert I64Value(3).value == 3 assert I64Value(3.3).value == 3 assert I64Value(DoubleValue(3.3)).value == 3 assert I64Value(return_non_zero()).value == return_non_zero() assert I64Value(I64Value(3)).value == 3 assert I64Value(I64Value(3).value).value == 3 # I64 datatype creation from expression assert I64Value(2 + 1).value == 3 assert I64Value(False and True).value == 0 assert I64Value(5 < 10).value == 1 assert I64Value(return_non_zero() > 1).value == 1 # I64 datatype creation from array assert I64Value(I64ValueArray([1, 3])[0]).value == 1 assert I64Value([1, 3][1]).value == 3 # I64 datatype creation that should fail with pytest.raises(TypeError): I64Value('3') with pytest.raises(TypeError): I64Value('string') with pytest.raises(TypeError): I64Value(object()) with pytest.raises(TypeError): I64Value([]) with pytest.raises(TypeError): I64Value(I64ValueArray([1]))
def int64_array_overflow(): a = I64ValueArray([0x80000000000000001, 0x8000000000000000]) return a.value
def int64_array_invalid_type1(): a = I64ValueArray( [5, '-5']) # noqa: F841 it's ok for this variable to never be used
def int64_array_type_run(): a = I64ValueArray([0, 1, 5]) return a[2].value
def int64_array_one_element_run(): a = I64ValueArray([1]) return a[0].value
def int64_array_empty(): a = I64ValueArray( []) # noqa: F841 it's ok for this variable to never be used
def int64_array_type(): a = I64ValueArray( [0, 1, 5]) # noqa: F841 it's ok for this variable to never be used
def int64_array_one_element(): a = I64ValueArray( [1]) # noqa: F841 it's ok for this variable to never be used