summaryrefslogtreecommitdiff
path: root/tests/test_reader.py
blob: 54a1681bc9fbb5eccd5212ab8e40c1535b2df07a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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