Updating the tests to not break Python 3.x
This commit is contained in:
parent
fb6ec426e6
commit
b1c605cc6a
@ -166,11 +166,13 @@ class HyASTCompiler(object):
|
|||||||
|
|
||||||
@builds("print")
|
@builds("print")
|
||||||
def compile_print_expression(self, expr):
|
def compile_print_expression(self, expr):
|
||||||
expr.pop(0) # print
|
call = expr.pop(0) # print
|
||||||
if sys.version_info[0] >= 3:
|
if sys.version_info[0] >= 3:
|
||||||
|
call = self.compile(call)
|
||||||
# AST changed with Python 3, we now just call it.
|
# AST changed with Python 3, we now just call it.
|
||||||
return ast.Call(
|
return ast.Call(
|
||||||
func=ast.Name(id='print', ctx=ast.Load()),
|
keywords=[],
|
||||||
|
func=call,
|
||||||
args=[self.compile(x) for x in expr],
|
args=[self.compile(x) for x in expr],
|
||||||
lineno=expr.start_line,
|
lineno=expr.start_line,
|
||||||
col_offset=expr.start_column)
|
col_offset=expr.start_column)
|
||||||
|
@ -206,4 +206,5 @@
|
|||||||
"NATIVE: test list comprehensions"
|
"NATIVE: test list comprehensions"
|
||||||
(assert (= (list-comp (* x 2) (x (range 2))) [0 2]))
|
(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 (* 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])))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user