phasm/tests/integration/test_fib.py
2022-03-04 09:57:35 +01:00

32 lines
522 B
Python

import pytest
from .helpers import Suite
@pytest.mark.slow_integration_test
def test_fib():
code_py = """
def helper(n: i32, a: i32, b: i32) -> i32:
if n < 1:
return a + b
return helper(n - 1, a + b, a)
def fib(n: i32) -> i32:
if n == 0:
return 0
if n == 1:
return 1
return helper(n - 1, 0, 1)
@exported
def testEntry() -> i32:
return fib(40)
"""
result = Suite(code_py, 'test_fib').run_code()
assert 102334155 == result.returned_value
assert False