This commit is contained in:
Yuyao Huang 2024-04-19 19:09:06 +08:00
parent 6e8c8e1998
commit 29c08c08e4
5 changed files with 31 additions and 6 deletions

View File

@ -5,11 +5,7 @@ from tests.test_utils import *
]) ])
def function(): def function():
mystring = 'hello' a, b = 3, 4
print(mystring)
mystring = "hello"
print(mystring)
return 1
print(function()) print(function())

View File

@ -11,3 +11,20 @@ def test_constant():
def target(): def target():
1 1
''') ''')
def test_tuple():
@Commentor("<return>")
def target():
a, b = 1, 2
asserteq_or_print(target(), '''
def target():
a, b = 1, 2
"""
========
1 : a
2 : b
"""
''')

View File

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

View File

@ -1,2 +1,7 @@
def Constant(self, cmtor): def Constant(self, cmtor):
pass pass
def Tuple(self, cmtor):
for x in self.elts:
cmtor.process(x)

View File

@ -1,6 +1,13 @@
import ast
from ..utils import to_source
def Pass(self, cmtor): def Pass(self, cmtor):
pass pass
def Assign(self, cmtor): def Assign(self, cmtor):
cmtor.process(self.value) cmtor.process(self.value)
cmtor.exec(self) cmtor.exec(self)
if type(self.value) not in [ast.Constant]:
cmtor.append_comment("========")
for target in self.targets:
cmtor.process(target)