Updating the tests to not break Python 3.x

This commit is contained in:
Paul R. Tagliamonte 2013-04-01 23:06:59 -04:00
parent fb6ec426e6
commit b1c605cc6a
2 changed files with 6 additions and 3 deletions

View File

@ -166,11 +166,13 @@ class HyASTCompiler(object):
@builds("print")
def compile_print_expression(self, expr):
expr.pop(0) # print
call = expr.pop(0) # print
if sys.version_info[0] >= 3:
call = self.compile(call)
# AST changed with Python 3, we now just call it.
return ast.Call(
func=ast.Name(id='print', ctx=ast.Load()),
keywords=[],
func=call,
args=[self.compile(x) for x in expr],
lineno=expr.start_line,
col_offset=expr.start_column)

View File

@ -206,4 +206,5 @@
"NATIVE: test list comprehensions"
(assert (= (list-comp (* x 2) (x (range 2))) [0 2]))
(assert (= (list-comp (* x 2) (x (range 4)) (% x 2)) [2 6]))
(assert (= (list-comp (* y 2) ((, x y) (.iteritems {"1" 1 "2" 2}))) [2 4])))
(assert (= (sorted (list-comp (* y 2) ((, x y) (.items {"1" 1 "2" 2}))))
[2 4])))