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.
62 lines
1.1 KiB
Python
62 lines
1.1 KiB
Python
import pytest
|
|
|
|
from ..helpers import Suite
|
|
|
|
|
|
@pytest.mark.integration_test
|
|
def test_call_nullary():
|
|
code_py = """
|
|
def helper() -> i32:
|
|
return 3
|
|
|
|
@exported
|
|
def testEntry() -> i32:
|
|
return helper()
|
|
"""
|
|
|
|
result = Suite(code_py).run_code()
|
|
|
|
assert 3 == result.returned_value
|
|
|
|
@pytest.mark.integration_test
|
|
def test_call_pre_defined():
|
|
code_py = """
|
|
def helper(left: i32) -> i32:
|
|
return left
|
|
|
|
@exported
|
|
def testEntry() -> i32:
|
|
return helper(13)
|
|
"""
|
|
|
|
result = Suite(code_py).run_code()
|
|
|
|
assert 13 == result.returned_value
|
|
|
|
@pytest.mark.integration_test
|
|
def test_call_post_defined():
|
|
code_py = """
|
|
@exported
|
|
def testEntry() -> i32:
|
|
return helper(10, 3)
|
|
|
|
def helper(left: i32, right: i32) -> i32:
|
|
return left - right
|
|
"""
|
|
|
|
result = Suite(code_py).run_code()
|
|
|
|
assert 7 == result.returned_value
|
|
|
|
@pytest.mark.integration_test
|
|
@pytest.mark.skip('FIXME: Type checking')
|
|
def test_call_invalid_type():
|
|
code_py = """
|
|
def helper(left: i32) -> i32:
|
|
return left()
|
|
"""
|
|
|
|
result = Suite(code_py).run_code()
|
|
|
|
assert 7 == result.returned_value
|