2021-08-21 19:13:56 +00:00
|
|
|
"""Tests covering the reader."""
|
|
|
|
|
2021-08-21 22:58:59 +00:00
|
|
|
from lilith.parser import Apply, Args, Block, Symbol
|
2021-08-21 19:13:56 +00:00
|
|
|
from lilith.reader import Module, read_buffer
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
2021-08-21 22:58:59 +00:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
"example, expected",
|
|
|
|
[
|
|
|
|
(
|
|
|
|
"""!def[main, lang[lil]]\nprint["hello, world"]\n""",
|
|
|
|
Module(
|
|
|
|
"&buff",
|
|
|
|
{
|
|
|
|
Symbol("main"): Block(
|
|
|
|
Apply(Symbol("lang"), Args([Symbol("lil")], {})),
|
|
|
|
['print["hello, world"]'],
|
|
|
|
)
|
|
|
|
},
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
2021-08-21 19:13:56 +00:00
|
|
|
def test_read(example, expected):
|
|
|
|
got = read_buffer(example)
|
|
|
|
assert got == expected
|