Beispiel #1
0
def test_print_escape_newlines():
    assert parse([
        tokens.ID('print'),
        tokens.WS(' '),
        tokens.ID('butt\\n'),
        tokens.WS('\n'),
    ]) == ast.Module(ast.Print(), ast.String(' butt\n'))
Beispiel #2
0
def test_print():
    assert parse([
        tokens.ID('print'),
        tokens.WS(' '),
        tokens.ID('butt'),
        tokens.WS('\n'),
    ]) == ast.Module(ast.Print(), ast.String(' butt'))
Beispiel #3
0
def test_lex_print():
    assert lex('print butt fart\n') == [
        tokens.ID('print'),
        tokens.WS(' '),
        tokens.ID('butt'),
        tokens.WS(' '),
        tokens.ID('fart'),
        tokens.WS('\n'),
    ]
Beispiel #4
0
def test_parse_hello_with_whitespace():
    assert parse([tokens.WS('\n\n   '),
                  tokens.ID('hello'),
                  tokens.WS('\n\t')]) == ast.Module(ast.Hello())
Beispiel #5
0
def test_lex_hello_whitespace():
    assert lex('\n\n   hello\n\t') == [
        tokens.WS('\n\n   '),
        tokens.ID('hello'),
        tokens.WS('\n\t')
    ]