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

35 lines
761 B
Python
Raw Normal View History

2021-08-21 20:07:57 +00:00
"""
"""
from lilith.interpreter import Bindings, Runtime, eval
from lilith.reader import Module
from lilith.parser import Args, Apply
import pytest
@pytest.mark.parametrize('expr, expected', [
(1, 1),
([1, 2], [1, 2]),
({"foo": "bar"}, {"foo": "bar"}),
])
def test_eval(expr, expected):
assert eval(
Runtime("test", dict()),
Module("__repl__", dict()),
Bindings("__root__", None),
expr
) == expected
def test_hello_world(capsys):
assert eval(
Runtime("test", {}),
Module("__repl__", {"print": print}),
Bindings("__root__", None),
Apply("print", Args(["hello, world"], {}))
) is None
captured = capsys.readouterr()
assert captured.out == "hello, world\n"