import pytest from ..helpers import Suite INT_TYPES = ['i32', 'i64'] FLOAT_TYPES = ['f32', 'f64'] TYPE_MAP = { 'i32': int, 'i64': int, 'f32': float, 'f64': float, } @pytest.mark.integration_test @pytest.mark.parametrize('type_', INT_TYPES) def test_abs_int(type_): code_py = f""" @exported def testEntry() -> {type_}: return abs(-3) """ result = Suite(code_py).run_code() assert 3 == result.returned_value assert TYPE_MAP[type_] is type(result.returned_value) @pytest.mark.integration_test @pytest.mark.parametrize('type_', FLOAT_TYPES) def test_abs_float(type_): code_py = f""" @exported def testEntry() -> {type_}: return abs(-3.5) """ result = Suite(code_py).run_code() assert 3.5 == result.returned_value assert TYPE_MAP[type_] is type(result.returned_value) @pytest.mark.integration_test @pytest.mark.parametrize('type_', INT_TYPES) def test_neg_int(type_): code_py = f""" @exported def testEntry() -> {type_}: return neg(3) """ result = Suite(code_py).run_code() assert -3 == result.returned_value assert TYPE_MAP[type_] is type(result.returned_value) @pytest.mark.integration_test @pytest.mark.parametrize('type_', FLOAT_TYPES) def test_neg_float(type_): code_py = f""" @exported def testEntry() -> {type_}: return neg(3.5) """ result = Suite(code_py).run_code() assert -3.5 == result.returned_value assert TYPE_MAP[type_] is type(result.returned_value)