def test_program_to_lispress_with_quotes_inside_string():
    # a string with a double-quote in it
    v, _ = mk_value_op(value='i got quotes"', schema="String", idx=0)
    program = Program(expressions=[v])
    rendered_lispress = render_pretty(program_to_lispress(program))
    assert rendered_lispress == '(#(String "i got quotes\\""))'
    round_tripped, _ = lispress_to_program(parse_lispress(rendered_lispress), 0)
    assert round_tripped == program
def test_surface_to_sexp_round_trips():
    """
    Tests that parsing a Lispress surface string into an S-expression
    and then pretty printing it is a no-op.
    """
    for surface_string in surface_strings:
        surface_string = surface_string.strip()
        lispress = parse_lispress(surface_string)
        round_tripped_surface_string = render_pretty(lispress)
        assert round_tripped_surface_string == surface_string
def test_surface_to_program_round_trips():
    """
    Goes all the way to `Program` and so is stricter
    than `test_surface_to_sexp_round_trips`.
    """
    for surface_string in surface_strings:
        surface_string = surface_string.strip()
        sexp = parse_lispress(surface_string)
        program, _ = lispress_to_program(sexp, 0)
        round_tripped_sexp = program_to_lispress(program)
        round_tripped_surface_string = render_pretty(round_tripped_sexp, max_width=60)
        assert round_tripped_surface_string == surface_string