Skip to content

Commit

Permalink
#7 again, another issue
Browse files Browse the repository at this point in the history
  • Loading branch information
thautwarm committed Aug 9, 2019
1 parent f9c5d7a commit f0c26ca
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ASTGen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,12 @@ function to_ast(filename, python :: Dict)
call(op, apply(left), apply(right))
end

# for Python 3.8+
(Record(:class => "Constant", value)
|| # for Python 3.7- and 3.7
Record(:class => "NameConstant", value)
) -> value

Record(:class=> "Compare", left, ops, comparators) ->
foldl(zip(ops, comparators) |> collect, init=apply(left)) do last, (op, comparator)
let comparator = apply(comparator)
Expand Down
12 changes: 12 additions & 0 deletions test/test_case1.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ result = sum_by(lambda x: x * 10, [1, 2, 3])
@test result == 60
@test sum_by(identity, [1, 2, 3]) === 6
end

py2jl"""
def __BOND_repl():
SENTINEL = 1
Expand All @@ -37,4 +38,15 @@ def __BOND_repl():
@testset "while & compare" begin
@test __BOND_repl() == 1
end

py2jl"""
def __BOND_repl():
SENTINEL = 10
while True:
break
return SENTINEL
"""
@testset "True" begin
@test __BOND_repl() == 10
end
end

0 comments on commit f0c26ca

Please sign in to comment.