source/projects/lilith/test/python/test_reader.py

36 lines
798 B
Python
Raw Normal View History

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