From 5cc96a0fb06fa7d86563f4cb64e5fa9d4f6a09f9 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Mon, 13 Nov 2017 01:00:33 -0500 Subject: 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. --- tests/test_reader.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/test_reader.py (limited to 'tests/test_reader.py') 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 -- cgit v1.2.3