34 lines
761 B
Python
34 lines
761 B
Python
"""
|
|
|
|
"""
|
|
|
|
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"
|