source/projects/lilith/test/test_reader.py

35 lines
798 B
Python

"""Tests covering the reader."""
from lilith.parser import (
Apply,
Args,
Block,
Symbol,
)
from lilith.reader import Def, Module, read_buffer
import pytest
@pytest.mark.parametrize(
"example, expected",
[
(
"""!def[main, lang[lil]]\nprint["hello, world"]\n""",
Module(
Symbol("&buff"),
[],
{
Symbol("main"): Def(
Block(
Apply(Symbol("lang"), Args([Symbol("lil")], {})),
['print["hello, world"]'],
),
)
},
),
)
],
)
def test_read(example, expected):
got = read_buffer(example)
assert got == expected