Skip to content

Commit

Permalink
Merge branch 'c2' into 'master'
Browse files Browse the repository at this point in the history
Python: add a test for Parser and AST classes

See merge request lfortran/lfortran!306
  • Loading branch information
certik committed Aug 30, 2019
2 parents cffc8e8 + edc9164 commit 1e52020
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lfortran/ast/tests/test_cparser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from lfortran.parser.cparser import parse
from lfortran.parser.cparser import parse, Parser, AST

def test_parse1():
assert parse("1+1") == "(+ 1 1)"
Expand All @@ -8,3 +8,15 @@ def test_parse1():
else
a = 2
end if""") == "(if (> x 0) [(= a 1)] [(= a 2)])"

def test_parse2():
p = Parser()
a = p.parse("1+1")
assert a.pickle() == "(+ 1 1)"
a = p.parse("""\
if (x > 0) then
a = 1
else
a = 2
end if""")
assert a.pickle() == "(if (> x 0) [(= a 1)] [(= a 2)])"

0 comments on commit 1e52020

Please sign in to comment.