Adding in some tests for print
This commit is contained in:
parent
b4ba4087df
commit
6831841699
@ -166,6 +166,14 @@ class HyASTCompiler(object):
|
||||
@builds("print")
|
||||
def compile_print_expression(self, expr):
|
||||
expr.pop(0) # print
|
||||
if sys.version_info[0] >= 3:
|
||||
# AST changed with Python 3, we now just call it.
|
||||
return ast.Call(
|
||||
func=ast.Name(id='print', ctx=ast.Load()),
|
||||
args=[self.compile(x) for x in expr],
|
||||
lineno=expr.start_line,
|
||||
col_offset=expr.start_column)
|
||||
|
||||
return ast.Print(
|
||||
lineno=expr.start_line,
|
||||
col_offset=expr.start_column,
|
||||
|
@ -20,7 +20,9 @@
|
||||
|
||||
from hy.compiler import hy_compile, HyCompileError
|
||||
from hy.lex import tokenize
|
||||
|
||||
import ast
|
||||
import sys
|
||||
|
||||
|
||||
def _ast_spotcheck(arg, root, secondary):
|
||||
@ -73,3 +75,12 @@ def test_ast_non_decoratable():
|
||||
assert True == False
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
|
||||
def test_ast_print():
|
||||
""" Ensure print doesn't suck. """
|
||||
code = hy_compile(tokenize("(print \"foo\")")).body[0]
|
||||
if sys.version_info[0] >= 3:
|
||||
assert type(code.value) == ast.Call
|
||||
return
|
||||
assert type(code) == ast.Print
|
||||
|
Loading…
Reference in New Issue
Block a user