Hello, world!
This commit is contained in:
parent
5531b80331
commit
02c5f61bb8
7 changed files with 213 additions and 6 deletions
projects/lilith/test/python
34
projects/lilith/test/python/test_interpreter.py
Normal file
34
projects/lilith/test/python/test_interpreter.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
"""
|
||||
|
||||
"""
|
||||
|
||||
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"
|
|
@ -12,5 +12,4 @@ import pytest
|
|||
])
|
||||
def test_read(example, expected):
|
||||
got = read_buffer(example)
|
||||
print(got)
|
||||
assert got == expected
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue