Add a Def() read-eval cache

This commit is contained in:
Reid 'arrdem' McKenzie 2021-08-22 11:15:28 -06:00
commit db9c0f7bf8
8 changed files with 67 additions and 22 deletions
projects/lilith/test/python

View file

@ -4,7 +4,7 @@
from lilith.interpreter import Bindings, eval, Runtime
from lilith.parser import Apply, Args, Symbol
from lilith.reader import Module
from lilith.reader import Def, Module
import pytest
@ -37,7 +37,7 @@ def test_hello_world(capsys, runtime):
assert (
eval(
runtime,
Module("__repl__", [], {Symbol("print"): print}),
Module("__repl__", [], {Symbol("print"): Def("__builtin__.print", print)}),
Bindings("__root__", None),
Apply(Symbol("print"), Args(["hello, world"], {})),
)

View file

@ -1,7 +1,7 @@
"""Tests covering the reader."""
from lilith.parser import Apply, Args, Block, Symbol
from lilith.reader import Module, read_buffer
from lilith.reader import Def, Module, read_buffer
import pytest
@ -14,9 +14,11 @@ import pytest
Symbol("&buff"),
[],
{
Symbol("main"): Block(
Apply(Symbol("lang"), Args([Symbol("lil")], {})),
['print["hello, world"]'],
Symbol("main"): Def(
Block(
Apply(Symbol("lang"), Args([Symbol("lil")], {})),
['print["hello, world"]'],
),
)
},
),