Adds a separte typing system #3
@ -360,3 +360,17 @@ def helper(left: {type_}, right: {type_}) -> {type_}:
|
||||
|
||||
assert 32.125 == result.returned_value
|
||||
assert TYPE_MAP[type_] == type(result.returned_value)
|
||||
|
||||
@pytest.mark.integration_test
|
||||
def test_call_invalid_type():
|
||||
code_py = """
|
||||
def helper() -> i64:
|
||||
return 19
|
||||
|
||||
@exported
|
||||
def testEntry() -> i32:
|
||||
return helper()
|
||||
"""
|
||||
|
||||
with pytest.raises(TypingError, match=r'i32.*i64'):
|
||||
Suite(code_py).run_code()
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
import pytest
|
||||
|
||||
from phasm.parser import phasm_parse
|
||||
from phasm.typer import phasm_type
|
||||
from phasm.exceptions import TypingError
|
||||
|
||||
@pytest.mark.integration_test
|
||||
def test_constant_too_wide():
|
||||
code_py = """
|
||||
def func_const() -> u8:
|
||||
return 0xFFF
|
||||
"""
|
||||
|
||||
ast = phasm_parse(code_py)
|
||||
with pytest.raises(TypingError, match='Other min bitwidth exceeds max bitwidth'):
|
||||
phasm_type(ast)
|
||||
|
||||
@pytest.mark.integration_test
|
||||
@pytest.mark.parametrize('type_', [32, 64])
|
||||
def test_signed_mismatch(type_):
|
||||
code_py = f"""
|
||||
def func_const() -> u{type_}:
|
||||
return 0
|
||||
|
||||
def func_call() -> i{type_}:
|
||||
return func_const()
|
||||
"""
|
||||
|
||||
ast = phasm_parse(code_py)
|
||||
with pytest.raises(TypingError, match='Signed does not match'):
|
||||
phasm_type(ast)
|
||||
Loading…
x
Reference in New Issue
Block a user