diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2017-11-13 01:00:33 -0500 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2017-11-13 01:01:34 -0500 |
| commit | 5cc96a0fb06fa7d86563f4cb64e5fa9d4f6a09f9 (patch) | |
| tree | 40052668ffe030452b45e3a2d6be8d8fc24acdee /tests/test_reader.py | |
| parent | 6a635660bd7b47238642d4a552782687352555ac (diff) | |
Big-ass coding binge presents: a Lisp.
This implements a continuation-passing interpreter, which means we get tail calls ferfree. I stopped short of implementing call/cc, because I don't think we need it, but we can get there if we have to.
Diffstat (limited to 'tests/test_reader.py')
| -rw-r--r-- | tests/test_reader.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test_reader.py b/tests/test_reader.py new file mode 100644 index 0000000..54a1681 --- /dev/null +++ b/tests/test_reader.py @@ -0,0 +1,28 @@ +from hypothesis import given +from hypothesis.strategies import text + +from actinide.reader import * +from actinide.ports import * +from actinide.types import * + +from .forms import * + +# Cases for the reader: + +# * Given a form, can the reader recover it from its display? +@given(forms()) +def test_reader(form): + input = display(form) + port = string_to_input_port(input) + + assert read(port, symbol_table) == form + +# * Given a form and some trailing garbage, can the reader recover the form +# without touching the garbage? This is only reliable with lists and conses. +@given(lists() | conses(), text()) +def test_reader_with_trailing(form, text): + input = display(form) + text + port = string_to_input_port(input) + + assert read(port, symbol_table) == form + assert read_port_fully(port) == text |
