summaryrefslogtreecommitdiff
path: root/tests/test_reader.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_reader.py')
-rw-r--r--tests/test_reader.py28
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