Doesn't give right answer yet and out of bound check fails. No constructor yet for static arrays, but module constants work. Which don't work yet for tuples and structs. Also, u32 for indexing please. Also, more module constant types.
32 lines
645 B
Python
32 lines
645 B
Python
import pytest
|
|
|
|
from .helpers import Suite
|
|
|
|
@pytest.mark.integration_test
|
|
def test_bytes_index_out_of_bounds():
|
|
code_py = """
|
|
@exported
|
|
def testEntry(f: bytes) -> u8:
|
|
return f[50]
|
|
"""
|
|
|
|
result = Suite(code_py).run_code(b'Short', b'Long' * 100)
|
|
|
|
assert 0 == result.returned_value
|
|
|
|
@pytest.mark.integration_test
|
|
def test_static_array_index_out_of_bounds():
|
|
code_py = """
|
|
CONSTANT0: u32[3] = (24, 57, 80, )
|
|
|
|
CONSTANT1: u32[16] = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, )
|
|
|
|
@exported
|
|
def testEntry() -> u32:
|
|
return CONSTANT0[16]
|
|
"""
|
|
|
|
result = Suite(code_py).run_code()
|
|
|
|
assert 0 == result.returned_value
|