type5 is much more first principles based, so we get a lot of weird quirks removed: - FromLiteral no longer needs to understand AST - Type unifications works more like Haskell - Function types are just ordinary types, saving a lot of manual busywork and more.
59 lines
1.2 KiB
Python
59 lines
1.2 KiB
Python
import pytest
|
|
|
|
from phasm.type5.solver import Type5SolverException
|
|
|
|
from ..helpers import Suite
|
|
|
|
|
|
@pytest.mark.integration_test
|
|
def test_static_array_constant_too_few_values():
|
|
code_py = """
|
|
CONSTANT: u8[4] = (24, 57, )
|
|
|
|
@exported
|
|
def testEntry() -> i32:
|
|
return 0
|
|
"""
|
|
|
|
with pytest.raises(Type5SolverException, match='Tuple element count mismatch'):
|
|
Suite(code_py).run_code()
|
|
|
|
@pytest.mark.integration_test
|
|
def test_static_array_constant_too_many_values():
|
|
code_py = """
|
|
CONSTANT: u8[3] = (24, 57, 1, 1, )
|
|
|
|
@exported
|
|
def testEntry() -> i32:
|
|
return 0
|
|
"""
|
|
|
|
with pytest.raises(Type5SolverException, match='Tuple element count mismatch'):
|
|
Suite(code_py).run_code()
|
|
|
|
@pytest.mark.integration_test
|
|
def test_static_array_export_constant():
|
|
code_py = """
|
|
CONSTANT: u8[3] = (1, 2, 3, )
|
|
|
|
@exported
|
|
def testEntry() -> u8[3]:
|
|
return CONSTANT
|
|
"""
|
|
|
|
result = Suite(code_py).run_code()
|
|
|
|
assert (1, 2, 3) == result.returned_value
|
|
|
|
@pytest.mark.integration_test
|
|
def test_static_array_export_instantiation():
|
|
code_py = """
|
|
@exported
|
|
def testEntry() -> u8[3]:
|
|
return (1, 2, 3, )
|
|
"""
|
|
|
|
result = Suite(code_py).run_code()
|
|
|
|
assert (1, 2, 3) == result.returned_value
|