Skip to content

Commit

Permalink
add table unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
bbyalcinkaya committed Jan 19, 2024
1 parent b03c138 commit 5b65130
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions pykwasm/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ disallow_untyped_defs = true
exclude = [
'src/pykwasm/wasm2kast\.py',
'src/wasm/*',
'src/tests/unit/test_wasm2kast\.py',
]

[tool.poetry.scripts]
Expand Down
21 changes: 21 additions & 0 deletions pykwasm/src/tests/unit/test_wasm2kast.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import pytest
from pyk.kast.inner import KApply, KInner
from wasm.datatypes import ExternAddress, FunctionAddress, Limits, Table, TableType

from pykwasm import wasm2kast
from pykwasm.kwasm_ast import KInt, externref, funcref

TABLE_TEST_DATA = (
(Table(TableType(Limits(0, None), FunctionAddress)), KApply('limitsMin', [KInt(0)]), funcref),
(Table(TableType(Limits(0, 100), ExternAddress)), KApply('limitsMinMax', [KInt(0), KInt(100)]), externref),
)


@pytest.mark.parametrize(('input', 'limits', 'typ'), TABLE_TEST_DATA)
def test_table(input: Table, limits: KInner, typ: KInner) -> None:
# When
t = wasm2kast.table(input)

# Then
assert limits == t.args[0]
assert typ == t.args[1]

0 comments on commit 5b65130

Please sign in to comment.