Compare()

This commit is contained in:
Yuyao Huang 2024-04-19 19:16:39 +08:00
parent 29c08c08e4
commit 245a927382
4 changed files with 27 additions and 2 deletions

View File

@ -5,7 +5,8 @@ from tests.test_utils import *
])
def function():
a, b = 3, 4
x = 2
print(x == 2)
print(function())

19
tests/test_conditions.py Normal file
View File

@ -0,0 +1,19 @@
from test_utils import *
def test_constant():
@Commentor("<return>")
def target():
x = 2
print(x == 2)
asserteq_or_print(target(), '''
def target():
x = 2
print(x == 2)
"""
True : x == 2
None : print(x == 2)
"""
''')

View File

@ -1,5 +1,5 @@
from .definitions import FunctionDef, Return
from .statements import Pass, Assign
from .expressions import Expr, BinOp, Call
from .expressions import Expr, BinOp, Call, Compare
from .literals import Constant, Tuple
from .variables import Name

View File

@ -6,6 +6,11 @@ def BinOp(self, cmtor):
cmtor.process(self.right)
cmtor.append_comment(cmtor.eval(self))
def Compare(self, cmtor):
for cmp in self.comparators:
cmtor.process(cmp)
cmtor.append_comment(cmtor.eval(self))
def Call(self, cmtor):
for arg in self.args:
cmtor.process(arg)